Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"build": "next build",
"dev": "next dev --turbo",
"start": "next start",
"lint": "eslint .",
"format": "prettier \"src/**/*.{ts,tsx,js,jsx,json,css}\" \"content/**/*.{md,mdx}\" --write",
"format:check": "prettier \"src/**/*.{ts,tsx,js,jsx,json,css}\" \"content/**/*.{md,mdx}\" --check",
"postinstall": "fumadocs-mdx"
Expand All @@ -31,6 +32,7 @@
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-simple-code-editor": "^0.14.1",
"schema-dts": "^1.1.5",
"sharp": "^0.34.3",
"tailwind-merge": "^3.3.1",
"use-debounce": "^10.0.5"
Expand Down
50 changes: 45 additions & 5 deletions src/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,41 @@ import {
DocsPage,
DocsTitle,
} from "fumadocs-ui/page";
import type { Metadata, ResolvingMetadata } from "next";
import { notFound } from "next/navigation";
import { Article, WithContext } from "schema-dts";

export default async function Page(props: {
params: Promise<{ slug?: string[] }>;
}) {
const params = await props.params;
const page = source.getPage(params.slug);
const owner = "javaistic";
const repo = "javaistic";

if (!page) notFound();

const MDXContent = page.data.body;

const jsonLd: WithContext<Article> = {
"@context": "https://schema.org",
"@type": "Article",
headline: page.data.title,
description: page.data.description,
author: {
"@type": "Organization",
name: "Javaistic",
},
publisher: {
"@type": "Organization",
name: "Javaistic",
},
mainEntityOfPage: {
"@type": "WebPage",
"@id": `https://javaistic.vercel.app${page.url}`,
},
};

return (
<DocsPage
toc={page.data.toc}
Expand All @@ -31,6 +55,7 @@ export default async function Page(props: {
<DocsDescription className="mb-3">
{page.data.description}
</DocsDescription>

<DocsBody>
<MDXContent
components={getMDXComponents({
Expand All @@ -39,6 +64,12 @@ export default async function Page(props: {
})}
/>
</DocsBody>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(jsonLd).replace(/</g, "\\u003c"),
}}
/>
</DocsPage>
);
}
Expand All @@ -47,11 +78,19 @@ export async function generateStaticParams() {
return source.generateParams();
}

export async function generateMetadata(props: {
type Props = {
params: Promise<{ slug?: string[] }>;
}) {
const params = await props.params;
const page = source.getPage(params.slug);
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
};

export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
const { slug } = await params;

const page = source.getPage(slug);

if (!page) notFound();

return {
Expand All @@ -60,7 +99,8 @@ export async function generateMetadata(props: {
openGraph: {
title: `${page.data.title} - Javaistic`,
description: page.data.description,
sitename: "Javaistic",
siteName: "Javaistic",
url: `https://javaistic.vercel.app${page.url}`,
images: `https://og-javaistic.vercel.app/og?title=${page.data.title}`,
},
twitter: {
Expand Down
46 changes: 38 additions & 8 deletions src/app/programs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { programsSource } from "@/lib/source";
import { getMDXComponents } from "@/mdx-components";
import { createRelativeLink } from "fumadocs-ui/mdx";
import {
DocsPage,
DocsBody,
DocsDescription,
DocsPage,
DocsTitle,
} from "fumadocs-ui/page";
import type { Metadata, ResolvingMetadata } from "next";
import { notFound } from "next/navigation";
import { createRelativeLink } from "fumadocs-ui/mdx";
import { getMDXComponents } from "@/mdx-components";
import { HowTo, WithContext } from "schema-dts";

export default async function Page(props: {
params: Promise<{ slug?: string[] }>;
Expand All @@ -18,6 +20,21 @@ export default async function Page(props: {

const MDXContent = page.data.body;

const jsonLd: WithContext<HowTo> = {
"@context": "https://schema.org",
"@type": "HowTo",
name: page.data.title,
description: page.data.description,
provider: {
"@type": "Organization",
name: "Javaistic",
},
mainEntityOfPage: {
"@type": "WebPage",
"@id": `https://javaistic.vercel.app${page.url}`,
},
};

return (
<DocsPage
toc={page.data.toc}
Expand All @@ -36,6 +53,12 @@ export default async function Page(props: {
})}
/>
</DocsBody>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(jsonLd).replace(/</g, "\\u003c"),
}}
/>
</DocsPage>
);
}
Expand All @@ -44,11 +67,17 @@ export async function generateStaticParams() {
return programsSource.generateParams();
}

export async function generateMetadata(props: {
type Props = {
params: Promise<{ slug?: string[] }>;
}) {
const params = await props.params;
const page = programsSource.getPage(params.slug);
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
};

export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
const { slug } = await params;
const page = programsSource.getPage(slug);
if (!page) notFound();

return {
Expand All @@ -57,7 +86,8 @@ export async function generateMetadata(props: {
openGraph: {
title: `${page.data.title} - Javaistic`,
description: page.data.description,
sitename: "Javaistic",
siteName: "Javaistic",
url: `https://javaistic.vercel.app${page.url}`,
images: `https://og-javaistic.vercel.app/og?title=${page.data.title}`,
},
twitter: {
Expand Down
Loading