@f5-sales-demo/docs-theme 4.4.12 → 4.5.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.
|
@@ -13,6 +13,17 @@ export const onRequest = defineRouteMiddleware(async (context, next) => {
|
|
|
13
13
|
providerNavigation ||= JSON.parse(fs.readFileSync(process.env.PROVIDER_NAVIGATION || '', 'utf8'));
|
|
14
14
|
const metadata = entry.data.xcsh_docs;
|
|
15
15
|
const base = import.meta.env.BASE_URL;
|
|
16
|
+
const slug = route.id.replace(/\/$/, '');
|
|
17
|
+
const scope = metadata ? slug || '_llms-txt/root' : null;
|
|
18
|
+
route.head.push({
|
|
19
|
+
tag: 'link',
|
|
20
|
+
attrs: {
|
|
21
|
+
rel: 'describedby',
|
|
22
|
+
href: scope
|
|
23
|
+
? `${base.replace(/\/$/, '')}/${scope}/_llms/content/llms.txt`
|
|
24
|
+
: `${base.replace(/\/$/, '')}/llms.txt`,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
16
27
|
const sections = stagedProviderSections().map((section) => ({
|
|
17
28
|
type: 'link' as const,
|
|
18
29
|
label: section.label,
|
package/config.ts
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from './src/i18n/mega-menu-translations.ts';
|
|
32
32
|
import { sidebarTranslations } from './src/i18n/translations.ts';
|
|
33
33
|
import remarkMermaid from './src/plugins/remark-mermaid.mjs';
|
|
34
|
+
import canonicalLlms from './src/utils/canonical-llms.mjs';
|
|
34
35
|
import { providerMegaMenu } from './src/utils/canonical-provider.ts';
|
|
35
36
|
import { menuLocalizationPolicy } from './src/utils/menu-localization.ts';
|
|
36
37
|
import { stagedProviderSections } from './src/utils/provider-sections.ts';
|
|
@@ -933,7 +934,9 @@ export function createF5xcDocsConfig(options: F5xcDocsConfigOptions = {}) {
|
|
|
933
934
|
],
|
|
934
935
|
}),
|
|
935
936
|
react(),
|
|
936
|
-
...(canonicalProvider
|
|
937
|
+
...(canonicalProvider
|
|
938
|
+
? [providerSharedAssets(), canonicalLlms({ contentRoot: canonicalProvider.contentRoot, base, title })]
|
|
939
|
+
: []),
|
|
937
940
|
...additionalIntegrations,
|
|
938
941
|
],
|
|
939
942
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@f5-sales-demo/docs-theme",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "F5 Distributed Cloud branded Starlight documentation theme",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"@anthropic-ai/sdk": "^0.121.0",
|
|
145
145
|
"@astrojs/react": "^6.0.4",
|
|
146
146
|
"@f5-sales-demo/i18n-core": "^1.0.56",
|
|
147
|
-
"@f5-sales-demo/starlight-llms-txt": "2.
|
|
147
|
+
"@f5-sales-demo/starlight-llms-txt": "2.3.0",
|
|
148
148
|
"@f5-sales-demo/starlight-mega-menu": "^3.0.0",
|
|
149
149
|
"gray-matter": "^4.0.3",
|
|
150
150
|
"remark-code-import": "^1.2.0",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { readCanonicalCorpus, writeCanonicalHierarchy } from '@f5-sales-demo/starlight-llms-txt/canonical-corpus';
|
|
3
|
+
|
|
4
|
+
export default function canonicalLlms({ contentRoot, base, title }) {
|
|
5
|
+
return {
|
|
6
|
+
name: 'f5-canonical-llms',
|
|
7
|
+
hooks: {
|
|
8
|
+
'astro:config:setup'() {
|
|
9
|
+
// Validate before Astro starts processing staged content.
|
|
10
|
+
const corpus = readCanonicalCorpus(contentRoot);
|
|
11
|
+
if (!corpus.pages.length) throw new Error('Canonical publication has no pages');
|
|
12
|
+
},
|
|
13
|
+
'astro:build:done'({ dir }) {
|
|
14
|
+
writeCanonicalHierarchy({ contentRoot, outputRoot: fileURLToPath(dir), base, title });
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
const read = vi.fn(() => ({ pages: [{}] }));
|
|
4
|
+
const write = vi.fn();
|
|
5
|
+
vi.mock('@f5-sales-demo/starlight-llms-txt/canonical-corpus', () => ({
|
|
6
|
+
readCanonicalCorpus: read,
|
|
7
|
+
writeCanonicalHierarchy: write,
|
|
8
|
+
}));
|
|
9
|
+
describe('canonical llms integration', () => {
|
|
10
|
+
it('validates the original root before processing and streams after the build', async () => {
|
|
11
|
+
const { default: integration } = await import('./canonical-llms.mjs');
|
|
12
|
+
const plugin = integration({ contentRoot: '/fixture/documentation', base: '/preview/', title: 'Fixture' });
|
|
13
|
+
expect(read).not.toHaveBeenCalled();
|
|
14
|
+
plugin.hooks['astro:config:setup']();
|
|
15
|
+
expect(read).toHaveBeenCalledWith('/fixture/documentation');
|
|
16
|
+
plugin.hooks['astro:build:done']({ dir: new URL('file:///fixture/output/') });
|
|
17
|
+
expect(write).toHaveBeenCalledWith({
|
|
18
|
+
contentRoot: '/fixture/documentation',
|
|
19
|
+
outputRoot: '/fixture/output/',
|
|
20
|
+
base: '/preview/',
|
|
21
|
+
title: 'Fixture',
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|