From 0acca62436a3521c67b3be423b07a57f9e829def Mon Sep 17 00:00:00 2001 From: Fushihara <1039534+fushihara@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:24:00 +0900 Subject: =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=AF=E4=B8=80=E8=A6=A7=E3=82=92?= =?UTF-8?q?=E5=80=8B=E5=88=A5=E3=82=A8=E3=83=AC=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=AB=E5=88=87=E3=82=8A=E5=87=BA=E3=81=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/_components/archiveLinkElement.tsx | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/app/_components/archiveLinkElement.tsx (limited to 'src/app/_components/archiveLinkElement.tsx') diff --git a/src/app/_components/archiveLinkElement.tsx b/src/app/_components/archiveLinkElement.tsx new file mode 100644 index 0000000..d97d904 --- /dev/null +++ b/src/app/_components/archiveLinkElement.tsx @@ -0,0 +1,84 @@ +import Link from "next/link"; +type ArticlePage = { + type: "article", + articleId: number, + subPageNumber?: number, +} +type AnimeTop = { + type: "animeTop", + animeId: number, +}; +type AnimeReviewList = { + type: "animeReviewList", + animeId: number, + /** 0始まり */ + pageNumber: number, +}; +type AnimeReviewItem = { + type: "AnimeReviewItem", + animeId: number, + reviewId: number, +}; +type Common = { showLinkUnderline?: boolean } +type Option = (ArticlePage | AnimeTop | AnimeReviewList | AnimeReviewItem) & Common; +export function ArciveLinkElement(option: Option) { + const officialLinkTitle = `公式のakiba-souken.com へのリンク。閉鎖後は繋がらなくなるはず`; + const iaSearchResultLinkTitle = `InternetArchive の検索結果へのリンク`; + const iframeLinkTitle = `Iframeを使ってInternetArchiveに記録されたアーカイブを表示します`; + let originalUrl = ""; + let iframeSrc = ""; + let suffixPrivate: JSX.Element = <>; + let className = ""; + if (option.type == "article") { + if (option.subPageNumber == null) { + originalUrl = `https://akiba-souken.com/article/${option.articleId}/`; + iframeSrc = `article-${option.articleId}`; + } else { + originalUrl = `https://akiba-souken.com/article/${option.articleId}/?page=${option.subPageNumber}`; + iframeSrc = `article-${option.articleId}-${option.subPageNumber}`; + suffixPrivate = <>Page:{option.subPageNumber} + } + } else if (option.type == "animeTop") { + originalUrl = `https://akiba-souken.com/anime/${option.animeId}/`; + iframeSrc = `anime-${option.animeId}` + } else if (option.type == "animeReviewList") { + if (option.pageNumber == 0) { + originalUrl = `https://akiba-souken.com/anime/${option.animeId}/review/`; + iframeSrc = `anime-${option.animeId}-review` + } else { + const page = option.pageNumber + 1; + originalUrl = `https://akiba-souken.com/anime/${option.animeId}/?page=${page}`; + iframeSrc = `anime-${option.animeId}-review-p${page}` + } + } else if (option.type == "AnimeReviewItem") { + originalUrl = `https://akiba-souken.com/anime/${option.animeId}/review/${option.reviewId}`; + iframeSrc = `anime-${option.animeId}-review-${option.reviewId}`; + } else { + throw new Error(); + } + if (option.showLinkUnderline == true) { + className = `original-href`; + } + return ( + <> + 公式 + IA検索結果 + IAをiframe + {suffixPrivate} + + ) +} \ No newline at end of file -- cgit v1.2.3