@f5-sales-demo/docs-theme 4.4.11 → 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.
- package/canonical-route-middleware.ts +11 -0
- package/components/SharedHeader.astro +122 -0
- package/components/SharedMegaMenu.tsx +5 -0
- package/components/SharedMegaMenuMobile.tsx +5 -0
- package/config.ts +4 -1
- package/index.ts +1 -0
- package/package.json +4 -3
- package/src/utils/canonical-llms.mjs +18 -0
- package/src/utils/canonical-llms.test.ts +24 -0
- package/src/utils/shared-header.test.ts +14 -0
|
@@ -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,
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
import LanguageSelect from 'virtual:starlight/components/LanguageSelect';
|
|
3
|
+
import Search from 'virtual:starlight/components/Search';
|
|
4
|
+
import SiteTitle from 'virtual:starlight/components/SiteTitle';
|
|
5
|
+
import SocialIcons from 'virtual:starlight/components/SocialIcons';
|
|
6
|
+
import ThemeSelect from 'virtual:starlight/components/ThemeSelect';
|
|
7
|
+
import config from 'virtual:starlight/user-config';
|
|
8
|
+
import MegaMenu from './SharedMegaMenu.tsx';
|
|
9
|
+
import MegaMenuMobile from './SharedMegaMenuMobile.tsx';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Render the `Search` component if Pagefind is enabled or the default search component has been overridden.
|
|
13
|
+
*/
|
|
14
|
+
const shouldRenderSearch = config.pagefind || config.components.Search !== '@astrojs/starlight/components/Search.astro';
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<div class="header sl-mega-menu-header">
|
|
18
|
+
<div class="title-wrapper sl-flex">
|
|
19
|
+
<SiteTitle />
|
|
20
|
+
</div>
|
|
21
|
+
<nav class="smm-desktop-nav">
|
|
22
|
+
<MegaMenu client:only="react" />
|
|
23
|
+
</nav>
|
|
24
|
+
<div class="sl-flex print:hidden">
|
|
25
|
+
{shouldRenderSearch && <Search />}
|
|
26
|
+
</div>
|
|
27
|
+
<div class="sl-hidden md:sl-flex print:hidden right-group">
|
|
28
|
+
<div class="sl-flex social-icons">
|
|
29
|
+
<SocialIcons />
|
|
30
|
+
</div>
|
|
31
|
+
<ThemeSelect />
|
|
32
|
+
<LanguageSelect />
|
|
33
|
+
</div>
|
|
34
|
+
<div class="smm-mobile-toggle">
|
|
35
|
+
<MegaMenuMobile client:only="react" />
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
@layer starlight.core {
|
|
41
|
+
.header {
|
|
42
|
+
display: flex;
|
|
43
|
+
gap: var(--sl-nav-gap);
|
|
44
|
+
justify-content: space-between;
|
|
45
|
+
align-items: center;
|
|
46
|
+
height: 100%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.title-wrapper {
|
|
50
|
+
/* Prevent long titles overflowing and covering the search and menu buttons on narrow viewports. */
|
|
51
|
+
overflow: clip;
|
|
52
|
+
/* Avoid clipping focus ring around link inside title wrapper. */
|
|
53
|
+
padding: 0.25rem;
|
|
54
|
+
margin: -0.25rem;
|
|
55
|
+
min-width: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.right-group,
|
|
59
|
+
.social-icons {
|
|
60
|
+
gap: 1rem;
|
|
61
|
+
align-items: center;
|
|
62
|
+
}
|
|
63
|
+
.social-icons::after {
|
|
64
|
+
content: '';
|
|
65
|
+
height: 2rem;
|
|
66
|
+
border-inline-end: 1px solid var(--sl-color-gray-5);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Desktop nav is hidden on small screens */
|
|
70
|
+
.smm-desktop-nav {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Mobile toggle is visible on small screens */
|
|
75
|
+
.smm-mobile-toggle {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (min-width: 50rem) {
|
|
81
|
+
:global(:root[data-has-sidebar]) {
|
|
82
|
+
--__sidebar-pad: calc(2 * var(--sl-nav-pad-x));
|
|
83
|
+
}
|
|
84
|
+
:global(:root:not([data-has-toc])) {
|
|
85
|
+
--__toc-width: 0rem;
|
|
86
|
+
}
|
|
87
|
+
.header {
|
|
88
|
+
--__sidebar-width: max(0rem, var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x));
|
|
89
|
+
--__main-column-fr: calc(
|
|
90
|
+
(
|
|
91
|
+
100% + var(--__sidebar-pad, 0rem) - var(--__toc-width, var(--sl-sidebar-width)) -
|
|
92
|
+
(2 * var(--__toc-width, var(--sl-nav-pad-x))) - var(--sl-content-inline-start, 0rem) -
|
|
93
|
+
var(--sl-content-width)
|
|
94
|
+
) / 2
|
|
95
|
+
);
|
|
96
|
+
display: grid;
|
|
97
|
+
grid-template-columns:
|
|
98
|
+
/* 1 (site title) */
|
|
99
|
+
auto
|
|
100
|
+
/* 2 (mega-menu nav) */
|
|
101
|
+
1fr
|
|
102
|
+
/* 3 (search box) */
|
|
103
|
+
auto
|
|
104
|
+
/* 4 (right items) */
|
|
105
|
+
auto;
|
|
106
|
+
align-content: center;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Show desktop nav, hide mobile toggle */
|
|
110
|
+
.smm-desktop-nav {
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
min-width: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.smm-mobile-toggle {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
</style>
|
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/index.ts
CHANGED
|
@@ -24,6 +24,7 @@ export default function f5xcDocsTheme(): StarlightPlugin {
|
|
|
24
24
|
],
|
|
25
25
|
components: {
|
|
26
26
|
...config.components,
|
|
27
|
+
Header: '@f5-sales-demo/docs-theme/components/SharedHeader.astro',
|
|
27
28
|
...(process.env.DOCS_PROFILE === 'canonical-provider'
|
|
28
29
|
? {
|
|
29
30
|
Sidebar: '@f5-sales-demo/docs-theme/components/ProviderSidebar.astro',
|
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": {
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"./src/utils/localize-ecosystem-href.ts": "./src/utils/localize-ecosystem-href.ts",
|
|
44
44
|
"./canonical-route-middleware": "./canonical-route-middleware.ts",
|
|
45
45
|
"./components/ProviderSidebar.astro": "./components/ProviderSidebar.astro",
|
|
46
|
-
"./components/ProviderHeader.astro": "./components/ProviderHeader.astro"
|
|
46
|
+
"./components/ProviderHeader.astro": "./components/ProviderHeader.astro",
|
|
47
|
+
"./components/SharedHeader.astro": "./components/SharedHeader.astro"
|
|
47
48
|
},
|
|
48
49
|
"files": [
|
|
49
50
|
"index.ts",
|
|
@@ -143,7 +144,7 @@
|
|
|
143
144
|
"@anthropic-ai/sdk": "^0.121.0",
|
|
144
145
|
"@astrojs/react": "^6.0.4",
|
|
145
146
|
"@f5-sales-demo/i18n-core": "^1.0.56",
|
|
146
|
-
"@f5-sales-demo/starlight-llms-txt": "2.
|
|
147
|
+
"@f5-sales-demo/starlight-llms-txt": "2.3.0",
|
|
147
148
|
"@f5-sales-demo/starlight-mega-menu": "^3.0.0",
|
|
148
149
|
"gray-matter": "^4.0.3",
|
|
149
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
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { expect, it } from 'vitest';
|
|
3
|
+
|
|
4
|
+
it('bundles menu config in shared clients instead of serialized island props', () => {
|
|
5
|
+
const header = readFileSync(new URL('../../components/SharedHeader.astro', import.meta.url), 'utf8');
|
|
6
|
+
expect(header).not.toContain('config={');
|
|
7
|
+
expect(header).toContain('<ThemeSelect');
|
|
8
|
+
expect(header).toContain('<LanguageSelect');
|
|
9
|
+
expect(header).toContain('<SocialIcons');
|
|
10
|
+
for (const name of ['SharedMegaMenu', 'SharedMegaMenuMobile']) {
|
|
11
|
+
const client = readFileSync(new URL(`../../components/${name}.tsx`, import.meta.url), 'utf8');
|
|
12
|
+
expect(client).toContain('virtual:starlight-mega-menu/config');
|
|
13
|
+
}
|
|
14
|
+
});
|