@se-studio/markdown-renderer 2.0.16 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +4 -0
  3. package/dist/siteFiles/handlers.d.ts +29 -0
  4. package/dist/siteFiles/handlers.d.ts.map +1 -0
  5. package/dist/siteFiles/handlers.js +80 -0
  6. package/dist/siteFiles/handlers.js.map +1 -0
  7. package/dist/siteFiles/helpers.d.ts +53 -0
  8. package/dist/siteFiles/helpers.d.ts.map +1 -0
  9. package/dist/siteFiles/helpers.js +114 -0
  10. package/dist/siteFiles/helpers.js.map +1 -0
  11. package/dist/siteFiles/index.d.ts +8 -0
  12. package/dist/siteFiles/index.d.ts.map +1 -0
  13. package/dist/siteFiles/index.js +8 -0
  14. package/dist/siteFiles/index.js.map +1 -0
  15. package/dist/siteFiles/llmsFull.d.ts +37 -0
  16. package/dist/siteFiles/llmsFull.d.ts.map +1 -0
  17. package/dist/siteFiles/llmsFull.js +82 -0
  18. package/dist/siteFiles/llmsFull.js.map +1 -0
  19. package/dist/siteFiles/llmsTxt.d.ts +49 -0
  20. package/dist/siteFiles/llmsTxt.d.ts.map +1 -0
  21. package/dist/siteFiles/llmsTxt.js +73 -0
  22. package/dist/siteFiles/llmsTxt.js.map +1 -0
  23. package/dist/siteFiles/markdownIndex.d.ts +14 -0
  24. package/dist/siteFiles/markdownIndex.d.ts.map +1 -0
  25. package/dist/siteFiles/markdownIndex.js +28 -0
  26. package/dist/siteFiles/markdownIndex.js.map +1 -0
  27. package/dist/siteFiles/siteInfo.d.ts +60 -0
  28. package/dist/siteFiles/siteInfo.d.ts.map +1 -0
  29. package/dist/siteFiles/siteInfo.js +251 -0
  30. package/dist/siteFiles/siteInfo.js.map +1 -0
  31. package/dist/siteFiles/types.d.ts +100 -0
  32. package/dist/siteFiles/types.d.ts.map +1 -0
  33. package/dist/siteFiles/types.js +2 -0
  34. package/dist/siteFiles/types.js.map +1 -0
  35. package/docs/llms.md +37 -1
  36. package/package.json +6 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @se-studio/markdown-renderer
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8e93a52: Config-driven site files, step 3: `llms.txt`, `llms-full.txt`, `site-info.md`, `markdown-index.txt`.
8
+
9
+ - `markdown-renderer`: new `@se-studio/markdown-renderer/site-files` entry with pure builders and `Response` handler factories (`createSiteLlmsTxtHandler`, `createLlmsFullTxtHandler`, `createSiteInfoHandler`, `createMarkdownIndexHandler`), the shared `SiteContent` description, and the generic helpers `selectKeyPages`, `selectLatestArticles`, `oneLine`, `isSitePath`, `countArticles`, `buildMarkdownUrlPattern`. `llms-full.txt` is opt-in and bounded.
10
+ - `core-ui`: `SiteFilesConfig` gains `content`, `llms`, `llmsFull`, `siteInfo` and `markdownIndex`; new route factories `llmsTxtRoute`, `llmsFullTxtRoute`, `siteInfoRoute`, `markdownIndexRoute`. A missing section answers 404 and never throws at import. New dependency on `@se-studio/markdown-renderer`.
11
+ - `project-build`: `generate-marketing-routes --write` also writes the four discovery routes (with a literal `revalidate = 3600`) for a site that has `src/lib/site-files.config.ts`.
12
+
13
+ The template app's `llms.txt`, `site-info.md` and `markdown-index.txt` now come from these factories, so their output changes (latest articles, documents hook and fuller site-info) compared with the old hand-written template routes.
14
+
15
+ ## 2.0.17
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [c749645]
20
+ - @se-studio/contentful-rest-api@2.10.0
21
+
3
22
  ## 2.0.16
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -90,6 +90,10 @@ Options:
90
90
 
91
91
  Sites that serve those indexes pass the same slugs to `buildMarkdownLinksFromAppLinks` as `personTypeLinks` (href from `urlCalculators.personType`, title from the type). `generateMarkdownIndex` then appends each internal href as a `.md` URL. Omit the option, or pass no links, and the index is unchanged.
92
92
 
93
+ ### Site files (`@se-studio/markdown-renderer/site-files`)
94
+
95
+ Config-driven `llms.txt`, `llms-full.txt` (opt-in), `site-info.md` and `markdown-index.txt` as pure builders and `Response` handlers: `createSiteLlmsTxtHandler`, `createLlmsFullTxtHandler`, `createSiteInfoHandler`, `createMarkdownIndexHandler`, fed by one `SiteContent` object. See [docs/llms.md](docs/llms.md#site-files-se-studiomarkdown-renderersite-files).
96
+
93
97
  ### Custom hero converters
94
98
 
95
99
  `Article hero`, `Person hero`, and `Person bio` are not built-in exports. A site owns those three types by registering a `markdownConverter` on the component registration and passing `customConverters` to `MarkdownConverter.convert` and search indexing. Without a converter they use the generic component renderer (component heading, copy, and visual only). Apps with other custom hero components (e.g. `Publications Hero`, `News Hero`) do the same.
@@ -0,0 +1,29 @@
1
+ import { type LlmsFullSettings } from './llmsFull';
2
+ import { type LlmsTxtSettings } from './llmsTxt';
3
+ import { type MarkdownIndexSettings } from './markdownIndex';
4
+ import { type SiteInfoSettings } from './siteInfo';
5
+ import type { SiteContent } from './types';
6
+ /** The inputs every site-file handler needs: the site's absolute base URL and its content description. */
7
+ export interface SiteFileHandlerOptions {
8
+ baseUrl: string;
9
+ content: SiteContent;
10
+ }
11
+ /** A route handler: a standard `Response`, so it works as a Next.js `GET` without importing `next`. */
12
+ export type SiteFileHandler = () => Promise<Response>;
13
+ /** `llms.txt`: key pages, latest articles, optional documents, markdown URL pattern and Optional links. */
14
+ export declare function createSiteLlmsTxtHandler(options: SiteFileHandlerOptions & {
15
+ settings?: LlmsTxtSettings;
16
+ }): SiteFileHandler;
17
+ /** `llms-full.txt`: the llms.txt header and the full markdown of the key pages and latest articles. */
18
+ export declare function createLlmsFullTxtHandler(options: SiteFileHandlerOptions & {
19
+ settings: LlmsFullSettings;
20
+ }): SiteFileHandler;
21
+ /** `site-info.md`: counts and lists of the site's content; the clock is injectable through `settings.now`. */
22
+ export declare function createSiteInfoHandler(options: SiteFileHandlerOptions & {
23
+ settings?: SiteInfoSettings;
24
+ }): SiteFileHandler;
25
+ /** `markdown-index.txt`: the absolute `.md` URL of every page, article and optional section. */
26
+ export declare function createMarkdownIndexHandler(options: SiteFileHandlerOptions & {
27
+ settings?: MarkdownIndexSettings;
28
+ }): SiteFileHandler;
29
+ //# sourceMappingURL=handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../src/siteFiles/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,SAAS,CAAC;AAI9D,0GAA0G;AAC1G,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,uGAAuG;AACvG,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;AAUtD,2GAA2G;AAC3G,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,sBAAsB,GAAG;IAAE,QAAQ,CAAC,EAAE,eAAe,CAAA;CAAE,GAC/D,eAAe,CAmBjB;AAED,uGAAuG;AACvG,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,sBAAsB,GAAG;IAAE,QAAQ,EAAE,gBAAgB,CAAA;CAAE,GAC/D,eAAe,CAejB;AAED,8GAA8G;AAC9G,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAAG;IAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAAE,GAChE,eAAe,CAwBjB;AAED,gGAAgG;AAChG,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,sBAAsB,GAAG;IAAE,QAAQ,CAAC,EAAE,qBAAqB,CAAA;CAAE,GACrE,eAAe,CAKjB"}
@@ -0,0 +1,80 @@
1
+ import { buildLlmsFullTxt } from './llmsFull';
2
+ import { buildSiteLlmsTxt } from './llmsTxt';
3
+ import { buildSiteMarkdownIndex, fetchMarkdownIndexLinks, } from './markdownIndex';
4
+ import { buildSiteInfoMarkdown } from './siteInfo';
5
+ const PLAIN_TEXT = 'text/plain; charset=utf-8';
6
+ function plainResponse(body, contentType = PLAIN_TEXT, extraHeaders) {
7
+ return new Response(body, { headers: { 'Content-Type': contentType, ...extraHeaders } });
8
+ }
9
+ /** `llms.txt`: key pages, latest articles, optional documents, markdown URL pattern and Optional links. */
10
+ export function createSiteLlmsTxtHandler(options) {
11
+ return async () => {
12
+ const [pageRes, articleRes] = await Promise.all([
13
+ options.content.getAllPageLinks(),
14
+ options.content.getAllArticleLinks(),
15
+ ]);
16
+ const discovery = options.settings?.getPageDiscovery
17
+ ? await options.settings.getPageDiscovery(pageRes.data)
18
+ : undefined;
19
+ const body = buildSiteLlmsTxt({
20
+ baseUrl: options.baseUrl,
21
+ content: options.content,
22
+ pages: pageRes.data,
23
+ articles: articleRes.data,
24
+ ...(discovery ? { discovery } : {}),
25
+ ...(options.settings ? { settings: options.settings } : {}),
26
+ });
27
+ return plainResponse(body);
28
+ };
29
+ }
30
+ /** `llms-full.txt`: the llms.txt header and the full markdown of the key pages and latest articles. */
31
+ export function createLlmsFullTxtHandler(options) {
32
+ return async () => {
33
+ const [pageRes, articleRes] = await Promise.all([
34
+ options.content.getAllPageLinks(),
35
+ options.content.getAllArticleLinks(),
36
+ ]);
37
+ const body = await buildLlmsFullTxt({
38
+ baseUrl: options.baseUrl,
39
+ content: options.content,
40
+ pages: pageRes.data,
41
+ articles: articleRes.data,
42
+ settings: options.settings,
43
+ });
44
+ return plainResponse(body);
45
+ };
46
+ }
47
+ /** `site-info.md`: counts and lists of the site's content; the clock is injectable through `settings.now`. */
48
+ export function createSiteInfoHandler(options) {
49
+ return async () => {
50
+ const { content } = options;
51
+ const empty = { data: [] };
52
+ const [pageRes, articleRes, personRes, tagRes] = await Promise.all([
53
+ content.getAllPageLinks(),
54
+ content.getAllArticleLinks(),
55
+ content.enablePerson && content.getAllPersonLinks ? content.getAllPersonLinks() : empty,
56
+ content.enableTag && content.getAllTagLinks ? content.getAllTagLinks() : empty,
57
+ ]);
58
+ const body = buildSiteInfoMarkdown({
59
+ baseUrl: options.baseUrl,
60
+ content,
61
+ pages: pageRes.data ?? [],
62
+ articles: articleRes.data ?? [],
63
+ persons: personRes.data ?? [],
64
+ tagLinks: tagRes.data ?? [],
65
+ ...(options.settings ? { settings: options.settings } : {}),
66
+ now: (options.settings?.now ?? (() => new Date()))(),
67
+ });
68
+ return plainResponse(body, 'text/markdown; charset=utf-8', {
69
+ 'Cache-Control': 'public, s-maxage=3600, stale-while-revalidate',
70
+ });
71
+ };
72
+ }
73
+ /** `markdown-index.txt`: the absolute `.md` URL of every page, article and optional section. */
74
+ export function createMarkdownIndexHandler(options) {
75
+ return async () => {
76
+ const links = await fetchMarkdownIndexLinks(options.content);
77
+ return plainResponse(buildSiteMarkdownIndex(links, options.baseUrl, options.settings));
78
+ };
79
+ }
80
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../src/siteFiles/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAyB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAwB,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GAExB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAyB,MAAM,YAAY,CAAC;AAG1E,MAAM,UAAU,GAAG,2BAA2B,CAAC;AAW/C,SAAS,aAAa,CACpB,IAAY,EACZ,WAAW,GAAG,UAAU,EACxB,YAAqC;IAErC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,OA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AC7B,QAAQ,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;YAC3B,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3D,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,EAAE;SACrD,CAAC,CAAC;QACH,OAAO,aAAa,CAAC,IAAI,EAAE,8BAA8B,EAAE;YACzD,eAAe,EAAE,+CAA+C;SACjE,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,0BAA0B,CACxC,OAAsE;IAEtE,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,KAAK,GAAG,MAAM,uBAAuB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC7D,OAAO,aAAa,CAAC,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzF,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { SiteArticleLink, SiteArticleTypeRoute, SiteContent, SitePageLink } from './types';
2
+ /** True for a path on this site; false for an absolute URL to another host. */
3
+ export declare function isSitePath(href: string | undefined | null): href is string;
4
+ /** One line, no markdown breakers, for a description after a link. */
5
+ export declare function oneLine(text: string | null | undefined): string | undefined;
6
+ /** On-site pages that are meant to be indexed, home first, then CMS order. */
7
+ export declare function selectKeyPages<T extends SitePageLink>(pages: readonly T[]): T[];
8
+ /** Newest first. Only articles with an on-site page that are not excluded from indexing. */
9
+ export declare function selectLatestArticles<T extends SiteArticleLink>(articles: readonly T[], limit: number): T[];
10
+ /** Article counts used by `site-info.md`. */
11
+ export interface SiteArticleCounts {
12
+ total: number;
13
+ onSite: number;
14
+ externalOnly: number;
15
+ withDownload: number;
16
+ }
17
+ /**
18
+ * Counts for `site-info.md`. A download does not make an article download-only: an article can have an
19
+ * on-site page and a file.
20
+ */
21
+ export declare function countArticles(articles: readonly SiteArticleLink[]): SiteArticleCounts;
22
+ /** The routing facts the markdown URL pattern sentence is built from. */
23
+ export interface MarkdownUrlPatternInput {
24
+ enableArticleTypeIndex?: boolean;
25
+ enablePrimaryTagPartOfSlug?: boolean;
26
+ enablePerson?: boolean;
27
+ articlesSlug?: string;
28
+ articleTypeRoutes?: readonly SiteArticleTypeRoute[];
29
+ peopleSlug?: string;
30
+ personTypeSlugs?: readonly string[];
31
+ tagsSlug?: string;
32
+ tagTypeSlugs?: readonly string[];
33
+ }
34
+ /**
35
+ * The "Append .md to any page URL..." sentence for the Markdown access section of `llms.txt`. It lists the
36
+ * page, article, team and tag URL shapes the site really has, including the `{topic}` segment when the
37
+ * primary tag is part of the article slug.
38
+ */
39
+ export declare function buildMarkdownUrlPattern(input: MarkdownUrlPatternInput): string;
40
+ /** Default `articleIndexPath`: the type's route index, else under the articles base, else `/{type}/`. */
41
+ export declare function defaultArticleIndexPath(content: SiteContent, articleTypeSlug: string): string;
42
+ /** Default `teamIndexPath`: the people base, else the only person type, else the site root. */
43
+ export declare function defaultTeamIndexPath(content: SiteContent): string;
44
+ /** Default `tagUrl`: under the tags base when the site has one, else `/{tag}/`. */
45
+ export declare function defaultTagUrl(content: SiteContent, tagSlug: string): string;
46
+ /** Resolved URL helpers for a site: its own when configured, else the defaults. */
47
+ export declare function resolveSiteUrls(content: SiteContent): {
48
+ articleIndexPath: (articleTypeSlug: string) => string;
49
+ teamIndexPath: () => string;
50
+ tagUrl: (tagSlug: string) => string;
51
+ tagsBase: string;
52
+ };
53
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/siteFiles/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,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;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAmC9E;AAMD,yGAAyG;AACzG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAO7F;AAED,+FAA+F;AAC/F,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAOjE;AAED,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAI3E;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG;IACrD,gBAAgB,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC;IACtD,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAQA"}
@@ -0,0 +1,114 @@
1
+ /** True for a path on this site; false for an absolute URL to another host. */
2
+ export function isSitePath(href) {
3
+ return typeof href === 'string' && href.startsWith('/') && !href.startsWith('//');
4
+ }
5
+ /** One line, no markdown breakers, for a description after a link. */
6
+ export function oneLine(text) {
7
+ const value = text?.replace(/\s+/g, ' ').trim();
8
+ return value ? value : undefined;
9
+ }
10
+ /** On-site pages that are meant to be indexed, home first, then CMS order. */
11
+ export function selectKeyPages(pages) {
12
+ const eligible = pages.filter((page) => isSitePath(page.href) && page.indexed !== false && page.hidden !== true);
13
+ const home = eligible.filter((page) => page.href === '/');
14
+ const rest = eligible.filter((page) => page.href !== '/');
15
+ return [...home, ...rest];
16
+ }
17
+ /** Newest first. Only articles with an on-site page that are not excluded from indexing. */
18
+ export function selectLatestArticles(articles, limit) {
19
+ return articles
20
+ .filter((article) => isSitePath(article.href) && article.indexed !== false)
21
+ .sort((a, b) => Date.parse(b.date ?? '') - Date.parse(a.date ?? '') || 0)
22
+ .slice(0, limit);
23
+ }
24
+ /**
25
+ * Counts for `site-info.md`. A download does not make an article download-only: an article can have an
26
+ * on-site page and a file.
27
+ */
28
+ export function countArticles(articles) {
29
+ const onSite = articles.filter((article) => isSitePath(article.href)).length;
30
+ return {
31
+ total: articles.length,
32
+ onSite,
33
+ externalOnly: articles.length - onSite,
34
+ withDownload: articles.filter((article) => Boolean(article.download)).length,
35
+ };
36
+ }
37
+ /**
38
+ * The "Append .md to any page URL..." sentence for the Markdown access section of `llms.txt`. It lists the
39
+ * page, article, team and tag URL shapes the site really has, including the `{topic}` segment when the
40
+ * primary tag is part of the article slug.
41
+ */
42
+ export function buildMarkdownUrlPattern(input) {
43
+ const routes = input.articleTypeRoutes ?? [];
44
+ const personTypeSlugs = input.personTypeSlugs ?? [];
45
+ const topic = input.enablePrimaryTagPartOfSlug;
46
+ const articlesSlug = input.articlesSlug ?? '';
47
+ const articlePatterns = input.enableArticleTypeIndex && routes.length > 0
48
+ ? routes.map((route) => {
49
+ const base = route.articlePath.replace(/\/$/, '');
50
+ const pattern = topic ? `\`${base}/{topic}/{slug}.md\`` : `\`${base}/{slug}.md\``;
51
+ return `Articles (${route.slug}): ${pattern}`;
52
+ })
53
+ : [
54
+ input.enableArticleTypeIndex
55
+ ? topic
56
+ ? `Articles: \`/${articlesSlug}/{type}/{topic}/{slug}.md\``
57
+ : `Articles: \`/${articlesSlug}/{type}/{slug}.md\``
58
+ : 'Articles: append .md to article URLs',
59
+ ];
60
+ const parts = ['Pages: `/{slug}.md`', ...articlePatterns];
61
+ if (input.enablePerson && input.peopleSlug) {
62
+ parts.push(`Team: \`/${input.peopleSlug}/{slug}.md\``);
63
+ if (personTypeSlugs.length > 0) {
64
+ parts.push(`Team types: \`/${input.peopleSlug}/{type}/{slug}.md\``);
65
+ }
66
+ }
67
+ else if (input.enablePerson) {
68
+ for (const type of personTypeSlugs) {
69
+ parts.push(`Team (${type}): \`/${type}/{slug}.md\``);
70
+ }
71
+ }
72
+ for (const type of input.tagTypeSlugs ?? []) {
73
+ const prefix = input.tagsSlug ? `/${input.tagsSlug}/${type}` : `/${type}`;
74
+ parts.push(`Tags (${type}): \`${prefix}/{slug}.md\``);
75
+ }
76
+ return `Append .md to any page URL for a markdown version. ${parts.join('; ')}.`;
77
+ }
78
+ function basePath(slug, base) {
79
+ return base ?? (slug ? `/${slug}` : '');
80
+ }
81
+ /** Default `articleIndexPath`: the type's route index, else under the articles base, else `/{type}/`. */
82
+ export function defaultArticleIndexPath(content, articleTypeSlug) {
83
+ const route = content.articleTypeRoutes?.find((item) => item.slug === articleTypeSlug);
84
+ if (route) {
85
+ return route.indexPath;
86
+ }
87
+ const base = basePath(content.articlesSlug, content.articlesBase);
88
+ return base ? `${base}/${articleTypeSlug}/` : `/${articleTypeSlug}/`;
89
+ }
90
+ /** Default `teamIndexPath`: the people base, else the only person type, else the site root. */
91
+ export function defaultTeamIndexPath(content) {
92
+ if (content.peopleSlug) {
93
+ return `${basePath(content.peopleSlug, content.peopleBase)}/`;
94
+ }
95
+ const types = content.personTypeSlugs ?? [];
96
+ const onlyType = types.length === 1 ? types[0] : undefined;
97
+ return onlyType ? `/${onlyType}/` : '/';
98
+ }
99
+ /** Default `tagUrl`: under the tags base when the site has one, else `/{tag}/`. */
100
+ export function defaultTagUrl(content, tagSlug) {
101
+ return content.tagsSlug
102
+ ? `${basePath(content.tagsSlug, content.tagsBase)}/${tagSlug}/`
103
+ : `/${tagSlug}/`;
104
+ }
105
+ /** Resolved URL helpers for a site: its own when configured, else the defaults. */
106
+ export function resolveSiteUrls(content) {
107
+ return {
108
+ articleIndexPath: content.articleIndexPath ?? ((slug) => defaultArticleIndexPath(content, slug)),
109
+ teamIndexPath: content.teamIndexPath ?? (() => defaultTeamIndexPath(content)),
110
+ tagUrl: content.tagUrl ?? ((slug) => defaultTagUrl(content, slug)),
111
+ tagsBase: basePath(content.tagsSlug, content.tagsBase),
112
+ };
113
+ }
114
+ //# sourceMappingURL=helpers.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AO,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAC1C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,aAAa,CAAC,OAAoB,EAAE,OAAe;IACjE,OAAO,OAAO,CAAC,QAAQ;QACrB,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,GAAG;QAC/D,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC;AACrB,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,eAAe,CAAC,OAAoB;IAMlD,OAAO;QACL,gBAAgB,EACd,OAAO,CAAC,gBAAgB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAChF,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAC7E,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClE,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC;KACvD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './handlers';
2
+ export * from './helpers';
3
+ export * from './llmsFull';
4
+ export * from './llmsTxt';
5
+ export * from './markdownIndex';
6
+ export * from './siteInfo';
7
+ export * from './types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/siteFiles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './handlers';
2
+ export * from './helpers';
3
+ export * from './llmsFull';
4
+ export * from './llmsTxt';
5
+ export * from './markdownIndex';
6
+ export * from './siteInfo';
7
+ export * from './types';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/siteFiles/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { type LlmsTxtSettings } from './llmsTxt';
2
+ import type { SiteArticleLink, SiteContent, SitePageLink } from './types';
3
+ /** Default cap on the number of documents in `llms-full.txt`. */
4
+ export declare const DEFAULT_LLMS_FULL_MAX_DOCUMENTS = 25;
5
+ /** Default cap on the size of `llms-full.txt` (UTF-8 bytes). */
6
+ export declare const DEFAULT_LLMS_FULL_MAX_BYTES: number;
7
+ /**
8
+ * Options for `llms-full.txt`, which is off unless a site supplies them. It writes the `llms.txt` header and
9
+ * then the full markdown of every key page and latest article, so an agent can read the site in one request.
10
+ *
11
+ * `getMarkdown(href)` returns the markdown for a site path such as `/about/`, or null when there is none;
12
+ * a rejected call skips that document. `maxDocuments` (default 25) and `maxBytes` (default 512 KiB) bound
13
+ * the output: documents are added in order (key pages first) until either limit would be exceeded, and the
14
+ * rest are left out. `stripFrontmatter` (default true) removes the leading YAML block from each document.
15
+ * The selection options of `LlmsTxtSettings` apply, so the key pages and latest articles match `llms.txt`.
16
+ */
17
+ export interface LlmsFullSettings extends Pick<LlmsTxtSettings, 'latestArticlesLimit' | 'selectKeyPages' | 'selectLatestArticles' | 'details' | 'customBlocks'> {
18
+ getMarkdown: (href: string) => Promise<string | null | undefined>;
19
+ maxDocuments?: number;
20
+ maxBytes?: number;
21
+ stripFrontmatter?: boolean;
22
+ }
23
+ /** The data `buildLlmsFullTxt` formats. */
24
+ export interface LlmsFullInput {
25
+ baseUrl: string;
26
+ content: SiteContent;
27
+ pages: readonly SitePageLink[];
28
+ articles: readonly SiteArticleLink[];
29
+ settings: LlmsFullSettings;
30
+ }
31
+ /**
32
+ * Builds `llms-full.txt`. The header is the `llms.txt` title and summary (plus `details` and
33
+ * `customBlocks`), followed by a Key pages and a Latest articles section; each document is introduced by its
34
+ * title and markdown URL.
35
+ */
36
+ export declare function buildLlmsFullTxt(input: LlmsFullInput): Promise<string>;
37
+ //# sourceMappingURL=llmsFull.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llmsFull.d.ts","sourceRoot":"","sources":["../../src/siteFiles/llmsFull.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,WAAW,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1E,iEAAiE;AACjE,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAElD,gEAAgE;AAChE,eAAO,MAAM,2BAA2B,QAAa,CAAC;AAItD;;;;;;;;;GASG;AACH,MAAM,WAAW,gBACf,SAAQ,IAAI,CACV,eAAe,EACf,qBAAqB,GAAG,gBAAgB,GAAG,sBAAsB,GAAG,SAAS,GAAG,cAAc,CAC/F;IACD,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IACrC,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAiCD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CA+C5E"}
@@ -0,0 +1,82 @@
1
+ import { generateLlmsTxt, toMarkdownUrl } from '../llmsTxt';
2
+ import { selectLlmsEntries } from './llmsTxt';
3
+ /** Default cap on the number of documents in `llms-full.txt`. */
4
+ export const DEFAULT_LLMS_FULL_MAX_DOCUMENTS = 25;
5
+ /** Default cap on the size of `llms-full.txt` (UTF-8 bytes). */
6
+ export const DEFAULT_LLMS_FULL_MAX_BYTES = 512 * 1024;
7
+ const FETCH_BATCH_SIZE = 5;
8
+ const FRONTMATTER = /^---\r?\n[\s\S]*?\r?\n---\r?\n+/;
9
+ function byteLength(value) {
10
+ return new TextEncoder().encode(value).byteLength;
11
+ }
12
+ async function loadDocuments(entries, settings) {
13
+ const out = [];
14
+ for (let start = 0; start < entries.length; start += FETCH_BATCH_SIZE) {
15
+ const batch = entries.slice(start, start + FETCH_BATCH_SIZE);
16
+ const loaded = await Promise.all(batch.map(async (entry) => {
17
+ try {
18
+ const raw = await settings.getMarkdown(entry.href);
19
+ const body = (settings.stripFrontmatter === false ? raw : raw?.replace(FRONTMATTER, ''))?.trim();
20
+ return body ? { ...entry, body } : null;
21
+ }
22
+ catch {
23
+ return null;
24
+ }
25
+ }));
26
+ out.push(...loaded);
27
+ }
28
+ return out;
29
+ }
30
+ /**
31
+ * Builds `llms-full.txt`. The header is the `llms.txt` title and summary (plus `details` and
32
+ * `customBlocks`), followed by a Key pages and a Latest articles section; each document is introduced by its
33
+ * title and markdown URL.
34
+ */
35
+ export async function buildLlmsFullTxt(input) {
36
+ const { baseUrl, content, settings } = input;
37
+ const { keyPages, latestArticles } = selectLlmsEntries({
38
+ pages: input.pages,
39
+ articles: input.articles,
40
+ settings,
41
+ });
42
+ const toEntry = (link) => ({
43
+ href: link.href ?? '',
44
+ title: link.title ?? link.slug ?? 'Untitled',
45
+ });
46
+ const onSite = (entry) => Boolean(toMarkdownUrl(entry.href));
47
+ const keyEntries = keyPages.map(toEntry).filter(onSite);
48
+ const latestEntries = latestArticles.map(toEntry).filter(onSite);
49
+ const maxDocuments = settings.maxDocuments ?? DEFAULT_LLMS_FULL_MAX_DOCUMENTS;
50
+ const wanted = [
51
+ ...keyEntries.map((entry) => ({ ...entry, section: 'Key pages' })),
52
+ ...latestEntries.map((entry) => ({ ...entry, section: 'Latest articles' })),
53
+ ].slice(0, Math.max(0, maxDocuments));
54
+ const loaded = await loadDocuments(wanted, settings);
55
+ const header = generateLlmsTxt({
56
+ siteName: content.customerName,
57
+ summary: content.siteDescription,
58
+ ...(settings.details ? { details: settings.details } : {}),
59
+ ...(settings.customBlocks ? { customBlocks: settings.customBlocks } : {}),
60
+ });
61
+ const maxBytes = settings.maxBytes ?? DEFAULT_LLMS_FULL_MAX_BYTES;
62
+ const parts = [header];
63
+ let bytes = byteLength(header);
64
+ let currentSection = '';
65
+ for (const [index, document] of loaded.entries()) {
66
+ const section = wanted[index]?.section ?? '';
67
+ if (!document) {
68
+ continue;
69
+ }
70
+ const heading = section === currentSection ? '' : `## ${section}\n\n`;
71
+ const block = `${heading}### ${document.title}\n\nSource: ${baseUrl}${toMarkdownUrl(document.href)}\n\n${document.body}`;
72
+ const nextBytes = bytes + byteLength(block) + 2;
73
+ if (nextBytes > maxBytes) {
74
+ break;
75
+ }
76
+ parts.push(block);
77
+ bytes = nextBytes;
78
+ currentSection = section;
79
+ }
80
+ return `${parts.join('\n\n')}\n`;
81
+ }
82
+ //# sourceMappingURL=llmsFull.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llmsFull.js","sourceRoot":"","sources":["../../src/siteFiles/llmsFull.ts"],"names":[],"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CAAC,MAAM,OAAO,MAAM,CAAC;QACtE,MAAM,KAAK,GAAG,GAAG,OAAO,OAAO,QAAQ,CAAC,KAAK,eAAe,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzH,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChD,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;YACzB,MAAM;QACR,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,KAAK,GAAG,SAAS,CAAC;QAClB,cAAc,GAAG,OAAO,CAAC;IAC3B,CAAC;IACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;AACnC,CAAC"}
@@ -0,0 +1,49 @@
1
+ import { type LlmsTxtCustomBlock, type LlmsTxtSection } from '../llmsTxt';
2
+ import type { SiteArticleLink, SiteContent, SitePageDiscovery, SitePageLink } from './types';
3
+ type LlmsItem = LlmsTxtSection['items'][number];
4
+ /** Default number of latest articles listed in `llms.txt`. */
5
+ export declare const DEFAULT_LATEST_ARTICLES_LIMIT = 5;
6
+ /**
7
+ * Per-site options for `llms.txt` (every one is optional and defaults to the standard behaviour).
8
+ *
9
+ * `latestArticlesLimit` caps the Latest articles section (default 5). `selectKeyPages` and
10
+ * `selectLatestArticles` replace the default selection (on-site, indexed pages with the home page first;
11
+ * newest on-site articles). `getPageDiscovery` is the site-side hook that reads each key page once and returns
12
+ * a description per page slug and the documents found in page content (the Documents section is omitted
13
+ * without it). `markdownUrlPattern` replaces the generated "Append .md" sentence, either as text or as a
14
+ * function that receives the generated one. `details` and `customBlocks` are passed to the underlying
15
+ * generator. `optionalLinks` replaces the default Optional links (markdown index and site information);
16
+ * an empty array drops the section.
17
+ */
18
+ export interface LlmsTxtSettings {
19
+ latestArticlesLimit?: number;
20
+ selectKeyPages?: (pages: readonly SitePageLink[]) => SitePageLink[];
21
+ selectLatestArticles?: (articles: readonly SiteArticleLink[], limit: number) => SiteArticleLink[];
22
+ getPageDiscovery?: (pages: readonly SitePageLink[]) => Promise<SitePageDiscovery>;
23
+ markdownUrlPattern?: string | ((generated: string) => string);
24
+ details?: string;
25
+ customBlocks?: readonly LlmsTxtCustomBlock[];
26
+ optionalLinks?: readonly LlmsItem[];
27
+ }
28
+ /** The data `buildSiteLlmsTxt` formats. */
29
+ export interface SiteLlmsTxtInput {
30
+ baseUrl: string;
31
+ content: SiteContent;
32
+ pages: readonly SitePageLink[];
33
+ articles: readonly SiteArticleLink[];
34
+ discovery?: SitePageDiscovery;
35
+ settings?: LlmsTxtSettings;
36
+ }
37
+ /** The key pages and latest articles that `llms.txt` and `llms-full.txt` both list. */
38
+ export declare function selectLlmsEntries(input: {
39
+ pages: readonly SitePageLink[];
40
+ articles: readonly SiteArticleLink[];
41
+ settings?: LlmsTxtSettings;
42
+ }): {
43
+ keyPages: SitePageLink[];
44
+ latestArticles: SiteArticleLink[];
45
+ };
46
+ /** Pure `llms.txt` builder: same output as the route handler for the same data. */
47
+ export declare function buildSiteLlmsTxt(input: SiteLlmsTxtInput): string;
48
+ export {};
49
+ //# sourceMappingURL=llmsTxt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llmsTxt.d.ts","sourceRoot":"","sources":["../../src/siteFiles/llmsTxt.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EAEpB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7F,KAAK,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD,8DAA8D;AAC9D,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,e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 @@
1
+ import { generateLlmsTxt, toMarkdownUrl, } from '../llmsTxt';
2
+ import { buildMarkdownUrlPattern, oneLine, selectKeyPages, selectLatestArticles } from './helpers';
3
+ /** Default number of latest articles listed in `llms.txt`. */
4
+ export const DEFAULT_LATEST_ARTICLES_LIMIT = 5;
5
+ function markdownUrlOf(baseUrl, href) {
6
+ const markdown = href ? toMarkdownUrl(href) : '';
7
+ return markdown ? `${baseUrl}${markdown}` : '';
8
+ }
9
+ /** The key pages and latest articles that `llms.txt` and `llms-full.txt` both list. */
10
+ export function selectLlmsEntries(input) {
11
+ const settings = input.settings ?? {};
12
+ const keyPages = (settings.selectKeyPages ?? selectKeyPages)(input.pages);
13
+ const latestArticles = (settings.selectLatestArticles ?? selectLatestArticles)(input.articles, settings.latestArticlesLimit ?? DEFAULT_LATEST_ARTICLES_LIMIT);
14
+ return { keyPages, latestArticles };
15
+ }
16
+ /** Pure `llms.txt` builder: same output as the route handler for the same data. */
17
+ export function buildSiteLlmsTxt(input) {
18
+ const { baseUrl, content } = input;
19
+ const settings = input.settings ?? {};
20
+ const descriptionBySlug = input.discovery?.descriptionBySlug;
21
+ const { keyPages, latestArticles } = selectLlmsEntries(input);
22
+ const keyPageItems = keyPages
23
+ .map((page) => ({
24
+ url: markdownUrlOf(baseUrl, page.href),
25
+ title: page.title ?? '',
26
+ description: oneLine((page.slug ? descriptionBySlug?.get(page.slug) : undefined) ?? page.description),
27
+ }))
28
+ .filter((item) => item.url);
29
+ const latestItems = latestArticles
30
+ .map((article) => ({
31
+ url: markdownUrlOf(baseUrl, article.href),
32
+ title: article.title ?? '',
33
+ description: oneLine(article.description),
34
+ }))
35
+ .filter((item) => item.url);
36
+ const documentItems = (input.discovery?.documents ?? []).map((document) => ({
37
+ url: document.href.startsWith('/') ? `${baseUrl}${document.href}` : document.href,
38
+ title: document.title,
39
+ description: undefined,
40
+ }));
41
+ const generatedPattern = buildMarkdownUrlPattern(content);
42
+ const markdownUrlPattern = typeof settings.markdownUrlPattern === 'function'
43
+ ? settings.markdownUrlPattern(generatedPattern)
44
+ : (settings.markdownUrlPattern ?? generatedPattern);
45
+ const optionalLinks = settings.optionalLinks ?? [
46
+ {
47
+ url: `${baseUrl}/markdown-index.txt`,
48
+ title: 'Markdown index',
49
+ description: 'Complete list of all pages available in markdown format',
50
+ },
51
+ {
52
+ url: `${baseUrl}/site-info.md`,
53
+ title: 'Site information',
54
+ description: 'Factual summary of site content (counts, lists) for support and AI',
55
+ },
56
+ ];
57
+ return generateLlmsTxt({
58
+ siteName: content.customerName,
59
+ summary: content.siteDescription,
60
+ markdownUrlPattern,
61
+ ...(settings.details ? { details: settings.details } : {}),
62
+ ...(settings.customBlocks ? { customBlocks: settings.customBlocks } : {}),
63
+ sections: [
64
+ { title: 'Key pages', items: keyPageItems },
65
+ { title: 'Latest articles', items: latestItems },
66
+ { title: 'Documents', items: documentItems },
67
+ ].filter((section) => section.items.length > 0),
68
+ ...(optionalLinks.length > 0
69
+ ? { optionalSection: { title: 'Optional', items: [...optionalLinks] } }
70
+ : {}),
71
+ });
72
+ }
73
+ //# sourceMappingURL=llmsTxt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llmsTxt.js","sourceRoot":"","sources":["../../src/siteFiles/llmsTxt.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGf,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAKnG,8DAA8D;AAC9D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAmC/C,SAAS,aAAa,CAAC,OAAe,EAAE,IAA+B;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,OAAO,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,QAAQ,EAAE,CAAC,C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e;YAC9B,KAAK,EAAE,kBAAkB;YACzB,WAAW,EAAE,oEAAoE;SAClF;KACF,CAAC;IAEF,OAAO,eAAe,CAAC;QACrB,QAAQ,EAAE,OAAO,CAAC,YAAY;QAC9B,OAAO,EAAE,OAAO,CAAC,eAAe;QAChC,kBAAkB;QAClB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,QAAQ,EAAE;YACR,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE;YAC3C,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,WAAW,EAAE;YAChD,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,EAAE;SAC7C,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/C,GAAG,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC;YAC1B,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,EAAE;YACvE,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type MarkdownIndexLinks } from '../llmsTxt';
2
+ import type { SiteContent } from './types';
3
+ /**
4
+ * Per-site options for `markdown-index.txt`. `adjustLinks` receives the link groups before they are
5
+ * written, for a site that needs to drop or add entries.
6
+ */
7
+ export interface MarkdownIndexSettings {
8
+ adjustLinks?: (links: MarkdownIndexLinks) => MarkdownIndexLinks;
9
+ }
10
+ /** Fetches the link lists the index needs. Person and tag lists are only requested when enabled. */
11
+ export declare function fetchMarkdownIndexLinks(content: SiteContent): Promise<MarkdownIndexLinks>;
12
+ /** Pure `markdown-index.txt` builder: one absolute `.md` URL per line. */
13
+ export declare function buildSiteMarkdownIndex(links: MarkdownIndexLinks, baseUrl: string, settings?: MarkdownIndexSettings): string;
14
+ //# sourceMappingURL=markdownIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdownIndex.d.ts","sourceRoot":"","sources":["../../src/siteFiles/markdownIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,kBAAkB,CAAC;CACjE;AAKD,oGAAoG;AACpG,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkB/F;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,MAAM,CAIR"}
@@ -0,0 +1,28 @@
1
+ import { buildMarkdownLinksFromAppLinks, generateMarkdownIndex, } from '../llmsTxt';
2
+ const NO_LINKS = { data: [] };
3
+ /** Fetches the link lists the index needs. Person and tag lists are only requested when enabled. */
4
+ export async function fetchMarkdownIndexLinks(content) {
5
+ const [pageRes, articleRes, articleTypeRes, personRes, tagRes, personTypeLinks] = await Promise.all([
6
+ content.getAllPageLinks(),
7
+ content.getAllArticleLinks(),
8
+ content.getAllArticleTypeLinks ? content.getAllArticleTypeLinks() : NO_LINKS,
9
+ content.enablePerson && content.getAllPersonLinks ? content.getAllPersonLinks() : NO_LINKS,
10
+ content.enableTag && content.getAllTagLinks ? content.getAllTagLinks() : NO_LINKS,
11
+ content.getPersonTypeLinks ? content.getPersonTypeLinks() : [],
12
+ ]);
13
+ return buildMarkdownLinksFromAppLinks({
14
+ pageLinks: pageRes.data,
15
+ articleLinks: articleRes.data,
16
+ articleTypeLinks: articleTypeRes.data,
17
+ tagLinks: content.enableTag ? tagRes.data : undefined,
18
+ personLinks: content.enablePerson ? personRes.data : undefined,
19
+ ...(content.getPersonTypeLinks ? { personTypeLinks } : {}),
20
+ });
21
+ }
22
+ /** Pure `markdown-index.txt` builder: one absolute `.md` URL per line. */
23
+ export function buildSiteMarkdownIndex(links, baseUrl, settings) {
24
+ return generateMarkdownIndex(settings?.adjustLinks ? settings.adjustLinks(links) : links, {
25
+ baseUrl,
26
+ });
27
+ }
28
+ //# sourceMappingURL=markdownIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdownIndex.js","sourceRoot":"","sources":["../../src/siteFiles/markdownIndex.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,qBAAqB,GAEtB,MAAM,YAAY,CAAC;AAYpB,MAAM,QAAQ,GAAc,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AAEzC,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAAoB;IAChE,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,CAAC,GAC7E,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,OAAO,CAAC,eAAe,EAAE;QACzB,OAAO,CAAC,kBAAkB,EAAE;QAC5B,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC,QAAQ;QAC5E,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,QAAQ;QAC1F,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,QAAQ;QACjF,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE;KAC/D,CAAC,CAAC;IACL,OAAO,8BAA8B,CAAC;QACpC,SAAS,EAAE,OAAO,CAAC,IAAI;QACvB,YAAY,EAAE,UAAU,CAAC,IAAI;QAC7B,gBAAgB,EAAE,cAAc,CAAC,IAAI;QACrC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QACrD,WAAW,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAC9D,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3D,CAAC,CAAC;AACL,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,sBAAsB,CACpC,KAAyB,EACzB,OAAe,EACf,QAAgC;IAEhC,OAAO,qBAAqB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;QACxF,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { SiteArticleLink, SiteContent, SitePageLink, SiteTagRef } from './types';
2
+ /** An article type with its article count, as listed in `site-info.md`. */
3
+ export interface SiteInfoArticleType {
4
+ name: string;
5
+ slug: string;
6
+ count: number;
7
+ }
8
+ /** A topic (tag) with its article count and page URL, as listed in `site-info.md`. */
9
+ export interface SiteInfoTag {
10
+ name: string;
11
+ slug: string;
12
+ count: number;
13
+ href: string;
14
+ }
15
+ /**
16
+ * Everything `site-info.md` is built from, passed to `appendSections`: the article types and topics with
17
+ * their counts, and the raw link lists.
18
+ */
19
+ export interface SiteInfoData {
20
+ pages: readonly SitePageLink[];
21
+ articles: readonly SiteArticleLink[];
22
+ persons: readonly SitePageLink[];
23
+ articleTypes: readonly SiteInfoArticleType[];
24
+ tags: readonly SiteInfoTag[];
25
+ }
26
+ /**
27
+ * Per-site options for `site-info.md` (all optional).
28
+ *
29
+ * `publicationTypeSlugs` lists the article type slugs counted as "publications" in the summary (default
30
+ * `['publications']`; the line is omitted when the count is zero). `intro` replaces the three explanatory
31
+ * lines under the title. `tagName` chooses the display name of a topic from the name found on articles and
32
+ * the tag's own link (default: the tag link's `text`, then `name`, then the article's). `appendSections`
33
+ * returns extra lines placed after the Team section, before the closing rule. `now` is the clock used for
34
+ * the `Last updated` line; inject it in tests.
35
+ */
36
+ export interface SiteInfoSettings {
37
+ publicationTypeSlugs?: readonly string[];
38
+ intro?: readonly string[];
39
+ tagName?: (input: {
40
+ slug: string;
41
+ articleName: string;
42
+ tagLink?: SiteTagRef;
43
+ }) => string;
44
+ appendSections?: (data: SiteInfoData) => string[];
45
+ now?: () => Date;
46
+ }
47
+ /** The data `buildSiteInfoMarkdown` formats. */
48
+ export interface SiteInfoInput {
49
+ baseUrl: string;
50
+ content: SiteContent;
51
+ pages: readonly SitePageLink[];
52
+ articles: readonly SiteArticleLink[];
53
+ persons: readonly SitePageLink[];
54
+ tagLinks: readonly SiteTagRef[];
55
+ settings?: SiteInfoSettings;
56
+ now: Date;
57
+ }
58
+ /** Pure `site-info.md` builder: same output as the route handler for the same data and clock. */
59
+ export declare function buildSiteInfoMarkdown(input: SiteInfoInput): string;
60
+ //# sourceMappingURL=siteInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteInfo.d.ts","sourceRoot":"","sources":["../../src/siteFiles/siteInfo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAE,U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AAE,CAAC;IACjC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;IAChC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,GAAG,EAAE,IAAI,CAAC;CACX;AA0ND,iGAAiG;AACjG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAyElE"}
@@ -0,0 +1,251 @@
1
+ import { countArticles, isSitePath, resolveSiteUrls } from './helpers';
2
+ const DEFAULT_INTRO = [
3
+ 'This document provides factual information about the current contents of this website.',
4
+ 'It is intended for support tools (e.g. Intercom) and AI assistants to answer questions',
5
+ 'such as "how many publications are there?" or "what resources are available?".',
6
+ ];
7
+ function countByArticleType(articles) {
8
+ const map = new Map();
9
+ for (const article of articles) {
10
+ const slug = article.articleType?.slug ?? 'unknown';
11
+ const name = article.articleType?.name ?? slug;
12
+ const current = map.get(slug);
13
+ if (current) {
14
+ current.count++;
15
+ }
16
+ else {
17
+ map.set(slug, { name, count: 1 });
18
+ }
19
+ }
20
+ return Array.from(map.entries())
21
+ .map(([slug, { name, count }]) => ({ name, slug, count }))
22
+ .sort((a, b) => a.name.localeCompare(b.name));
23
+ }
24
+ function countTagsFromArticles(articles) {
25
+ const counts = new Map();
26
+ for (const article of articles) {
27
+ if (!article.tags) {
28
+ continue;
29
+ }
30
+ for (const tag of article.tags) {
31
+ if (!tag?.slug) {
32
+ continue;
33
+ }
34
+ const text = tag.text ?? tag.name ?? tag.slug;
35
+ const existing = counts.get(tag.slug);
36
+ if (existing) {
37
+ existing.count++;
38
+ }
39
+ else {
40
+ counts.set(tag.slug, { count: 1, name: text });
41
+ }
42
+ }
43
+ }
44
+ return counts;
45
+ }
46
+ function buildSummaryLines(counts, content) {
47
+ const out = [
48
+ '## Summary counts',
49
+ '',
50
+ `- **Total number of pages (top-level):** ${counts.pages}`,
51
+ `- **Total number of articles/resources:** ${counts.articles}`,
52
+ ` - With a page on this site: ${counts.onSite}`,
53
+ ...(counts.externalOnly > 0 ? [` - Link to another site only: ${counts.externalOnly}`] : []),
54
+ ` - With a downloadable file (PDF): ${counts.withDownload}`,
55
+ ];
56
+ if (counts.publications > 0) {
57
+ out.push(`- **Number of publications:** ${counts.publications}`);
58
+ }
59
+ if (content.enablePerson && counts.persons > 0) {
60
+ out.push(`- **Number of team members:** ${counts.persons}`);
61
+ }
62
+ if (content.enableTag && counts.tags > 0) {
63
+ out.push(`- **Number of topics/tags:** ${counts.tags}`);
64
+ }
65
+ out.push('');
66
+ return out;
67
+ }
68
+ function buildArticleTypesLines(byType, baseUrl, articleIndexPath) {
69
+ const out = [
70
+ '## Article types (resources)',
71
+ '',
72
+ 'Each article type has its own index.',
73
+ '',
74
+ ];
75
+ if (byType.length === 0) {
76
+ out.push('There are no articles in the CMS.');
77
+ }
78
+ else {
79
+ for (const { name, slug, count } of byType) {
80
+ const indexHref = `${baseUrl}${articleIndexPath(slug)}`;
81
+ out.push(`- **${name}** (slug: \`${slug}\`): ${count} — [Index](${indexHref})`);
82
+ }
83
+ }
84
+ out.push('');
85
+ return out;
86
+ }
87
+ function pageLinkLine(page, baseUrl) {
88
+ const href = page.href ? `${baseUrl}${page.href}` : '';
89
+ const title = page.title ?? page.slug ?? 'Untitled';
90
+ return href ? `- [${title}](${href})` : `- ${title}`;
91
+ }
92
+ function sortedByTitle(links) {
93
+ return [...links].sort((a, b) => (a.title ?? '').localeCompare(b.title ?? ''));
94
+ }
95
+ function buildPageListLines(pages, baseUrl) {
96
+ const out = ['## All pages', ''];
97
+ if (pages.length === 0) {
98
+ out.push('No pages in the CMS.');
99
+ }
100
+ else {
101
+ for (const page of sortedByTitle(pages)) {
102
+ out.push(pageLinkLine(page, baseUrl));
103
+ }
104
+ }
105
+ out.push('');
106
+ return out;
107
+ }
108
+ function groupArticlesByType(articles) {
109
+ const map = new Map();
110
+ for (const article of articles) {
111
+ const slug = article.articleType?.slug ?? 'other';
112
+ let list = map.get(slug);
113
+ if (!list) {
114
+ list = [];
115
+ map.set(slug, list);
116
+ }
117
+ list.push(article);
118
+ }
119
+ return map;
120
+ }
121
+ function formatArticleLine(article, baseUrl) {
122
+ const href = article.href
123
+ ? isSitePath(article.href)
124
+ ? `${baseUrl}${article.href}`
125
+ : article.href
126
+ : '';
127
+ const title = article.title ?? article.slug ?? 'Untitled';
128
+ const dateStr = article.date ? ` (${new Date(article.date).toISOString().slice(0, 10)})` : '';
129
+ const download = article.download ? ' — download' : '';
130
+ return href ? `- [${title}](${href})${dateStr}${download}` : `- ${title}${dateStr}${download}`;
131
+ }
132
+ function buildArticlesByTypeLines(articles, byType, baseUrl) {
133
+ const articlesByType = groupArticlesByType(articles);
134
+ const out = ['## All articles (by type)', ''];
135
+ for (const typeSlug of byType.map((type) => type.slug)) {
136
+ const list = articlesByType.get(typeSlug) ?? [];
137
+ const typeName = byType.find((type) => type.slug === typeSlug)?.name ?? typeSlug;
138
+ out.push(`### ${typeName}`, '');
139
+ const sorted = [...list].sort((a, b) => {
140
+ const dateA = a.date ? new Date(a.date).getTime() : 0;
141
+ const dateB = b.date ? new Date(b.date).getTime() : 0;
142
+ return dateB - dateA;
143
+ });
144
+ for (const article of sorted) {
145
+ out.push(formatArticleLine(article, baseUrl));
146
+ }
147
+ out.push('');
148
+ }
149
+ if (articlesByType.size === 0 && articles.length > 0) {
150
+ for (const article of articles) {
151
+ out.push(formatArticleLine(article, baseUrl));
152
+ }
153
+ out.push('');
154
+ }
155
+ return out;
156
+ }
157
+ function buildTopicsLines(tags, baseUrl, tagsBase, content) {
158
+ if (!content.enableTag || tags.length === 0) {
159
+ return [];
160
+ }
161
+ const out = [
162
+ '## Topics (tags)',
163
+ '',
164
+ `Topics are listed under \`${tagsBase}\`. Article listings can be filtered by topic.`,
165
+ '',
166
+ ];
167
+ for (const tag of tags) {
168
+ out.push(`- [${tag.name}](${baseUrl}${tag.href}) — ${tag.count} article(s)`);
169
+ }
170
+ out.push('');
171
+ return out;
172
+ }
173
+ function buildTeamLines(persons, baseUrl, teamIndexPath, content) {
174
+ if (!content.enablePerson || persons.length === 0) {
175
+ return [];
176
+ }
177
+ const out = ['## Team', '', `Team members are listed under \`${teamIndexPath}\`.`, ''];
178
+ for (const person of sortedByTitle(persons)) {
179
+ out.push(pageLinkLine(person, baseUrl));
180
+ }
181
+ out.push('');
182
+ return out;
183
+ }
184
+ /** Pure `site-info.md` builder: same output as the route handler for the same data and clock. */
185
+ export function buildSiteInfoMarkdown(input) {
186
+ const { baseUrl, content } = input;
187
+ const settings = input.settings ?? {};
188
+ const urls = resolveSiteUrls(content);
189
+ const pages = input.pages;
190
+ const articles = input.articles;
191
+ const persons = input.persons;
192
+ const byType = countByArticleType(articles);
193
+ const tagCounts = countTagsFromArticles(articles);
194
+ const tagLinkBySlug = new Map(input.tagLinks
195
+ .filter((tag) => Boolean(tag.slug))
196
+ .map((tag) => [tag.slug, tag]));
197
+ const tags = [];
198
+ for (const [slug, { count, name }] of tagCounts) {
199
+ const tagLink = tagLinkBySlug.get(slug);
200
+ const displayName = settings.tagName
201
+ ? settings.tagName({ slug, articleName: name, ...(tagLink ? { tagLink } : {}) })
202
+ : (tagLink?.text ?? tagLink?.name ?? name);
203
+ tags.push({ name: displayName, slug, count, href: urls.tagUrl(slug) });
204
+ }
205
+ tags.sort((a, b) => a.name.localeCompare(b.name));
206
+ const publicationSlugs = settings.publicationTypeSlugs ?? ['publications'];
207
+ const publications = byType
208
+ .filter((type) => publicationSlugs.includes(type.slug))
209
+ .reduce((sum, type) => sum + type.count, 0);
210
+ const articleCounts = countArticles(articles);
211
+ const title = content.siteTitle;
212
+ const lines = [
213
+ '---',
214
+ `title: "Site information: ${title}"`,
215
+ `description: "Factual summary of site content for support tools and AI assistants"`,
216
+ `contentType: site-info`,
217
+ `source: "${content.source}"`,
218
+ `license: "${content.license}"`,
219
+ '---',
220
+ '',
221
+ `# Site information: ${title}`,
222
+ '',
223
+ ...(settings.intro ?? DEFAULT_INTRO),
224
+ '',
225
+ `- **Site name:** ${title}`,
226
+ `- **Description:** ${content.siteDescription}`,
227
+ `- **Base URL:** ${baseUrl}`,
228
+ '',
229
+ ...buildSummaryLines({
230
+ pages: pages.length,
231
+ articles: articles.length,
232
+ onSite: articleCounts.onSite,
233
+ externalOnly: articleCounts.externalOnly,
234
+ withDownload: articleCounts.withDownload,
235
+ publications,
236
+ persons: persons.length,
237
+ tags: tags.length,
238
+ }, content),
239
+ ...buildArticleTypesLines(byType, baseUrl, urls.articleIndexPath),
240
+ ...buildPageListLines(pages, baseUrl),
241
+ ...buildArticlesByTypeLines(articles, byType, baseUrl),
242
+ ...buildTopicsLines(tags, baseUrl, urls.tagsBase, content),
243
+ ...buildTeamLines(persons, baseUrl, urls.teamIndexPath(), content),
244
+ ...(settings.appendSections?.({ pages, articles, persons, articleTypes: byType, tags }) ?? []),
245
+ '---',
246
+ '',
247
+ `*Generated from CMS data. Last updated: ${input.now.toISOString()}.*`,
248
+ ];
249
+ return lines.join('\n');
250
+ }
251
+ //# sourceMappingURL=siteInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteInfo.js","sourceRoot":"","sources":["../../src/siteFiles/siteInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAgDvE,MAAM,aAAa,GAAG;IACpB,wFAAwF;IACxF,wFAAwF;IACxF,gFAAgF;CACjF,CAAC;AAcF,SAAS,kBAAkB,CAAC,QAAoC;IAC9D,MAAM,GAAG,GAAG,IAAI,GAAG,EAA2C,CAAC;IAC/D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,IAAI,SAAS,CAAC;QACpD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,IAAI,IAAI,IAAI,CAAC;QAC/C,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,OAAO,EAAE,CAAC;YACZ,O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EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,OAAO,CAAC;QAClE,GAAG,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9F,KAAK;QACL,EAAE;QACF,2CAA2C,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI;KACvE,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,100 @@
1
+ import type { IArticleLink, IArticleTypeLink, IInternalLink } from '@se-studio/core-data-types';
2
+ /** The `{ data }` envelope every `getAll...Links` helper in the app returns; other fields are ignored. */
3
+ export interface SiteLinkResponse<T> {
4
+ data: T[];
5
+ }
6
+ /** A link list getter. App helpers such as `getAllPageLinks` already have this shape. */
7
+ export type SiteLinkFetcher<T> = () => Promise<SiteLinkResponse<T>>;
8
+ /**
9
+ * A route for one article type: `slug` is the CMS article type slug, `indexPath` the listing page
10
+ * (`/letters/`) and `articlePath` the base of the article pages (`/letter/`). Both end in a slash.
11
+ */
12
+ export interface SiteArticleTypeRoute {
13
+ slug: string;
14
+ articlePath: string;
15
+ indexPath: string;
16
+ }
17
+ /** The minimum a page needs to appear in the generated files. */
18
+ export interface SitePageLink {
19
+ href?: string | null;
20
+ title?: string | null;
21
+ slug?: string | null;
22
+ description?: string | null;
23
+ indexed?: boolean | null;
24
+ hidden?: boolean | null;
25
+ }
26
+ /** A tag as embedded in an article link. `text` wins over `name`. */
27
+ export interface SiteTagRef {
28
+ slug?: string | null;
29
+ name?: string | null;
30
+ text?: string | null;
31
+ }
32
+ /** The minimum an article needs to appear in the generated files. */
33
+ export interface SiteArticleLink extends SitePageLink {
34
+ date?: string | null;
35
+ download?: unknown;
36
+ externalLink?: string | null;
37
+ articleType?: {
38
+ slug?: string | null;
39
+ name?: string | null;
40
+ } | null;
41
+ tags?: readonly SiteTagRef[] | null;
42
+ }
43
+ /**
44
+ * Everything the generated discovery files read about a site.
45
+ *
46
+ * Identity: `customerName` heads `llms.txt`, `siteTitle`, `siteDescription`, `source` and `license` fill
47
+ * `site-info.md`.
48
+ *
49
+ * Data: the `getAll...Links` getters. Pages and articles are required, the others are only called when the
50
+ * matching flag is on (`getAllPersonLinks` with `enablePerson`, `getAllTagLinks` with `enableTag`).
51
+ * `getAllArticleTypeLinks` and `getPersonTypeLinks` (a plain array, as the person type index helper returns) feed `markdown-index.txt` only.
52
+ *
53
+ * Flags: `enablePerson`, `enableTag`, `enableArticleTypeIndex` and `enablePrimaryTagPartOfSlug` mirror the
54
+ * site's marketing flags and all default to false.
55
+ *
56
+ * Routes: `articlesSlug`/`articlesBase`, `articleTypeRoutes`, `peopleSlug`/`peopleBase`, `personTypeSlugs`,
57
+ * `tagsSlug`/`tagsBase` and `tagTypeSlugs` mirror the generated marketing slugs. A base is the path with a
58
+ * leading slash and no trailing one (`/team`), and is derived from the slug when omitted.
59
+ *
60
+ * URL helpers: `articleIndexPath(articleTypeSlug)`, `teamIndexPath()` and `tagUrl(tagSlug)` default to the
61
+ * standard layout built from the routes above; pass them when the site calculates URLs differently.
62
+ */
63
+ export interface SiteContent {
64
+ customerName: string;
65
+ siteTitle: string;
66
+ siteDescription: string;
67
+ source: string;
68
+ license: string;
69
+ getAllPageLinks: SiteLinkFetcher<IInternalLink>;
70
+ getAllArticleLinks: SiteLinkFetcher<IArticleLink>;
71
+ getAllArticleTypeLinks?: SiteLinkFetcher<IArticleTypeLink>;
72
+ getAllPersonLinks?: SiteLinkFetcher<IInternalLink>;
73
+ getAllTagLinks?: SiteLinkFetcher<IInternalLink>;
74
+ getPersonTypeLinks?: () => Promise<IInternalLink[]>;
75
+ enablePerson?: boolean;
76
+ enableTag?: boolean;
77
+ enableArticleTypeIndex?: boolean;
78
+ enablePrimaryTagPartOfSlug?: boolean;
79
+ articlesSlug?: string;
80
+ articlesBase?: string;
81
+ articleTypeRoutes?: readonly SiteArticleTypeRoute[];
82
+ peopleSlug?: string;
83
+ peopleBase?: string;
84
+ personTypeSlugs?: readonly string[];
85
+ tagsSlug?: string;
86
+ tagsBase?: string;
87
+ tagTypeSlugs?: readonly string[];
88
+ articleIndexPath?: (articleTypeSlug: string) => string;
89
+ teamIndexPath?: () => string;
90
+ tagUrl?: (tagSlug: string) => string;
91
+ }
92
+ /** What the page discovery hook returns: a description per page slug and the documents found in content. */
93
+ export interface SitePageDiscovery {
94
+ descriptionBySlug: ReadonlyMap<string, string>;
95
+ documents: readonly {
96
+ href: string;
97
+ title: string;
98
+ }[];
99
+ }
100
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/siteFiles/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhG,0GAA0G;AAC1G,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,EAAE,CAAC;CACX;AAED,yFAAyF;AACzF,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpE;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,GAAG,IA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vB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,gBAAgB,CAAC,EAAE,CAAC,eAAe,EAAE,MAAM,KAAK,MAAM,CAAC;IACvD,aAAa,CAAC,EAAE,MAAM,MAAM,CAAC;IAC7B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC;AAED,4GAA4G;AAC5G,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,SAAS,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACvD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/siteFiles/types.ts"],"names":[],"mappings":""}
package/docs/llms.md CHANGED
@@ -94,7 +94,43 @@ Omit `customBlocks` for byte-compatible legacy output. Prefer `llmsAccessPolicyB
94
94
 
95
95
  Misconfigured `customBlocks` (oversized bodies, heading injection, newlines in link fields, total over 256 KiB) throw from `generateLlmsTxt` by design — the `/llms.txt` route will 500 until the site constants are fixed.
96
96
 
97
- `llms-full.txt` is **not** generated by this package (not part of llmstxt.org v2). Custom blocks apply to `generateLlmsTxt` only.
97
+ Custom blocks apply to `generateLlmsTxt` only. The data-driven `llms.txt`, `llms-full.txt`, `site-info.md` and `markdown-index.txt` handlers are in the `site-files` entry below.
98
+
99
+ ## Site files (`@se-studio/markdown-renderer/site-files`)
100
+
101
+ Pure builders and handler factories that return a standard `Response` (no `next` import). Sites normally reach them through `@se-studio/core-ui/site-files` and `site-files.config.ts`; call them directly for a bespoke route.
102
+
103
+ ```ts
104
+ import {
105
+ createLlmsFullTxtHandler,
106
+ createMarkdownIndexHandler,
107
+ createSiteInfoHandler,
108
+ createSiteLlmsTxtHandler,
109
+ type SiteContent,
110
+ } from '@se-studio/markdown-renderer/site-files';
111
+
112
+ const content: SiteContent = {
113
+ customerName, siteTitle, siteDescription, source, license,
114
+ getAllPageLinks, getAllArticleLinks, getAllArticleTypeLinks, getAllPersonLinks, getAllTagLinks,
115
+ enablePerson, enableTag, enableArticleTypeIndex, enablePrimaryTagPartOfSlug,
116
+ articlesSlug, articleTypeRoutes, peopleSlug, personTypeSlugs, tagsSlug, tagTypeSlugs,
117
+ };
118
+
119
+ export const GET = createSiteLlmsTxtHandler({ baseUrl, content, settings: { getPageDiscovery } });
120
+ ```
121
+
122
+ | Handler | Output | Headers |
123
+ |---------|--------|---------|
124
+ | `createSiteLlmsTxtHandler` | Key pages (home first, descriptions), latest articles, optional Documents, Markdown access pattern, Optional links | `Content-Type: text/plain; charset=utf-8` |
125
+ | `createLlmsFullTxtHandler` | The llms.txt header, then the full markdown of the key pages and latest articles | same |
126
+ | `createSiteInfoHandler` | Counts and lists (article types, pages, articles, topics, team) | `text/markdown; charset=utf-8`, `Cache-Control: public, s-maxage=3600, stale-while-revalidate` |
127
+ | `createMarkdownIndexHandler` | One absolute `.md` URL per line | `text/plain; charset=utf-8` |
128
+
129
+ Every divergence between sites is an option with a default. `LlmsTxtSettings`: `latestArticlesLimit`, `selectKeyPages`, `selectLatestArticles`, `getPageDiscovery` (site-side hook returning `{ descriptionBySlug, documents }`), `markdownUrlPattern` (text or function of the generated sentence), `details`, `customBlocks`, `optionalLinks`. `SiteInfoSettings`: `publicationTypeSlugs`, `intro`, `tagName`, `appendSections`, `now` (inject the clock in tests). `MarkdownIndexSettings`: `adjustLinks`. The generic helpers (`selectKeyPages`, `selectLatestArticles`, `oneLine`, `isSitePath`, `countArticles`, `buildMarkdownUrlPattern`) are exported for reuse inside a hook.
130
+
131
+ ### `llms-full.txt` (opt-in)
132
+
133
+ `LlmsFullSettings.getMarkdown(href)` returns the markdown of one site path (for example by running the same exporter and converter as the `/markdown/[...params]` route); null or a thrown error skips that document. The output is bounded: `maxDocuments` (default 25, key pages first) and `maxBytes` (default 512 KiB, UTF-8). Documents are fetched five at a time. The leading YAML frontmatter of each document is removed unless `stripFrontmatter: false`. Without the section the generated route answers 404.
98
134
 
99
135
  ## URL Builder Helpers
100
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/markdown-renderer",
3
- "version": "2.0.16",
3
+ "version": "2.1.0",
4
4
  "description": "Markdown renderer for Contentful content",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,6 +16,10 @@
16
16
  "types": "./dist/index.d.ts",
17
17
  "import": "./dist/index.js"
18
18
  },
19
+ "./site-files": {
20
+ "types": "./dist/siteFiles/index.d.ts",
21
+ "import": "./dist/siteFiles/index.js"
22
+ },
19
23
  "./converter": {
20
24
  "types": "./dist/converter.d.ts",
21
25
  "import": "./dist/converter.js"
@@ -28,7 +32,7 @@
28
32
  ],
29
33
  "dependencies": {
30
34
  "@contentful/rich-text-types": "^17.2.7",
31
- "@se-studio/contentful-rest-api": "2.9.5",
35
+ "@se-studio/contentful-rest-api": "2.10.0",
32
36
  "@se-studio/core-data-types": "2.3.0",
33
37
  "html-entities": "^2.6.0",
34
38
  "js-yaml": "^5.5.0"