page.ts
This file
Path
packages/agent-kit/src/docs/page.ts
49 lines · 1.1 KiB · TypeScript
Last changed by
Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import { Brand } from "@repo/brand";
import type { CommandDoc } from "../command-doc.ts";import { code, page } from "../text.ts";import type { DocEntry, DocSlug } from "./entries.ts";
export interface DocInput { readonly commands: readonly CommandDoc[]; readonly platformUrl: string; readonly webUrl: string;}
export interface DocPage extends DocEntry { readonly markdown: string;}
export interface DocSource { readonly slug: DocSlug; readonly body: (input: DocInput) => readonly string[];}
export const written = ( entry: DocEntry, source: DocSource, input: DocInput): DocPage => ({ ...entry, markdown: page([ `# ${entry.title}`, "", entry.summary, "", ...source.body(input), ]),});
export const cli = (words: string) => code(`${Brand.cli} ${words}`);
export const shell = (...lines: readonly string[]) => [ "```sh", ...lines, "```",];
export const withoutHeading = (lines: readonly string[]) => { const [first, blank, ...rest] = lines;
return first?.startsWith("## ") === true && blank === "" ? rest : lines;};