@dino-ovum/preset 0.1.0 → 0.2.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
@@ -2,6 +2,10 @@
2
2
 
3
3
  Docusaurus configuration and shared document, navigation, search, and PWA plugins for Dino Ovum.
4
4
 
5
+ ```sh
6
+ pnpm add @dino-ovum/preset @docusaurus/core@3.10.1 @mdx-js/react react react-dom
7
+ ```
8
+
5
9
  ```js
6
10
  import {createDinoConfig} from '@dino-ovum/preset/config';
7
11
 
@@ -15,6 +19,6 @@ The preset includes the compatible `@dino-ovum/theme`. Use Docusaurus 3.10.1, Re
15
19
 
16
20
  Search is enabled by default. PWA and the `/updates` page are opt-in. Site settings override defaults; nested objects merge and arrays replace. Additional site plugins, themes, and presets are retained.
17
21
 
18
- Read the [configuration guide](https://github.com/4BFC/dino-ovum/blob/main/docs/configuration.md) for options, translation overrides, and migration. See the [repository README](https://github.com/4BFC/dino-ovum#install) for local archive installation while the initial release is being prepared.
22
+ Read the [configuration guide](https://github.com/4BFC/dino-ovum/blob/main/docs/configuration.md) for options, translation overrides, and migration.
19
23
 
20
24
  MIT. Dependencies retain their own licenses.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.1.0",
2
+ "version": "0.2.0",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
5
  "author": "4BFC",
@@ -34,7 +34,7 @@
34
34
  "docusaurus-plugin-sass": "^0.2.7",
35
35
  "sass": "^1.106.1",
36
36
  "prism-react-renderer": "^2.3.0",
37
- "@dino-ovum/theme": "0.1.0"
37
+ "@dino-ovum/theme": "0.2.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@docusaurus/core": "3.10.1",
package/src/config.js CHANGED
@@ -19,19 +19,6 @@ export function mergeConfig(defaults, overrides) {
19
19
  return result;
20
20
  }
21
21
 
22
- const escapeRegex = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
23
-
24
- // activeBaseRegex is tested against the full pathname, which carries the
25
- // baseUrl and, outside the default locale, a locale segment.
26
- export function createHomeActiveRegex({baseUrl, home, localePrefixes}) {
27
- const base = escapeRegex(`/${baseUrl.replace(/^\/+|\/+$/g, '')}/`.replace(/^\/\/$/, '/'));
28
- const locale = localePrefixes.length
29
- ? `(?:(?:${localePrefixes.map(escapeRegex).join('|')})/)?`
30
- : '';
31
- const homePath = home.replace(/^\/+|\/+$/g, '');
32
- return `^${base}${locale}${homePath ? `${escapeRegex(homePath)}/?` : ''}$`;
33
- }
34
-
35
22
  export function createDinoConfig(siteConfig, presetOptions = {}) {
36
23
  if (!siteConfig?.title || !siteConfig?.url) {
37
24
  throw new TypeError('createDinoConfig requires a site title and URL.');
@@ -43,13 +30,6 @@ export function createDinoConfig(siteConfig, presetOptions = {}) {
43
30
  ko: {label: '한국어', htmlLang: 'ko'},
44
31
  ja: {label: '日本語', htmlLang: 'ja'},
45
32
  };
46
- const home = `/${options.documents.routeBasePath.replace(/^\/+|\/+$/g, '')}`;
47
- const defaultLocale = siteConfig.i18n?.defaultLocale ?? locales[0];
48
- const homeActiveRegex = createHomeActiveRegex({
49
- baseUrl: siteConfig.baseUrl ?? '/',
50
- home,
51
- localePrefixes: locales.filter((locale) => locale !== defaultLocale),
52
- });
53
33
  const defaults = {
54
34
  baseUrl: '/',
55
35
  staticDirectories: ['public'],
@@ -74,14 +54,12 @@ export function createDinoConfig(siteConfig, presetOptions = {}) {
74
54
  title: siteConfig.title,
75
55
  items: [
76
56
  {type: 'custom-sidebarToggle', position: 'left'},
77
- {
78
- to: home,
79
- label: 'Home',
80
- position: 'right',
81
- activeBaseRegex: homeActiveRegex,
82
- },
57
+ // The site title already links home; its old place opens the comment drawer.
58
+ ...(options.comments ? [{type: 'custom-comments', position: 'right'}] : []),
83
59
  ...(options.updates ? [{type: 'custom-recentUpdates', position: 'right'}] : []),
84
60
  ...(locales.length > 1 ? [{type: 'custom-languageDropdown', position: 'right'}] : []),
61
+ // On narrow screens it holds recent updates, languages, and the color mode.
62
+ {type: 'custom-moreMenu', position: 'right'},
85
63
  ],
86
64
  },
87
65
  prism: {theme: prismThemes.github, darkTheme: prismThemes.dracula},
package/src/index.js CHANGED
@@ -94,7 +94,10 @@ export default function dinoPreset(context, presetOptions = {}) {
94
94
  ],
95
95
  ]
96
96
  : []),
97
- [require.resolve('@dino-ovum/theme'), {customCss: options.customCss}],
97
+ [
98
+ require.resolve('@dino-ovum/theme'),
99
+ {customCss: options.customCss, comments: options.comments},
100
+ ],
98
101
  ],
99
102
  };
100
103
  }
package/src/options.js CHANGED
@@ -5,7 +5,7 @@ export function resolveOptions(options = {}) {
5
5
  if (!options || typeof options !== 'object' || Array.isArray(options)) {
6
6
  throw new TypeError('Dino Ovum options must be an object.');
7
7
  }
8
- const supported = ['documents', 'customCss', 'search', 'pwa', 'updates'];
8
+ const supported = ['documents', 'customCss', 'search', 'pwa', 'updates', 'comments'];
9
9
  for (const key of Object.keys(options)) {
10
10
  if (!supported.includes(key)) throw new TypeError(`Unknown Dino Ovum option: ${key}`);
11
11
  }
@@ -30,8 +30,10 @@ export function resolveOptions(options = {}) {
30
30
  throw new TypeError(`${key} must be a boolean or an options object.`);
31
31
  }
32
32
  }
33
- if (options.updates !== undefined && typeof options.updates !== 'boolean') {
34
- throw new TypeError('updates must be a boolean.');
33
+ for (const key of ['updates', 'comments']) {
34
+ if (options[key] !== undefined && typeof options[key] !== 'boolean') {
35
+ throw new TypeError(`${key} must be a boolean.`);
36
+ }
35
37
  }
36
38
  const customCss =
37
39
  options.customCss === undefined
@@ -55,5 +57,6 @@ export function resolveOptions(options = {}) {
55
57
  search: options.search ?? true,
56
58
  pwa: options.pwa ?? false,
57
59
  updates: options.updates ?? false,
60
+ comments: options.comments ?? false,
58
61
  };
59
62
  }
@@ -1,7 +1,7 @@
1
1
  // Docusaurus 3.10.1 generates mixed ESM/CommonJS (registry, client modules).
2
2
  // Scope: generated JS parsing and temporary CommonJS SSG chunks only.
3
3
  // Upstream: https://github.com/facebook/docusaurus/discussions/11326
4
- // Recheck this compatibility layer when upgrading Docusaurus; see docs/development.md.
4
+ // Recheck this compatibility layer when upgrading Docusaurus.
5
5
  export default function generatedModuleCompat({generatedFilesDir}) {
6
6
  return {
7
7
  name: 'generated-module-compat',