@f5-sales-demo/docs-theme 4.1.6 → 4.3.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.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import Default from '@astrojs/starlight/components/Banner.astro';
3
3
 
4
- const docsHome = process.env.DOCS_HOME || 'https://f5-sales-demo.github.io/docs/';
4
+ const docsHome = process.env.DOCS_HOME || 'https://f5-sales-demo.github.io/';
5
5
  const { sidebar, entry, siteTitle, editUrl } = Astro.locals.starlightRoute;
6
6
  const t = Astro.locals.t;
7
7
 
@@ -2,7 +2,7 @@
2
2
  import config from 'virtual:starlight/user-config';
3
3
  import { logos } from 'virtual:starlight/user-images';
4
4
 
5
- const docsHome = process.env.DOCS_HOME || 'https://f5-sales-demo.github.io/docs/';
5
+ const docsHome = process.env.DOCS_HOME || 'https://f5-sales-demo.github.io/';
6
6
  const { siteTitle } = Astro.locals.starlightRoute;
7
7
  ---
8
8
 
package/config.ts CHANGED
@@ -37,6 +37,62 @@ import { buildSubcategorySidebar } from './src/utils/subcategory-sidebar.ts';
37
37
  export type { LocaleConfig } from './src/i18n/locales.ts';
38
38
  export { f5xcDefaultLocales } from './src/i18n/locales.ts';
39
39
 
40
+ interface ProgressiveCorpusPolicy {
41
+ taxonomy?: {
42
+ levels: ['category', 'subcategory'];
43
+ collapseSingletonSubcategories: boolean;
44
+ };
45
+ hints?: {
46
+ strategy: 'first-sentence';
47
+ maxCharacters: number;
48
+ };
49
+ }
50
+
51
+ export function progressiveCorpusPolicy(config: Record<string, unknown>): ProgressiveCorpusPolicy {
52
+ const value = config.progressiveCorpus;
53
+ if (value === undefined) return {};
54
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
55
+ throw new Error('[docs-theme] progressiveCorpus configuration must be an object');
56
+ }
57
+ const input = value as Record<string, unknown>;
58
+ const policy: ProgressiveCorpusPolicy = {};
59
+ if (input.taxonomy !== undefined) {
60
+ if (!input.taxonomy || typeof input.taxonomy !== 'object' || Array.isArray(input.taxonomy)) {
61
+ throw new Error('[docs-theme] progressiveCorpus taxonomy is invalid');
62
+ }
63
+ const taxonomy = input.taxonomy as Record<string, unknown>;
64
+ const levels = taxonomy.levels;
65
+ if (
66
+ !Array.isArray(levels) ||
67
+ levels.length !== 2 ||
68
+ levels[0] !== 'category' ||
69
+ levels[1] !== 'subcategory' ||
70
+ typeof taxonomy.collapseSingletonSubcategories !== 'boolean'
71
+ ) {
72
+ throw new Error('[docs-theme] progressiveCorpus taxonomy is invalid');
73
+ }
74
+ policy.taxonomy = {
75
+ levels: ['category', 'subcategory'],
76
+ collapseSingletonSubcategories: taxonomy.collapseSingletonSubcategories,
77
+ };
78
+ }
79
+ if (input.hints !== undefined) {
80
+ if (!input.hints || typeof input.hints !== 'object' || Array.isArray(input.hints)) {
81
+ throw new Error('[docs-theme] progressiveCorpus hints are invalid');
82
+ }
83
+ const hints = input.hints as Record<string, unknown>;
84
+ if (
85
+ hints.strategy !== 'first-sentence' ||
86
+ !Number.isInteger(hints.maxCharacters) ||
87
+ (hints.maxCharacters as number) < 1
88
+ ) {
89
+ throw new Error('[docs-theme] progressiveCorpus hints are invalid');
90
+ }
91
+ policy.hints = { strategy: 'first-sentence', maxCharacters: hints.maxCharacters as number };
92
+ }
93
+ return policy;
94
+ }
95
+
40
96
  interface HeadEntry {
41
97
  tag: string;
42
98
  attrs?: Record<string, string>;
@@ -252,6 +308,12 @@ export const defaultMegaMenuItems: MegaMenuItem[] = [
252
308
  title: 'Documentation Tools',
253
309
  translations: categoryTitles['Documentation Tools'],
254
310
  items: [
311
+ {
312
+ label: 'F5 XC Docs',
313
+ description: 'Organization documentation portal',
314
+ href: 'https://f5-sales-demo.github.io/',
315
+ icon: resolveMegaMenuIcon('f5xc:doc'),
316
+ },
255
317
  {
256
318
  label: 'Docs Builder',
257
319
  translations: itemLabels['Docs Builder'],
@@ -547,10 +609,19 @@ mermaid.initialize({
547
609
  },
548
610
  ];
549
611
 
612
+ export function federatedSearchBundlePaths(site: string, base: string): string[] {
613
+ const normalizedBase = base.replace(/\/+$/, '');
614
+ return federatedSearchSites
615
+ .filter((entry) => (entry.repo === 'f5-sales-demo.github.io' ? '' : `/${entry.repo}`) !== normalizedBase)
616
+ .map((entry) =>
617
+ entry.repo === 'f5-sales-demo.github.io' ? `${site}/pagefind/` : `${site}/${entry.repo}/pagefind/`,
618
+ );
619
+ }
620
+
550
621
  export const federatedSearchSites = [
551
622
  { repo: 'docs-builder', label: 'Docs Builder' },
552
623
  { repo: 'docs-theme', label: 'Docs Theme' },
553
- { repo: 'docs', label: 'F5 XC Docs' },
624
+ { repo: 'f5-sales-demo.github.io', label: 'F5 XC Docs' },
554
625
  { repo: 'administration', label: 'Administration' },
555
626
  { repo: 'nginx', label: 'NGINX' },
556
627
  { repo: 'observability', label: 'Observability' },
@@ -633,6 +704,7 @@ export function createF5xcDocsConfig(options: F5xcDocsConfigOptions = {}) {
633
704
 
634
705
  const federatedSearch = options.federatedSearch !== false;
635
706
  const normalizedBase = base.replace(/\/+$/, '');
707
+ const repositoryCorpusPolicy = progressiveCorpusPolicy(llmsConfig);
636
708
  const progressiveCorpus =
637
709
  options.progressiveCorpus ||
638
710
  (process.env.MACHINE_CORPUS_DIR
@@ -642,6 +714,7 @@ export function createF5xcDocsConfig(options: F5xcDocsConfigOptions = {}) {
642
714
  assetBaseUrl: `${normalizedBase}/snapshot/`,
643
715
  title,
644
716
  description,
717
+ ...repositoryCorpusPolicy,
645
718
  sources: {
646
719
  'docs-cloud-f5-com': {
647
720
  title: 'F5 Distributed Cloud Documentation',
@@ -655,11 +728,7 @@ export function createF5xcDocsConfig(options: F5xcDocsConfigOptions = {}) {
655
728
  }
656
729
  : undefined);
657
730
  const mergeIndex = federatedSearch
658
- ? federatedSearchSites
659
- .filter((s) => `/${s.repo}` !== normalizedBase)
660
- .map((s) => ({
661
- bundlePath: `${site}/${s.repo}/pagefind/`,
662
- }))
731
+ ? federatedSearchBundlePaths(site, base).map((bundlePath) => ({ bundlePath }))
663
732
  : undefined;
664
733
 
665
734
  const starlightPlugins: StarlightPlugin[] = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@f5-sales-demo/docs-theme",
3
- "version": "4.1.6",
3
+ "version": "4.3.0",
4
4
  "description": "F5 Distributed Cloud branded Starlight documentation theme",
5
5
  "type": "module",
6
6
  "engines": {
@@ -139,7 +139,7 @@
139
139
  "@anthropic-ai/sdk": "^0.121.0",
140
140
  "@astrojs/react": "^6.0.4",
141
141
  "@f5-sales-demo/i18n-core": "^1.0.56",
142
- "@f5-sales-demo/starlight-llms-txt": "2.1.0",
142
+ "@f5-sales-demo/starlight-llms-txt": "2.2.0",
143
143
  "@f5-sales-demo/starlight-mega-menu": "^3.0.0",
144
144
  "gray-matter": "^4.0.3",
145
145
  "remark-code-import": "^1.2.0",