diff --git a/src/app/site/[site]/[slug]/page.tsx b/src/app/site/[site]/[slug]/page.tsx index a4820492..5e224d3b 100644 --- a/src/app/site/[site]/[slug]/page.tsx +++ b/src/app/site/[site]/[slug]/page.tsx @@ -5,6 +5,7 @@ import serialize from "serialize-javascript" import { Hydrate, dehydrate } from "@tanstack/react-query" import { PageContent } from "~/components/common/PageContent" +import { OIAButton } from "~/components/site/OIAButton" import { PostFooter } from "~/components/site/PostFooter" import PostMeta from "~/components/site/PostMeta" import { SITE_URL } from "~/lib/env" @@ -155,6 +156,7 @@ export default async function SitePagePage({ site={site} withActions={true} /> + {!onlyContent && ( diff --git a/src/components/site/OIAButton.tsx b/src/components/site/OIAButton.tsx new file mode 100644 index 00000000..a8e3f3c1 --- /dev/null +++ b/src/components/site/OIAButton.tsx @@ -0,0 +1,49 @@ +"use client" + +import React, { useCallback, useEffect, useState } from "react" + +import { useIsMobileLayout } from "~/hooks/useMobileLayout" +import { useTranslation } from "~/lib/i18n/client" + +export const OIAButton: React.FC<{ + link: `/${string}` +}> = ({ link }) => { + const { t, i18n } = useTranslation("site") + const [isVisible, setIsVisible] = useState(true) + + const oia = useCallback(() => { + window.open(`https://oia.xlog.app${link}`, "_blank") + }, []) + + const isMobileLayout = useIsMobileLayout() + + useEffect(() => { + if (!isMobileLayout) { + return + } + + let timeoutId: ReturnType | null = null + const handleScroll = () => { + setIsVisible(false) + timeoutId && clearTimeout(timeoutId) + timeoutId = setTimeout(() => setIsVisible(true), 1000) + } + window.addEventListener("scroll", handleScroll) + return () => window.removeEventListener("scroll", handleScroll) + }, [isMobileLayout]) + + if (!isMobileLayout) { + return null + } + + return ( + + ) +} diff --git a/src/lib/i18n/locales/ja/site.json b/src/lib/i18n/locales/ja/site.json index 626c40f4..2d5a4610 100644 --- a/src/lib/i18n/locales/ja/site.json +++ b/src/lib/i18n/locales/ja/site.json @@ -6,5 +6,6 @@ "load more": "まだ{{count}}件の{{name}}があります。", "signed and stored on the blockchain": "{{name}}は、創作者によって署名され、ブロックチェーンに安全に保存されています。", "Write a comment on the blockchain": "ブロックチェーンでコメントする", + "Open in App": "アプリで開く", "powered by": "このサイトは  によって作動します" } diff --git a/src/lib/i18n/locales/zh-TW/site.json b/src/lib/i18n/locales/zh-TW/site.json index b493986b..3d380999 100644 --- a/src/lib/i18n/locales/zh-TW/site.json +++ b/src/lib/i18n/locales/zh-TW/site.json @@ -18,5 +18,6 @@ "404 - Whoops, this page is gone.": "404 - 哎呀,這個頁面不見了。", "Back to Home": "回到首頁", "All Posts": "所有文章", + "Open in App": "在 App 中開啟", "Search Posts": "搜尋文章" } \ No newline at end of file diff --git a/src/lib/i18n/locales/zh/site.json b/src/lib/i18n/locales/zh/site.json index 2a4e6611..12874157 100644 --- a/src/lib/i18n/locales/zh/site.json +++ b/src/lib/i18n/locales/zh/site.json @@ -19,5 +19,6 @@ "404 - Whoops, this page is gone.": "404 - 哎呀,这个页面不见了。", "Back to Home": "返回主页", "All Posts": "所有文章", + "Open in App": "在 App 中打开", "Search Posts": "搜索文章" } \ No newline at end of file