diff --git a/pages/components/large/comics.tsx b/pages/components/large/comics.tsx
index 8cde5f9..fd90da1 100644
--- a/pages/components/large/comics.tsx
+++ b/pages/components/large/comics.tsx
@@ -1,14 +1,13 @@
-import { BandeDessineeConfig, ParsedContent, TableOfContents } from 'api-types'
+import { ParsedContent, TableOfContents } from 'api-types'
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitleH1 } from '../ui/card'
import { convertJST, convertJSTDate } from '@/lib/time'
import ClientImage from '../small/client_image'
import { rewriteImageURL } from '@/lib/image'
-import { imageOption, originImageOption } from '@/lib/static'
+import { imageOption } from '@/lib/static'
import ArticleContent from '../middle/article_content'
import { Button } from '../ui/button'
import Link from 'next/link'
import { ArrowLeftSquareIcon, ArrowRightSquareIcon, ArrowUpSquareIcon, BookImageIcon, HomeIcon } from 'lucide-react'
-import ComicBook from '../middle/comicbook'
import ShareButton from '../small/share'
import { getHostname } from '@/lib/env'
@@ -26,40 +25,21 @@ type ComicArticleProps = {
seriesName: string | null
tagId: string
tagName: string
+ cover: string | null
+ firstPage: string // 1ページ目のファイル名。結合済みで渡す
parsedDescription: ParsedContent[]
tableOfContents: TableOfContents
}
-type ComicBookProps = {
- id: string
- baseUrl: string
- coverImage: string
- backCoverImage: string
- firstPageNumber: number
- lastPageNumber: number
- firstPageLeftRight: 'left' | 'right'
- format: string
- filename: string
- parsedDescription: ParsedContent[]
- next: string | null
- previous: string | null
- seriesId: string | null
- seriesName: string | null
- tagId: string
- tagName: string
-}
-
export async function ComicOverview(props: ComicArticleProps) {
const contentsUrl = props.contentsUrl
- const contentsJSON = await fetch(contentsUrl)
- const contentsConfig = (await contentsJSON.json()) as BandeDessineeConfig
-
const contentsBaseURL = contentsUrl.replaceAll('/index.json', '')
- // 表紙
- const coverImageOriginURL = contentsBaseURL + '/' + contentsConfig.cover
- const coverImageURL = rewriteImageURL(imageOption, coverImageOriginURL)
+ // 表紙、または1ページ目の画像URL
+ const imageFile = props.cover || props.firstPage
+ const imageOriginURL = contentsBaseURL + '/' + imageFile
+ const imageURL = rewriteImageURL(imageOption, imageOriginURL)
// 説明文
const description = props.parsedDescription
// マンガのタイトル
@@ -67,8 +47,8 @@ export async function ComicOverview(props: ComicArticleProps) {
// マンガページのリンクURL
const linkURL = `/comics/${props.id}`
// 公開日・イベント情報
- const publishDate = props.publishDate ? convertJSTDate(props.publishDate) : 'Web初公開'
- const publishEvent = props.publishEvent ? props.publishEvent : 'Web初公開'
+ const publishDate = props.publishDate ? convertJSTDate(props.publishDate) : '-'
+ const publishEvent = props.publishEvent || '-'
// シリーズ設定
const series = props.seriesName || '-'
// ジャンル設定
@@ -78,8 +58,10 @@ export async function ComicOverview(props: ComicArticleProps) {
-
-
+
+
+
+
@@ -125,37 +107,17 @@ export async function ComicOverview(props: ComicArticleProps) {
)
}
-export async function ComicBookPage(props: ComicBookProps) {
- // 表紙の画像URL
- const coverPageSrc = props.baseUrl + '/' + props.coverImage
- // 裏表紙の画像URL
- const backCoverPageSrc = props.baseUrl + '/' + props.backCoverImage
-
- // 各種ページのソースURL
- const pageSrcArray = Array.from({ length: props.lastPageNumber - props.firstPageNumber + 1 }, (_, i) => {
- return getPageImageSrc(props.baseUrl, props.filename, props.firstPageNumber + i, props.format)
- })
-
- return (
-
-
-
- )
-}
-
-export async function ComicDetailPage(props: ComicArticleProps) {
+export function ComicDetailPage(props: ComicArticleProps) {
const url = getHostname() + '/comics/' + props.id
const isNextExist = props.nextId !== null
const isPreviousExist = props.previousId !== null
const isSereies = props.seriesName !== null
+ const nextLink = isNextExist ? `/comics/${props.nextId}` : ''
+ const previousLink = isPreviousExist ? `/comics/${props.previousId}` : ''
+ const seriesLink = isSereies ? `/comics?series=${props.seriesId}` : ''
- const publishDate = props.publishDate ? convertJSTDate(props.publishDate) : 'Web初公開'
- const publishEvent = props.publishEvent ? props.publishEvent : 'Web初公開'
+ const publishDate = props.publishDate ? convertJSTDate(props.publishDate) : '-'
+ const publishEvent = props.publishEvent || '-'
const seriesName = props.seriesName || '-'
const tagName = props.tagName || '-'
@@ -165,18 +127,18 @@ export async function ComicDetailPage(props: ComicArticleProps) {
{props.titleName}
-
-
+
+
-
+
-
+
@@ -111,7 +138,7 @@ export default function ComicBook(props: ComicBookProps) {
key={i}
className={cn('h-full w-full flex justify-center items-center', i === currentPage ? '' : 'hidden')}
>
-
+
)
case 'pair':
@@ -158,3 +185,9 @@ export default function ComicBook(props: ComicBookProps) {
)
}
+
+function getPageImageSrc(baseUrl: string, filename: string, pageNumber: number, format: string) {
+ // 3桁まで0埋め
+ const pageNumberStr = pageNumber.toString().padStart(3, '0')
+ return `${baseUrl}/${filename}_${pageNumberStr}.${format}`
+}
diff --git a/pages/lib/api/workers.ts b/pages/lib/api/workers.ts
index 0128651..375cfa7 100644
--- a/pages/lib/api/workers.ts
+++ b/pages/lib/api/workers.ts
@@ -143,14 +143,17 @@ async function getBandeDessineeByID(contentID: string, draftKey?: string) {
const host = env.HOST
const url = new URL(host + '/api/cms/bande_dessinee')
url.searchParams.set('content_id', contentID)
- if (draftKey) url.searchParams.set('draftKey', draftKey)
+ url.searchParams.set('draftKey', draftKey || 'undefined')
const cmsAPIKey = env.CMS_FETCHER_API_KEY
const request = new Request(url, { headers: { 'x-api-key': cmsAPIKey }, method: 'GET' })
- const res = await fetch(request, { next: { revalidate: revalidateTime } })
+ console.log('fetch start')
+ const res = await fetch(request, { cache: 'no-store' })
+ console.log('fetch finished')
const data = (await res.json()) as bandeDessineeResult
+ console.log('data set')
return data
}