Skip to content

Repository files navigation

@nbtca/docs

Typed GitHub client for the NBTCA documents repository. It lists Markdown documents, reads raw content, caches successful responses, and falls back to stale data after transient failures. Rendering remains the consumer's responsibility.

Install

npm install @nbtca/docs

Usage

import{createDocsClient}from'@nbtca/docs';constdocs=createDocsClient();constsections=awaitdocs.listDir();constdocuments=awaitdocs.listAll();constmarkdown=awaitdocs.getFile('repair/guide.md');constpage=awaitdocs.getDocument('repair/index.md');constmatches=awaitdocs.search('repair',{pathPrefix: 'repair'});

API

createDocsClient(options?)

OptionDefaultDescription
owner'nbtca'GitHub owner
repo'documents'Repository name
branch'main'Branch name or ref
tokenGITHUB_TOKEN or GH_TOKENGitHub token
cacheTtlMs.dir300000Directory and tree cache TTL
cacheTtlMs.file600000File cache TTL

docs.listDir(path?)

Lists directories and Markdown files at a repository-relative path. The root path is used when path is omitted.

docs.getFile(path)

Returns raw file content.

docs.listAll()

Lists every Markdown file through GitHub's recursive tree API.

docs.listSections()

Returns top-level content sections with document counts and optional index paths.

docs.getDocument(path)

Returns content with its route, section, title, summary, and semantic component attributes. Component metadata covers PageHero, FactStrip, LinkCard, Split, TimelineEntry, and Figure without imposing a renderer.

docs.search(query, options?)

Searches paths, titles, summaries, Markdown text, and semantic component attributes. Results are ranked and include excerpts. Use pathPrefix to scope a search and limit to cap results.

docs.clear()

Clears all cached values and in-flight request bookkeeping.

DocsFetchError

Thrown when a request fails without usable stale data. Exposes path and HTTP status.

License

MIT

About

Data-only library for the NBTCA documents repository (nbtca/documents). Fetches and caches directory listings and markdown files from GitHub.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages