@vantagecompute/docusaurus-theme 0.4.8 → 0.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/README.md CHANGED
@@ -16,8 +16,6 @@ Add the theme to your `docusaurus.config.js`:
16
16
  const {
17
17
  staticDir,
18
18
  rehypeTabsTransform,
19
- navbarLogo,
20
- footerLogo,
21
19
  getProjectVersion,
22
20
  } = require('@vantagecompute/docusaurus-theme');
23
21
 
@@ -30,8 +28,16 @@ const config = {
30
28
  // grows and shrinks reflows the header on every release.
31
29
  tagline: `What this project does (${projectVersion})`,
32
30
 
33
- // Add the Vantage theme
34
- themes: ['@vantagecompute/docusaurus-theme'],
31
+ // Add the Vantage theme. Its one option is the external buttons on the
32
+ // developer navbar: at most two, each a label and an absolute url.
33
+ themes: [
34
+ ['@vantagecompute/docusaurus-theme', {
35
+ navbarLinks: [
36
+ {label: 'GitHub', url: 'https://github.com/vantagecompute/my-project'},
37
+ {label: 'PyPI', url: 'https://pypi.org/project/my-project/'},
38
+ ],
39
+ }],
40
+ ],
35
41
 
36
42
  // Serve shared static assets (fonts, icons, brand mark)
37
43
  staticDirectories: ['static', staticDir],
@@ -47,24 +53,13 @@ const config = {
47
53
  ],
48
54
 
49
55
  themeConfig: {
50
- navbar: {
51
- title: 'my-project',
52
- logo: navbarLogo,
53
- items: [/* ... */],
54
- },
55
- footer: {
56
- style: 'dark',
57
- logo: footerLogo,
58
- links: [/* ... */],
59
- },
56
+ // No navbar and no footer here: the theme renders both. A site under
57
+ // /developer/ gets the developer navbar, anything else the public one.
58
+ prism: {/* ... */},
60
59
  },
61
60
  };
62
61
  ```
63
62
 
64
- `navbarLogo` and `footerLogo` carry the Vantage brand mark, its alt text, and
65
- the right link target for each position. Your site needs no copy of the SVG:
66
- it is served out of `staticDir`.
67
-
68
63
  ## What's included
69
64
 
70
65
  ### Design System CSS
@@ -79,21 +74,26 @@ Served from the package once `staticDir` is in your `staticDirectories`, so no s
79
74
  - **Fonts**: Satoshi (Regular, Medium, Bold + italics) as `.woff` files
80
75
  - **Icons**: Sun/moon toggles, search, external link, GitHub, chevron SVGs
81
76
  - **Brand mark**: `vantage-logo-color.svg`, the current Vantage mark, used by
82
- `navbarLogo` and `footerLogo`. It has no dark variant on purpose: the one
83
- colour mark is drawn to read in both colour modes.
77
+ the theme's navbar. It has no dark variant on purpose: the one colour mark
78
+ is drawn to read in both colour modes.
84
79
  - **Legacy logo**: `vantage-logo.svg`, the older monochrome mark. Kept for the
85
80
  `vantage-docs` hub, which still points at it. New sites should use the
86
81
  brand mark above.
87
82
  - **Favicon**: `favicon.ico`
88
83
 
89
84
  ### Theme Component Overrides
90
- | Component | Description |
85
+ | Component | What it changes |
91
86
  |---|---|
92
- | `ColorModeToggle` | Custom sun/moon SVG icon toggle |
93
- | `DocBreadcrumbs` | Full-path breadcrumb rendering |
94
- | `Navbar/Logo` | Centered site title with the version badge beside it |
95
- | `Tabs` | Bugfix for Docusaurus 3.10 whitespace crash |
96
- | `Navbar/MobileSidebar/SecondaryMenu` | Clean secondary menu render |
87
+ | `Navbar/Content` | The whole navbar, in a public or a developer variant chosen from `baseUrl` (0.5.0) |
88
+ | `Navbar/Logo` | The brand link with the variant's baked href, the centred title and the version badge |
89
+ | `Navbar/MobileSidebar/PrimaryMenu` | The developer navbar's external buttons, in the mobile drawer (0.5.0) |
90
+ | `Navbar/SiteActions` | An empty slot in the public navbar for a site's own controls (0.5.0) |
91
+ | `Navbar/MobileSidebar/SecondaryMenu` | A clean secondary-menu render |
92
+ | `Footer` | Renders nothing (0.5.0) |
93
+ | `ColorModeToggle` | Sun and moon SVG icons in place of the default toggle |
94
+ | `DocBreadcrumbs` | Full-path breadcrumbs instead of the truncated default |
95
+ | `Tabs` | A workaround for a Docusaurus 3.10 crash |
96
+ | `MDXComponents` | Every markdown `table` renders inside a horizontal scroll region (0.4.9) |
97
97
 
98
98
  ### Utilities
99
99
  | Export | Description |
@@ -101,8 +101,7 @@ Served from the package once `staticDir` is in your `staticDirectories`, so no s
101
101
  | `staticDir` | Absolute path to this package's `static/` directory; add it to `staticDirectories` |
102
102
  | `rehypeTabsTransform` | Rehype plugin that transforms lowercase `<tabs>`/`<tabitem>` to React components |
103
103
  | `getProjectVersion()` | Project version inferred from git tags (`git describe --tags --always`), or `"dev"` |
104
- | `navbarLogo` | Navbar logo config: the brand mark, linking to `https://docs.vantagecompute.ai` |
105
- | `footerLogo` | Footer logo config: the same mark, linking to `https://vantagecompute.ai` |
104
+ | `resolveNavbarVariant(baseUrl)` | The rule that picks the public or developer navbar; exported for tooling |
106
105
 
107
106
  ## Customization
108
107
 
@@ -117,19 +116,21 @@ your-docs-site/
117
116
  index.js
118
117
  ```
119
118
 
120
- ### Overriding the logo
121
-
122
- `navbarLogo` and `footerLogo` are plain objects. Spread one to change a field,
123
- and leave the rest to the theme:
119
+ ### Navbar buttons
124
120
 
125
121
  ```js
126
- navbar: {
127
- logo: { ...navbarLogo, href: 'https://docs.vantagecompute.ai/developer/' },
128
- },
122
+ themes: [
123
+ ['@vantagecompute/docusaurus-theme', {
124
+ navbarLinks: [
125
+ {label: 'GitHub', url: 'https://github.com/vantagecompute/my-project'},
126
+ {label: 'PyPI', url: 'https://pypi.org/project/my-project/'},
127
+ ],
128
+ }],
129
+ ],
129
130
  ```
130
131
 
131
- Spread rather than mutate: the objects are shared by everything that imports
132
- them. To render no logo at all, just omit `logo`.
132
+ That is the whole navbar surface a site has. See the docs site's Customization
133
+ page for the public navbar's `SiteActions` slot.
133
134
 
134
135
  ### Extending CSS
135
136
  Add your own CSS in `src/css/custom.css` and reference it in your preset config. Your styles will layer on top of the shared design system:
package/lib/index.cjs CHANGED
@@ -3,12 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.footerLogo = exports.navbarLogo = exports.rehypeTabsTransform = exports.staticDir = void 0;
6
+ exports.rehypeTabsTransform = exports.staticDir = exports.resolveNavbarVariant = exports.MAX_NAVBAR_LINKS = exports.LOGO_HREF = void 0;
7
7
  exports.default = themeVantage;
8
+ exports.validateOptions = validateOptions;
8
9
  exports.getProjectVersion = getProjectVersion;
9
10
  const node_path_1 = __importDefault(require("node:path"));
10
11
  const node_child_process_1 = require("node:child_process");
11
- function themeVantage() {
12
+ const options_cjs_1 = require("./options.cjs");
13
+ var options_cjs_2 = require("./options.cjs");
14
+ Object.defineProperty(exports, "LOGO_HREF", { enumerable: true, get: function () { return options_cjs_2.LOGO_HREF; } });
15
+ Object.defineProperty(exports, "MAX_NAVBAR_LINKS", { enumerable: true, get: function () { return options_cjs_2.MAX_NAVBAR_LINKS; } });
16
+ Object.defineProperty(exports, "resolveNavbarVariant", { enumerable: true, get: function () { return options_cjs_2.resolveNavbarVariant; } });
17
+ function themeVantage(context, options) {
18
+ const variant = (0, options_cjs_1.resolveNavbarVariant)(context.baseUrl);
19
+ const globalData = {
20
+ variant,
21
+ logoHref: options_cjs_1.LOGO_HREF[variant],
22
+ navbarLinks: options.navbarLinks,
23
+ };
12
24
  return {
13
25
  name: '@vantagecompute/docusaurus-theme',
14
26
  getThemePath() {
@@ -20,8 +32,20 @@ function themeVantage() {
20
32
  getClientModules() {
21
33
  return [node_path_1.default.resolve(__dirname, '../src/css/custom.css')];
22
34
  },
35
+ // The navbar variant and the external buttons reach the client this way.
36
+ // Nothing in themeConfig.navbar is read by the theme's components.
37
+ contentLoaded({ actions }) {
38
+ actions.setGlobalData(globalData);
39
+ },
23
40
  };
24
41
  }
42
+ /**
43
+ * Docusaurus calls this before the plugin factory. Hand-rolled rather than Joi
44
+ * so the package carries no validation dependency; see src/options.cts.
45
+ */
46
+ function validateOptions({ options, }) {
47
+ return (0, options_cjs_1.validateVantageThemeOptions)(options);
48
+ }
25
49
  /**
26
50
  * Returns the absolute path to this package's static directory.
27
51
  * Add this to your `staticDirectories` in docusaurus.config.js:
@@ -53,59 +77,4 @@ function getProjectVersion() {
53
77
  }
54
78
  // Re-export the rehype utility (plain JS, lives in src/utils/)
55
79
  exports.rehypeTabsTransform = require(node_path_1.default.resolve(__dirname, '../src/utils/rehypeTabsTransform'));
56
- /**
57
- * The Vantage colour brand mark, as a path relative to a served static
58
- * directory. It resolves once `staticDir` is in `staticDirectories`; no site
59
- * needs its own copy of the SVG.
60
- */
61
- const VANTAGE_LOGO_SRC = 'img/vantage-logo-color.svg';
62
- /**
63
- * Navbar logo for a Vantage documentation site.
64
- *
65
- * ```js
66
- * const { navbarLogo } = require('@vantagecompute/docusaurus-theme');
67
- * themeConfig: { navbar: { title: 'v8x', logo: navbarLogo, items: [...] } }
68
- * ```
69
- *
70
- * Deliberately has no `srcDark`. The single colour mark is drawn to read on
71
- * both colour modes, and a second asset would only be a second thing to keep
72
- * in sync.
73
- *
74
- * `href` points at the docs hub rather than the marketing site: from a spoke's
75
- * documentation the useful "home" is the rest of the documentation. `target`
76
- * is `_self` so that jump replaces the tab instead of opening a new one.
77
- *
78
- * Override by spreading, never by mutating -- the object is shared by every
79
- * site in the process:
80
- *
81
- * ```js
82
- * logo: { ...navbarLogo, href: 'https://docs.vantagecompute.ai/developer/' }
83
- * ```
84
- *
85
- * Omit `logo` entirely to render no navbar logo.
86
- */
87
- exports.navbarLogo = {
88
- alt: 'Vantage Compute Logo',
89
- src: VANTAGE_LOGO_SRC,
90
- href: 'https://docs.vantagecompute.ai',
91
- target: '_self',
92
- };
93
- /**
94
- * Footer logo for a Vantage documentation site.
95
- *
96
- * ```js
97
- * const { footerLogo } = require('@vantagecompute/docusaurus-theme');
98
- * themeConfig: { footer: { style: 'dark', logo: footerLogo, links: [...] } }
99
- * ```
100
- *
101
- * Same mark as {@link navbarLogo}, but `href` points at the marketing site:
102
- * the footer is where a reader who has finished reading looks for the company.
103
- *
104
- * Override by spreading; omit `logo` to render no footer logo.
105
- */
106
- exports.footerLogo = {
107
- alt: 'Vantage Compute Logo',
108
- src: VANTAGE_LOGO_SRC,
109
- href: 'https://vantagecompute.ai',
110
- };
111
80
  //# sourceMappingURL=index.cjs.map
package/lib/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":";;;;;;;;AAAA,0DAA6B;AAC7B,2DAA8C;AAG9C;IACE,OAAO;QACL,IAAI,EAAE,kCAAkC;QAExC,YAAY;YACV,OAAO,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACjD,CAAC;QAED,eAAe;YACb,OAAO,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,uCAAuC,CAAC,CAAC,CAAC;QAC5E,CAAC;QAED,gBAAgB;YACd,OAAO,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACU,QAAA,SAAS,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAE9D;;;;GAIG;AACH;IACE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,6BAAQ,EAAC,8BAA8B,EAAE;YACvD,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,+DAA+D;AAClD,QAAA,mBAAmB,GAAG,OAAO,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC,CAAC;AAexG;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACU,QAAA,UAAU,GAAc;IACnC,GA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,GAC+E;IAEtF,OAAO,IAAA,yCAA2B,EAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;GAUG;AACU,QAAA,SAAS,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAE9D;;;;GAIG;AACH;IACE,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,6BAAQ,EAAC,8BAA8B,EAAE;YACvD,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,+DAA+D;AAClD,QAAA,mBAAmB,GAAG,OAAO,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kCAAkC,CAAC,CAAC,CAAC"}
package/lib/index.d.cts CHANGED
@@ -1,5 +1,22 @@
1
- import type { Plugin } from '@docusaurus/types';
2
- export default function themeVantage(): Plugin;
1
+ import type { LoadContext, OptionValidationContext, Plugin } from '@docusaurus/types';
2
+ import { type ResolvedVantageThemeOptions, type VantageThemeOptions } from './options.cjs';
3
+ export type { NavbarLink, NavbarVariant, VantageThemeOptions } from './options.cjs';
4
+ export { LOGO_HREF, MAX_NAVBAR_LINKS, resolveNavbarVariant } from './options.cjs';
5
+ /**
6
+ * Shape of the global data the theme's client components read through
7
+ * `usePluginData('@vantagecompute/docusaurus-theme')`.
8
+ */
9
+ export interface VantageThemeGlobalData {
10
+ variant: 'public' | 'developer';
11
+ logoHref: string;
12
+ navbarLinks: ResolvedVantageThemeOptions['navbarLinks'];
13
+ }
14
+ export default function themeVantage(context: LoadContext, options: ResolvedVantageThemeOptions): Plugin;
15
+ /**
16
+ * Docusaurus calls this before the plugin factory. Hand-rolled rather than Joi
17
+ * so the package carries no validation dependency; see src/options.cts.
18
+ */
19
+ export declare function validateOptions({ options, }: OptionValidationContext<VantageThemeOptions | undefined, ResolvedVantageThemeOptions>): ResolvedVantageThemeOptions;
3
20
  /**
4
21
  * Returns the absolute path to this package's static directory.
5
22
  * Add this to your `staticDirectories` in docusaurus.config.js:
@@ -19,56 +36,4 @@ export declare const staticDir: string;
19
36
  */
20
37
  export declare function getProjectVersion(): string;
21
38
  export declare const rehypeTabsTransform: any;
22
- /**
23
- * Shape of a Docusaurus navbar or footer logo entry.
24
- */
25
- export interface ThemeLogo {
26
- alt: string;
27
- src: string;
28
- srcDark?: string;
29
- href: string;
30
- target?: string;
31
- width?: number;
32
- height?: number;
33
- }
34
- /**
35
- * Navbar logo for a Vantage documentation site.
36
- *
37
- * ```js
38
- * const { navbarLogo } = require('@vantagecompute/docusaurus-theme');
39
- * themeConfig: { navbar: { title: 'v8x', logo: navbarLogo, items: [...] } }
40
- * ```
41
- *
42
- * Deliberately has no `srcDark`. The single colour mark is drawn to read on
43
- * both colour modes, and a second asset would only be a second thing to keep
44
- * in sync.
45
- *
46
- * `href` points at the docs hub rather than the marketing site: from a spoke's
47
- * documentation the useful "home" is the rest of the documentation. `target`
48
- * is `_self` so that jump replaces the tab instead of opening a new one.
49
- *
50
- * Override by spreading, never by mutating -- the object is shared by every
51
- * site in the process:
52
- *
53
- * ```js
54
- * logo: { ...navbarLogo, href: 'https://docs.vantagecompute.ai/developer/' }
55
- * ```
56
- *
57
- * Omit `logo` entirely to render no navbar logo.
58
- */
59
- export declare const navbarLogo: ThemeLogo;
60
- /**
61
- * Footer logo for a Vantage documentation site.
62
- *
63
- * ```js
64
- * const { footerLogo } = require('@vantagecompute/docusaurus-theme');
65
- * themeConfig: { footer: { style: 'dark', logo: footerLogo, links: [...] } }
66
- * ```
67
- *
68
- * Same mark as {@link navbarLogo}, but `href` points at the marketing site:
69
- * the footer is where a reader who has finished reading looks for the company.
70
- *
71
- * Override by spreading; omit `logo` to render no footer logo.
72
- */
73
- export declare const footerLogo: ThemeLogo;
74
39
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,YAAY,IAAI,MAAM,CAgB7C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,QAAuC,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAU1C;AAGD,eAAO,MAAM,mBAAmB,KAAuE,CAAC;AAExG;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AASD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,EAAE,SAKxB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,EAAE,SAIxB,CAAC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.cts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,WAAW,EAAE,uBAAuB,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAIL,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAC,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClF,OAAO,EAAC,SAAS,EAAE,gBAAgB,EAAE,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,QAAQ,GAAG,WAAW,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,2BAA2B,CAAC,aAAa,CAAC,CAAC;CACzD;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,2BAA2B,GACnC,MAAM,CA6BR;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,GACR,EAAE,uBAAuB,CAAC,mBAAmB,GAAG,SAAS,EAAE,2BAA2B,CAAC,GACtF,2BAA2B,CAE5B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,QAAuC,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAU1C;AAGD,eAAO,MAAM,mBAAmB,KAAuE,CAAC"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ /**
3
+ * Theme options and the navbar variant rule. Pure functions with no Docusaurus
4
+ * imports, so they are tested directly against the compiled output.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LOGO_HREF = exports.MAX_NAVBAR_LINKS = void 0;
8
+ exports.resolveNavbarVariant = resolveNavbarVariant;
9
+ exports.validateVantageThemeOptions = validateVantageThemeOptions;
10
+ const DEFAULT_PLUGIN_ID = 'default';
11
+ /** Two is GitHub plus one registry (PyPI, npm, ...). More than that is a nav, and navs drift. */
12
+ exports.MAX_NAVBAR_LINKS = 2;
13
+ /**
14
+ * Where the brand mark links, per variant. Baked in on purpose: a site cannot
15
+ * point its logo anywhere else, which is what keeps the hub consistent.
16
+ */
17
+ exports.LOGO_HREF = {
18
+ public: 'https://docs.vantagecompute.ai/',
19
+ developer: 'https://docs.vantagecompute.ai/developer/',
20
+ };
21
+ /**
22
+ * Every site published under /developer/ (the developer overview and every
23
+ * spoke) gets the developer navbar. Everything else gets the public one.
24
+ * Docusaurus normalises baseUrl to a leading and trailing slash before the
25
+ * plugin sees it.
26
+ */
27
+ function resolveNavbarVariant(baseUrl) {
28
+ return baseUrl.startsWith('/developer/') ? 'developer' : 'public';
29
+ }
30
+ const PREFIX = '[@vantagecompute/docusaurus-theme]';
31
+ function fail(message) {
32
+ throw new Error(`${PREFIX} ${message}`);
33
+ }
34
+ function isPlainObject(value) {
35
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
36
+ }
37
+ function validateLink(value, index) {
38
+ const where = `navbarLinks[${index}]`;
39
+ if (!isPlainObject(value)) {
40
+ fail(`${where} must be an object with "label" and "url".`);
41
+ }
42
+ const extra = Object.keys(value).filter((key) => key !== 'label' && key !== 'url');
43
+ if (extra.length > 0) {
44
+ fail(`${where} has unsupported propert${extra.length === 1 ? 'y' : 'ies'} ` +
45
+ `${extra.map((k) => `"${k}"`).join(', ')}. Only "label" and "url" are ` +
46
+ `accepted; the icon, external-link marker and rel attributes come from the theme.`);
47
+ }
48
+ const { label, url } = value;
49
+ if (typeof label !== 'string' || label.trim() === '') {
50
+ fail(`${where}.label must be a non-empty string.`);
51
+ }
52
+ if (typeof url !== 'string' || url.trim() === '') {
53
+ fail(`${where}.url must be a non-empty string.`);
54
+ }
55
+ let parsed;
56
+ try {
57
+ parsed = new URL(url);
58
+ }
59
+ catch {
60
+ return fail(`${where}.url must be an absolute http(s) URL, got "${url}".`);
61
+ }
62
+ if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
63
+ fail(`${where}.url must be an absolute http(s) URL, got "${url}".`);
64
+ }
65
+ return { label: label.trim(), url };
66
+ }
67
+ /**
68
+ * Validate and normalise the theme options. Throws with a message that names
69
+ * the offending key, so a misconfigured spoke fails its build instead of
70
+ * quietly rendering something off-convention.
71
+ */
72
+ function validateVantageThemeOptions(options) {
73
+ if (options === undefined || options === null) {
74
+ return { id: DEFAULT_PLUGIN_ID, navbarLinks: [] };
75
+ }
76
+ if (!isPlainObject(options)) {
77
+ fail('theme options must be an object.');
78
+ }
79
+ const { navbarLinks, id, ...unknown } = options;
80
+ const unknownKeys = Object.keys(unknown);
81
+ if (unknownKeys.length > 0) {
82
+ fail(`unknown option${unknownKeys.length === 1 ? '' : 's'} ` +
83
+ `${unknownKeys.map((k) => `"${k}"`).join(', ')}. The only option is "navbarLinks".`);
84
+ }
85
+ const resolved = {
86
+ id: typeof id === 'string' ? id : DEFAULT_PLUGIN_ID,
87
+ navbarLinks: [],
88
+ };
89
+ if (navbarLinks === undefined) {
90
+ return resolved;
91
+ }
92
+ if (!Array.isArray(navbarLinks)) {
93
+ fail('"navbarLinks" must be an array of {label, url} objects.');
94
+ }
95
+ if (navbarLinks.length > exports.MAX_NAVBAR_LINKS) {
96
+ fail(`"navbarLinks" allows at most ${exports.MAX_NAVBAR_LINKS} entries, got ${navbarLinks.length}. ` +
97
+ `GitHub plus one package registry is the intended use.`);
98
+ }
99
+ resolved.navbarLinks = navbarLinks.map(validateLink);
100
+ return resolved;
101
+ }
102
+ //# sourceMappingURL=options.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.cjs","sourceRoot":"","sources":["../src/options.cts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AA2BH,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,iGAAiG;AACpF,QAAA,gBAAgB,GAAG,CAAC,CAAC;AAElC;;;GAGG;AACU,QAAA,SAAS,GAAkC;IACtD,MAAM,EAAE,iCAAiC;IACzC,SAAS,EAAE,2CAA2C;CACvD,CAAC;AAEF;;;;;GAKG;AACH,8BAAqC,OAAe;IAClD,OAAO,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;AACpE,CAAC;AAED,MAAM,MAAM,GAAG,oCAAoC,CAAC;AAEpD,SAAS,IAAI,CAAC,OAAe;IAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,O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EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB;QACnD,WAAW,EAAE,EAAE;KAChB,CAAC;IAEF,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAChC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,WAAW,CAAC,MAAM,GAAG,QAAA,gBAAgB,EAAE,CAAC;QAC1C,IAAI,CACF,gCAAgC,QAAA,gBAAgB,iBAAiB,WAAW,CAAC,MAAM,IAAI;YACrF,uDAAuD,CAC1D,CAAC;IACJ,CAAC;IAED,QAAQ,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACrD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Theme options and the navbar variant rule. Pure functions with no Docusaurus
3
+ * imports, so they are tested directly against the compiled output.
4
+ */
5
+ export type NavbarVariant = 'public' | 'developer';
6
+ /** One external button in the developer navbar. Nothing else is configurable. */
7
+ export interface NavbarLink {
8
+ label: string;
9
+ url: string;
10
+ }
11
+ /** What a site may pass in `themes: [['@vantagecompute/docusaurus-theme', {...}]]`. */
12
+ export interface VantageThemeOptions {
13
+ /** External buttons, at most {@link MAX_NAVBAR_LINKS}. Rendered by the developer navbar only. */
14
+ navbarLinks?: NavbarLink[];
15
+ }
16
+ /**
17
+ * Options after validation. `id` is Docusaurus's plugin-instance id. When a
18
+ * plugin exports validateOptions, Docusaurus trusts the returned object to
19
+ * carry it (its own Joi path adds one), and names the plugin's generated data
20
+ * directory after it. Leaving it out crashes the build in path.join.
21
+ */
22
+ export interface ResolvedVantageThemeOptions {
23
+ id: string;
24
+ navbarLinks: NavbarLink[];
25
+ }
26
+ /** Two is GitHub plus one registry (PyPI, npm, ...). More than that is a nav, and navs drift. */
27
+ export declare const MAX_NAVBAR_LINKS = 2;
28
+ /**
29
+ * Where the brand mark links, per variant. Baked in on purpose: a site cannot
30
+ * point its logo anywhere else, which is what keeps the hub consistent.
31
+ */
32
+ export declare const LOGO_HREF: Record<NavbarVariant, string>;
33
+ /**
34
+ * Every site published under /developer/ (the developer overview and every
35
+ * spoke) gets the developer navbar. Everything else gets the public one.
36
+ * Docusaurus normalises baseUrl to a leading and trailing slash before the
37
+ * plugin sees it.
38
+ */
39
+ export declare function resolveNavbarVariant(baseUrl: string): NavbarVariant;
40
+ /**
41
+ * Validate and normalise the theme options. Throws with a message that names
42
+ * the offending key, so a misconfigured spoke fails its build instead of
43
+ * quietly rendering something off-convention.
44
+ */
45
+ export declare function validateVantageThemeOptions(options: unknown): ResolvedVantageThemeOptions;
46
+ //# sourceMappingURL=options.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.cts","sourceRoot":"","sources":["../src/options.cts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEnD,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,uFAAuF;AACvF,MAAM,WAAW,mBAAmB;IAClC,iGAAiG;IACjG,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED;;;;;GAKG;AACH,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAID,iGAAiG;AACjG,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAGnD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAEnE;AAgDD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,2BAA2B,CAqCzF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vantagecompute/docusaurus-theme",
3
- "version": "0.4.8",
3
+ "version": "0.5.0",
4
4
  "description": "Shared Vantage Compute Docusaurus theme: design system, brand assets, and common theme overrides for all vantagecompute documentation sites.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.cjs",
@@ -12,6 +12,7 @@
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "tsc",
15
+ "test": "node --test 'test/**/*.test.cjs'",
15
16
  "prepublishOnly": "npm run build"
16
17
  },
17
18
  "peerDependencies": {