@conduction/docusaurus-preset 2.7.0-beta.2 → 2.7.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conduction/docusaurus-preset",
3
- "version": "2.7.0-beta.2",
3
+ "version": "2.7.0-beta.3",
4
4
  "scripts": {
5
5
  "prepack": "node scripts/prepack-bundle-css.js"
6
6
  },
package/src/index.js CHANGED
@@ -112,10 +112,16 @@ const baseNavbar = (siteName, repoUrl) => ({
112
112
  src: 'img/logo.svg',
113
113
  srcDark: 'img/logo-dark.svg',
114
114
  },
115
+ /* `custom-*` prefix is the Docusaurus convention for theme-defined
116
+ navbar item types — items prefixed this way bypass the strict Joi
117
+ schema validator in @docusaurus/theme-classic, so the brand Navbar
118
+ swizzle can dispatch on them without registering each shape with
119
+ core. The swizzle accepts both `custom-github` and the bare
120
+ `github` (etc.) for forward-compat. */
115
121
  items: [
116
- { type: 'versionPill', position: 'right' },
117
- { type: 'apiDocs', position: 'right' },
118
- { type: 'github', href: repoUrl || 'https://github.com/ConductionNL', position: 'right' },
122
+ { type: 'custom-versionPill', position: 'right' },
123
+ { type: 'custom-apiDocs', position: 'right' },
124
+ { type: 'custom-github', href: repoUrl || 'https://github.com/ConductionNL', position: 'right' },
119
125
  { type: 'localeDropdown', position: 'right' },
120
126
  ],
121
127
  });
@@ -24,12 +24,18 @@
24
24
  * { type: 'doc', label, to } internal doc link
25
25
  * { type: 'link', label, to | href } internal/external link
26
26
  * { type: 'localeDropdown' } Docusaurus locale switcher
27
- * { type: 'github', href } icon-only GitHub mark
28
- * { type: 'apiDocs', label?, to } icon + "API Documentation"
29
- * { type: 'versionPill', prefix? } "Stable · v{x.y.z}" pill
27
+ * { type: 'custom-github', href } icon-only GitHub mark
28
+ * { type: 'custom-apiDocs', label?, to } icon + "API Documentation"
29
+ * { type: 'custom-versionPill', prefix? } "Stable · v{x.y.z}" pill
30
30
  * reads customFields.appVersion;
31
31
  * hidden when no version
32
32
  *
33
+ * The `custom-` prefix is required so Docusaurus's themeConfig schema
34
+ * validator passes (`@docusaurus/theme-classic` rejects unknown bare
35
+ * type names). The swizzle below accepts both the prefixed and the
36
+ * bare names so 2.7.0-beta.1 sites that wired the bare names keep
37
+ * working after the upgrade.
38
+ *
33
39
  * The pill prefix defaults to "Stable" but can be overridden per site
34
40
  * (e.g. prefix="Beta" while on a pre-1.0 release line).
35
41
  *
@@ -46,6 +52,24 @@ import {brandFor, productWordmark} from '../brand.jsx';
46
52
  import {ICONS} from '../../components/primitives/icons';
47
53
  import styles from './styles.module.css';
48
54
 
55
+ /**
56
+ * Brand-specific navbar item types live under the `custom-` prefix
57
+ * because Docusaurus's themeConfig validator (Joi schema in
58
+ * @docusaurus/theme-classic) rejects unknown top-level types. The
59
+ * `custom-` namespace is the documented escape hatch: items prefixed
60
+ * with `custom-` bypass schema validation and are passed through to
61
+ * the theme as-is. The brand Navbar then dispatches on them below.
62
+ *
63
+ * Sites may also use the bare names (`github`, `apiDocs`,
64
+ * `versionPill`) — they render identically here but Docusaurus will
65
+ * reject the config at load time. Accept both forms so the migration
66
+ * from 2.7.0-beta.1 to .beta.2 doesn't break sites that already
67
+ * configured the bare names.
68
+ */
69
+ function typeIs(item, kind) {
70
+ return item.type === kind || item.type === 'custom-' + kind;
71
+ }
72
+
49
73
  /**
50
74
  * Render a single navbar item. The brand navbar supports a small
51
75
  * subset of Docusaurus item types plus the three brand-specific types
@@ -64,7 +88,7 @@ function NavItem({item, location, appVersion}) {
64
88
  /* GitHub: icon-only link with an accessible label. The aria-label
65
89
  gives screen-readers + browser tooltips a name without rendering
66
90
  a visible text label in the navbar. */
67
- if (item.type === 'github') {
91
+ if (typeIs(item, 'github')) {
68
92
  return (
69
93
  <a
70
94
  href={item.href || 'https://github.com/ConductionNL'}
@@ -82,7 +106,7 @@ function NavItem({item, location, appVersion}) {
82
106
  /* API Documentation: icon + label link. Target defaults to /api
83
107
  (the Redocusaurus mount point used by every Conduction docs site).
84
108
  Sites can override via `to` or `href`. */
85
- if (item.type === 'apiDocs') {
109
+ if (typeIs(item, 'apiDocs')) {
86
110
  const label = item.label || 'API Documentation';
87
111
  const to = item.to || '/api';
88
112
  const href = item.href;
@@ -106,7 +130,7 @@ function NavItem({item, location, appVersion}) {
106
130
  or package.json). Hidden when no version is available so sites
107
131
  without an app version (Hydra, design-system itself) get a clean
108
132
  navbar instead of an empty pill. */
109
- if (item.type === 'versionPill') {
133
+ if (typeIs(item, 'versionPill')) {
110
134
  if (!appVersion) return null;
111
135
  const prefix = item.prefix || 'Stable';
112
136
  return (
@@ -198,7 +222,12 @@ export default function Navbar() {
198
222
  position="right" — but the three brand-specific item types
199
223
  (github, apiDocs, versionPill) live on the right by convention,
200
224
  mirroring the docs-shell mock. */
201
- const RIGHT_TYPES = new Set(['localeDropdown', 'github', 'apiDocs', 'versionPill']);
225
+ const RIGHT_TYPES = new Set([
226
+ 'localeDropdown',
227
+ 'github', 'custom-github',
228
+ 'apiDocs', 'custom-apiDocs',
229
+ 'versionPill', 'custom-versionPill',
230
+ ]);
202
231
  const leftItems = items.filter(i => i.position !== 'right' && !RIGHT_TYPES.has(i.type));
203
232
  const rightItems = items.filter(i => i.position === 'right' || RIGHT_TYPES.has(i.type));
204
233