mirror of
https://github.com/vercel/chat.git
synced 2026-09-14 18:32:29 +08:00
5a72259fbc
SEO/AEO improvements for the docs site: - Append `| Chat SDK` to every page's `<title>` and `og:title` (home stays `Chat SDK`). - Expose a plain-markdown version of every docs and adapter page via an `sr-only` AI/LLM hint link and a `text/markdown` alternate; adapter pages get a new `/adapters/<group>/<slug>.md` endpoint. - Turn `llms.txt` into a sitemap-style index linking to each page's markdown, and move the full-text concatenation to `llms-full.txt`. A `<link rel="llms-txt">` is added to every page. --------- Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { type InferPageType, loader } from "fumadocs-core/source";
|
|
import { adapters } from "@/.source/server";
|
|
import { basePath } from "@/geistdocs";
|
|
import { i18n } from "./i18n";
|
|
|
|
export const adaptersSource = loader({
|
|
i18n,
|
|
baseUrl: "/adapters",
|
|
source: adapters.toFumadocsSource(),
|
|
});
|
|
|
|
export type AdapterPage = InferPageType<typeof adaptersSource>;
|
|
|
|
export const getAdapterPageImage = (page: AdapterPage) => {
|
|
const segments = [...page.slugs, "image.png"];
|
|
|
|
return {
|
|
segments,
|
|
url: basePath
|
|
? `${basePath}/og/${segments.join("/")}`
|
|
: `/og/${segments.join("/")}`,
|
|
};
|
|
};
|
|
|
|
export const getAdapterLLMText = async (page: AdapterPage, body?: string) => {
|
|
const content = body ?? (await page.data.getText("processed"));
|
|
const { title, description } = page.data;
|
|
const { packageName, tagline } = page.data as unknown as {
|
|
packageName?: string;
|
|
tagline?: string;
|
|
};
|
|
|
|
const frontmatter = [
|
|
"---",
|
|
`title: ${title}`,
|
|
description && `description: ${description}`,
|
|
tagline && `tagline: ${tagline}`,
|
|
packageName && `package: ${packageName}`,
|
|
"---",
|
|
]
|
|
.filter(Boolean)
|
|
.join("\n");
|
|
|
|
return `${frontmatter}
|
|
|
|
# ${title}
|
|
|
|
${content}`;
|
|
};
|