docs: replace the typedoc site with VitePress (v2 + v1 reface) (#2395)
This commit is contained in:
parent
801111ea15
commit
732abe0ac4
1 changed files with 1996 additions and 270 deletions
32
scripts/build-docs-index.ts
Normal file
32
scripts/build-docs-index.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Generate docs/index.md (the V2 site's landing page) from the repository README.
|
||||
*
|
||||
* The docs site lands on the README — the same model as the V1 site — so the README
|
||||
* stays the single source of truth and the landing page can never drift from it.
|
||||
* Links that only resolve on GitHub are rewritten for the site:
|
||||
* - `docs/<page>.md` -> `./<page>.md` (index.md sits next to the guide pages)
|
||||
* - other repo paths -> the GitHub blob URL
|
||||
*/
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const GITHUB = 'https://github.com/modelcontextprotocol/typescript-sdk/blob/main';
|
||||
|
||||
let markdown = readFileSync(join(repoRoot, 'README.md'), 'utf8');
|
||||
|
||||
markdown = markdown
|
||||
// The README's "API docs" link points at the old typedoc site; on the landing it is the
|
||||
// in-site API Reference section.
|
||||
.replaceAll('](https://modelcontextprotocol.github.io/typescript-sdk/)', '](./api/index.md)')
|
||||
.replaceAll('](docs/', '](./')
|
||||
.replaceAll('](packages/', `](${GITHUB}/packages/`)
|
||||
.replaceAll('](examples/', `](${GITHUB}/examples/`)
|
||||
.replaceAll('](LICENSE)', `](${GITHUB}/LICENSE)`)
|
||||
.replaceAll('](CONTRIBUTING.md)', `](${GITHUB}/CONTRIBUTING.md)`)
|
||||
.replaceAll('](SECURITY.md)', `](${GITHUB}/SECURITY.md)`)
|
||||
.replaceAll('](CODE_OF_CONDUCT.md)', `](${GITHUB}/CODE_OF_CONDUCT.md)`);
|
||||
|
||||
writeFileSync(join(repoRoot, 'docs', 'index.md'), markdown);
|
||||
console.log('docs/index.md generated from README.md');
|
||||
Loading…
Reference in a new issue