Skip to content

Commit

Permalink
[Fix] React component サブディレクトリ時のpath変更対応
Browse files Browse the repository at this point in the history
  • Loading branch information
naoki-00-ito committed Aug 13, 2024
1 parent d577e0e commit e7e8de7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "astro dev",
"dev:gh-pages": "TARGET=gh-pages astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"build:gh-pages": "astro check && TARGET=gh-pages astro build",
Expand Down
8 changes: 4 additions & 4 deletions src/components/WorksSlide/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import React, { useState, useRef } from 'react';
import TitleVertical from '../TitleVertical';
import scrollSlide from './scrollSlide';
import filters from '@/data/filters';
import updatePath from '@/libs/updatePath';

type Props = {
title: string;
titleEn: string;
items: Work[];
path: string;
};

const WorksSlide = ({ title, titleEn, items }: Props) => {
const WorksSlide = ({ title, titleEn, items, path }: Props) => {
const [selectedOption, setSelectedOption] = useState('ALL');
const [open, setOpen] = useState(false);
const wrapper = useRef<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -55,13 +55,13 @@ const WorksSlide = ({ title, titleEn, items }: Props) => {
}
>
<a
href={updatePath(`/works/${item.slug}/`)}
href={`${path}/works/${item.slug}/`}
className="ts-image-link flex flex-col h-full"
>
<div className="flex flex-1">
<picture className="flex-1">
<img
src={updatePath(item.image)}
src={`${path}${item.image}`}
alt={item.title}
className="w-full h-full object-cover"
/>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/works.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Layout from '@/layouts/Layout.astro';
import WorksSlide from '@/components/WorksSlide';
import works from '@/data/works';
import Stalker from '@/components/Stalker';
const path = import.meta.env.TARGET === 'gh-pages' ? '/st-portfolio' : '';
const title = '制作実績';
const titleEn = 'WORKS';
---
Expand All @@ -12,6 +13,7 @@ const titleEn = 'WORKS';
title={title}
titleEn={titleEn}
items={works}
path={path}
client:only="react"
/>
<Stalker client:only="react" />
Expand Down

0 comments on commit e7e8de7

Please sign in to comment.