diff --git a/website/astro.config.mjs b/website/astro.config.mjs index 71f49e92..92929fd6 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -6,7 +6,7 @@ import { pluginTerminal } from "./src/lib/ec-terminal.mjs"; import rehypeExternalLinks from "./src/lib/rehype-external-links.mjs"; import rehypeTableRegions from "./src/lib/rehype-table-regions.mjs"; import { en } from "./src/data/copy/en.ts"; -import { RELEASES_URL } from "./src/data/agents.ts"; +import { DOCS_SIDEBAR } from "./src/data/docs-sidebar.ts"; const SITE = "https://harness-kit.dev"; // The landing's English share image (public/og.png, scripts/og.mjs); share tags want an absolute URL. @@ -93,23 +93,8 @@ export default defineConfig({ { tag: "meta", attrs: { property: "og:image:alt", content: `HarnessKit · ${en.hero.title}` } }, { tag: "meta", attrs: { name: "twitter:image", content: SHARE_IMAGE } }, ], - // Groups start closed; Starlight opens the one holding the current page. - // Each label with its Chinese, as the App's zh UI and the landing name them; the pages under each come from - // their own titles. - // Getting started stays open: it is the group a first visit needs. Troubleshooting and the FAQ sit before - // Contributing, in the order a reader with a problem looks. - sidebar: [ - { label: "Overview", translations: { "zh-CN": "概览" }, slug: "docs" }, - { label: "Getting started", translations: { "zh-CN": "快速开始" }, collapsed: false, autogenerate: { directory: "docs/getting-started" } }, - { label: "Guides", translations: { "zh-CN": "使用指南" }, collapsed: true, autogenerate: { directory: "docs/guides" } }, - { label: "How it works", translations: { "zh-CN": "工作原理" }, collapsed: true, autogenerate: { directory: "docs/how-it-works" } }, - { label: "Reference", translations: { "zh-CN": "参考" }, collapsed: true, autogenerate: { directory: "docs/reference" } }, - { label: "Troubleshooting", translations: { "zh-CN": "常见问题排查" }, slug: "docs/troubleshooting" }, - { label: "FAQ", translations: { "zh-CN": "常见问题" }, slug: "docs/faq" }, - { label: "Contributing", translations: { "zh-CN": "参与贡献" }, collapsed: true, autogenerate: { directory: "docs/contributing" } }, - // The landing footer's Changelog link, so release notes are one click from the docs too. - { label: "Release notes ↗", translations: { "zh-CN": "更新日志 ↗" }, link: RELEASES_URL, attrs: { target: "_blank", rel: "noopener" } }, - ], + // In its own module, which /llms.txt also reads (src/pages/llms.txt.ts). + sidebar: DOCS_SIDEBAR, social: [{ icon: "github", label: "GitHub", href: "https://github.com/RealZST/HarnessKit" }], }), ], diff --git a/website/public/favicon.ico b/website/public/favicon.ico new file mode 100644 index 00000000..d8ef2c26 Binary files /dev/null and b/website/public/favicon.ico differ diff --git a/website/public/favicon.png b/website/public/favicon.png index e12e3a0b..d03bbb69 100644 Binary files a/website/public/favicon.png and b/website/public/favicon.png differ diff --git a/website/src/data/docs-sidebar.ts b/website/src/data/docs-sidebar.ts new file mode 100644 index 00000000..c966ef6a --- /dev/null +++ b/website/src/data/docs-sidebar.ts @@ -0,0 +1,20 @@ +import { RELEASES_URL } from "./agents"; + +// The docs sidebar (astro.config.mjs); /llms.txt lists the docs in the same groups and order (src/pages/llms.txt.ts). +// Groups start closed; Starlight opens the one holding the current page. +// Each label with its Chinese, as the App's zh UI and the landing name them; the pages under each come from +// their own titles. +// Getting started stays open: it is the group a first visit needs. Troubleshooting and the FAQ sit before +// Contributing, in the order a reader with a problem looks. +export const DOCS_SIDEBAR = [ + { label: "Overview", translations: { "zh-CN": "概览" }, slug: "docs" }, + { label: "Getting started", translations: { "zh-CN": "快速开始" }, collapsed: false, autogenerate: { directory: "docs/getting-started" } }, + { label: "Guides", translations: { "zh-CN": "使用指南" }, collapsed: true, autogenerate: { directory: "docs/guides" } }, + { label: "How it works", translations: { "zh-CN": "工作原理" }, collapsed: true, autogenerate: { directory: "docs/how-it-works" } }, + { label: "Reference", translations: { "zh-CN": "参考" }, collapsed: true, autogenerate: { directory: "docs/reference" } }, + { label: "Troubleshooting", translations: { "zh-CN": "常见问题排查" }, slug: "docs/troubleshooting" }, + { label: "FAQ", translations: { "zh-CN": "常见问题" }, slug: "docs/faq" }, + { label: "Contributing", translations: { "zh-CN": "参与贡献" }, collapsed: true, autogenerate: { directory: "docs/contributing" } }, + // The landing footer's Changelog link, so release notes are one click from the docs too. + { label: "Release notes ↗", translations: { "zh-CN": "更新日志 ↗" }, link: RELEASES_URL, attrs: { target: "_blank", rel: "noopener" } }, +]; diff --git a/website/src/pages/llms.txt.ts b/website/src/pages/llms.txt.ts new file mode 100644 index 00000000..cd3734ea --- /dev/null +++ b/website/src/pages/llms.txt.ts @@ -0,0 +1,29 @@ +import type { APIRoute } from "astro"; +import { getCollection, type CollectionEntry } from "astro:content"; +import { en } from "../data/copy/en"; +import { DOCS_SIDEBAR } from "../data/docs-sidebar"; + +// /llms.txt (llmstxt.org): the English docs in the sidebar's groups and order, each page with its frontmatter title +// and description, so the list cannot drift from the docs. The Chinese pages mirror them under /zh/. +type Page = CollectionEntry<"docs">; + +// The docs overview's opening paragraph (src/content/docs/docs/index.mdx), without its headline. +const ABOUT = "Each AI coding agent keeps its skills and settings in its own folder. HarnessKit shows all of them in one window: skills, MCP servers, plugins, hooks and CLIs, for every agent. One click adds a skill or MCP server to another agent. A security audit runs on your computer and gives each extension a trust score. Kits save skills, MCP servers and rules as a set you add to a project in one step. HarnessKit is free and open source, and runs as a desktop app, in the terminal, or in a browser."; + +/** A directory's pages, its index included, in the order of Starlight's autogenerated groups: `sidebar.order`, then id. */ +function pagesIn(pages: Page[], directory: string): Page[] { + const order = (page: Page) => page.data.sidebar.order ?? Number.MAX_VALUE; + return pages.filter(({ id }) => `${id}/`.startsWith(`${directory}/`)).sort((a, b) => order(a) - order(b) || a.id.localeCompare(b.id)); +} + +export const GET: APIRoute = async ({ site }) => { + const pages = await getCollection("docs"); + const link = ({ id, data }: Page) => `- [${data.title}](${new URL(`/${id}/`, site)})${data.description ? `: ${data.description}` : ""}`; + // The sidebar's external link (release notes) is not a docs page, so it gets no section. + const sections = DOCS_SIDEBAR.flatMap(({ label, slug, autogenerate }) => { + const listed = slug ? pages.filter(({ id }) => id === slug) : autogenerate ? pagesIn(pages, autogenerate.directory) : []; + return listed.length ? [`## ${label}\n\n${listed.map(link).join("\n")}`] : []; + }); + const chinese = `Each page is also in [Simplified Chinese](${new URL("/zh/docs/", site)}), at the same path under /zh/.`; + return new Response(["# HarnessKit", `> ${en.footer.tagline}`, ABOUT, chinese, ...sections].join("\n\n") + "\n"); +};