@se-studio/markdown-renderer 2.0.15 → 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.
- package/CHANGELOG.md +27 -0
- package/README.md +4 -0
- package/dist/siteFiles/handlers.d.ts +29 -0
- package/dist/siteFiles/handlers.d.ts.map +1 -0
- package/dist/siteFiles/handlers.js +80 -0
- package/dist/siteFiles/handlers.js.map +1 -0
- package/dist/siteFiles/helpers.d.ts +53 -0
- package/dist/siteFiles/helpers.d.ts.map +1 -0
- package/dist/siteFiles/helpers.js +114 -0
- package/dist/siteFiles/helpers.js.map +1 -0
- package/dist/siteFiles/index.d.ts +8 -0
- package/dist/siteFiles/index.d.ts.map +1 -0
- package/dist/siteFiles/index.js +8 -0
- package/dist/siteFiles/index.js.map +1 -0
- package/dist/siteFiles/llmsFull.d.ts +37 -0
- package/dist/siteFiles/llmsFull.d.ts.map +1 -0
- package/dist/siteFiles/llmsFull.js +82 -0
- package/dist/siteFiles/llmsFull.js.map +1 -0
- package/dist/siteFiles/llmsTxt.d.ts +49 -0
- package/dist/siteFiles/llmsTxt.d.ts.map +1 -0
- package/dist/siteFiles/llmsTxt.js +73 -0
- package/dist/siteFiles/llmsTxt.js.map +1 -0
- package/dist/siteFiles/markdownIndex.d.ts +14 -0
- package/dist/siteFiles/markdownIndex.d.ts.map +1 -0
- package/dist/siteFiles/markdownIndex.js +28 -0
- package/dist/siteFiles/markdownIndex.js.map +1 -0
- package/dist/siteFiles/siteInfo.d.ts +60 -0
- package/dist/siteFiles/siteInfo.d.ts.map +1 -0
- package/dist/siteFiles/siteInfo.js +251 -0
- package/dist/siteFiles/siteInfo.js.map +1 -0
- package/dist/siteFiles/types.d.ts +100 -0
- package/dist/siteFiles/types.d.ts.map +1 -0
- package/dist/siteFiles/types.js +2 -0
- package/dist/siteFiles/types.js.map +1 -0
- package/docs/llms.md +37 -1
- package/package.json +7 -3
|
@@ -0,0 +1,73 @@
|
|
|
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
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AC,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/si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AY,EAAE,CAAC;IAC/B,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IACrC,OAAO,EAAE,SAAS,YAAY,EAAE,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
|
+
//# sourceMappingUR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;QAC/C,mBAAmB,OAAO,EAAE;QAC5B,EAAE;QACF,GAAG,iBAAiB,CAClB;YACE,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,QAAQ,EAAE,QAAQ,CAAC,MAAM;YACzB,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,YAAY,EAAE,aAAa,CAAC,YAAY;YACxC,YAAY;YACZ,OAAO,EAAE,OAAO,CAAC,MAAM;YACvB,IAAI,EAAE,IAAI,CAAC,MAAM;SAClB,EACD,OAAO,CACR;QACD,GAAG,sBAAsB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC;QACjE,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC;QACrC,GAAG,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;QACtD,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC1D,GAAG,cAAc,CAAC,OAAO,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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aAAa,CAAC,CAAC;IACnD,cAAc,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IAChD,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,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 @@
|
|
|
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
|
-
|
|
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
|
|