diff --git a/package.json b/package.json index 32d4dd73b..384da9474 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "turbo": "^1.10.16", "typescript": "5.2.2" }, - "packageManager": "pnpm@8.10.4", + "packageManager": "pnpm@8.10.5", "engines": { "node": "^18 <19", "pnpm": "^8 <9" diff --git a/website/app/[caip2]/[asset]/page.tsx b/website/app/[caip2]/[asset]/page.tsx index dba311cd8..4cfa8655f 100644 --- a/website/app/[caip2]/[asset]/page.tsx +++ b/website/app/[caip2]/[asset]/page.tsx @@ -1,33 +1,17 @@ -import { - FrontmatterIndex, - getFrontmatterContent, - getFrontmatterIndexArray, - getInstalledFrontmatterCollection, -} from 'crypto-frontmatter'; +import { FrontmatterContent, FrontmatterIndex, getFrontmatterContent } from 'crypto-frontmatter'; import { Metadata } from 'next'; +import Image from 'next/image'; import { notFound } from 'next/navigation'; import type { ReactElement } from 'react'; +import { Highlighter } from 'shiki'; import { ContentedProse } from '@/components/contented/ContentedProse'; -import { FrontmatterImage } from '@/components/contented/FrontmatterImage'; import { loadHighlighter, ShikiHighlighter } from '@/components/contented/ShikiHighlighter'; function asCaip19(caip2: string, asset: string): string { return `${decodeURIComponent(caip2)}/${decodeURIComponent(asset)}`; } -export async function generateStaticParams(): Promise[0]['params'][]> { - const params: Parameters[0]['params'][] = []; - const collections = await getInstalledFrontmatterCollection(); - for (const { caip2, namespace } of collections) { - for (const index of await getFrontmatterIndexArray(caip2, namespace)) { - const [caip2, asset] = index.path.split('/'); - params.push({ caip2, asset }); - } - } - return params; -} - export async function generateMetadata(props: Parameters[0]): Promise { const baseUrl = process.env.BASE_URL!; const caip19 = asCaip19(props.params.caip2, props.params.asset); @@ -60,44 +44,57 @@ export default async function Page(props: { }; }): Promise { const caip19 = asCaip19(props.params.caip2, props.params.asset); - const frontmatterContent = await getFrontmatterContent(caip19); - if (frontmatterContent === undefined) { + const content = await getFrontmatterContent(caip19); + if (content === undefined) { return notFound(); } - const highlighter = await loadHighlighter(); + const image = content.fields.images?.find((image) => image.type === 'logo'); return (
-
- -
+ {image !== undefined && ( +
+ {`${content.fields.symbol} +
+ )} - + -
-
-
Frontmatter.json
-
- - -
-
+ +
+
+ ); +} -
- -
+function FrontmatterJson(props: { content: FrontmatterContent; highlighter: Highlighter }): ReactElement { + return ( +
+
+
Frontmatter.json
+
+ +
+
+ +
+
- +
); } diff --git a/website/components/contented/FrontmatterImage.tsx b/website/components/contented/FrontmatterImage.tsx deleted file mode 100644 index c3a131212..000000000 --- a/website/components/contented/FrontmatterImage.tsx +++ /dev/null @@ -1,20 +0,0 @@ -'use client'; -import type { FrontmatterIndex } from 'crypto-frontmatter'; -import Image from 'next/image'; -import type { ReactElement } from 'react'; - -export function FrontmatterImage(props: { frontmatter: FrontmatterIndex; type: 'logo' }): ReactElement { - const image = props.frontmatter.fields.images?.find((image) => image.type === props.type); - if (image === undefined) { - return <>; - } - - return ( - {`${props.frontmatter.fields.symbol} - ); -}