markupress 0.0.2 → 0.1.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.
Files changed (48) hide show
  1. package/README.md +244 -10
  2. package/dist/cli.js +1 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/content.d.ts +42 -1
  5. package/dist/content.d.ts.map +1 -1
  6. package/dist/content.js +276 -23
  7. package/dist/content.js.map +1 -1
  8. package/dist/controllers/code.d.ts +7 -0
  9. package/dist/controllers/code.d.ts.map +1 -0
  10. package/dist/controllers/code.js +31 -0
  11. package/dist/controllers/code.js.map +1 -0
  12. package/dist/controllers/outline.d.ts +8 -0
  13. package/dist/controllers/outline.d.ts.map +1 -0
  14. package/dist/controllers/outline.js +45 -0
  15. package/dist/controllers/outline.js.map +1 -0
  16. package/dist/controllers/shell.d.ts +6 -1
  17. package/dist/controllers/shell.d.ts.map +1 -1
  18. package/dist/controllers/shell.js +19 -24
  19. package/dist/controllers/shell.js.map +1 -1
  20. package/dist/index.d.ts +6 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/markdown.d.ts +24 -0
  25. package/dist/markdown.d.ts.map +1 -0
  26. package/dist/markdown.js +54 -0
  27. package/dist/markdown.js.map +1 -0
  28. package/dist/navigation.d.ts +51 -0
  29. package/dist/navigation.d.ts.map +1 -0
  30. package/dist/navigation.js +71 -0
  31. package/dist/navigation.js.map +1 -0
  32. package/dist/site.d.ts +47 -10
  33. package/dist/site.d.ts.map +1 -1
  34. package/dist/site.js +152 -262
  35. package/dist/site.js.map +1 -1
  36. package/dist/theme.d.ts +2 -1
  37. package/dist/theme.d.ts.map +1 -1
  38. package/dist/theme.js +4 -34
  39. package/dist/theme.js.map +1 -1
  40. package/dist/versions.d.ts.map +1 -1
  41. package/dist/versions.js +10 -5
  42. package/dist/versions.js.map +1 -1
  43. package/package.json +21 -12
  44. package/styles/base.css +1 -21
  45. package/styles/prose.css +14 -0
  46. package/theme/outline.html +11 -0
  47. package/theme/shell.html +66 -0
  48. package/theme/theme.css +52 -0
@@ -1,44 +1,39 @@
1
- /** Native controls and storage own interaction; HTML Next owns reactive state and cleanup. */
1
+ /**
2
+ * Native controls and storage own interaction; HTML Next owns reactive state and cleanup. The drawer is a
3
+ * native popover and the dropdowns are native details, which open without this controller. HTMLKit keeps
4
+ * the shell across client navigation, so a followed link here closes the drawer and any open dropdown, as a
5
+ * document load would.
6
+ */
2
7
  export default function shell(host) {
3
8
  host.on('connect', () => {
4
9
  const document = host.root.ownerDocument;
5
10
  const window = document.defaultView;
6
- let saved = null;
7
- try {
8
- saved = window.localStorage.getItem('markupress:theme');
9
- }
10
- catch { /* Storage can be disabled while native controls remain usable. */ }
11
- host.state.dark = saved === 'dark' || (saved === null && window.matchMedia('(prefers-color-scheme: dark)').matches);
12
- const actions = host.root.querySelector(':scope > header > .actions');
13
- const applyTheme = () => {
14
- document.documentElement.dataset.theme = host.state.dark ? 'dark' : 'light';
11
+ // The plugin's head script chose the theme before first paint.
12
+ host.state.dark = document.documentElement.dataset.theme === 'dark';
13
+ const close = (except) => {
14
+ for (const open of host.root.querySelectorAll('header details[open]'))
15
+ if (!open.contains(except ?? null))
16
+ open.removeAttribute('open');
15
17
  };
16
- applyTheme();
17
- // HTMLKit head metadata admits no script, so a saved theme lands after first paint. Settle it
18
- // at once instead of animating controls out of the default theme; user toggles still animate.
19
- for (const transition of document.getAnimations())
20
- if (transition instanceof window.CSSTransition)
21
- transition.finish();
22
18
  const click = (event) => {
23
19
  const target = event.target;
24
20
  if (!(target instanceof window.Element))
25
21
  return;
26
- if (!actions.contains(target))
27
- return;
28
- const action = target.closest('[data-action]')?.getAttribute('data-action');
29
- if (action === 'theme') {
22
+ if (target.closest('[data-action="theme"]')) {
30
23
  host.state.dark = !host.state.dark;
31
- applyTheme();
32
24
  const theme = host.state.dark ? 'dark' : 'light';
25
+ document.documentElement.dataset.theme = theme;
33
26
  try {
34
27
  window.localStorage.setItem('markupress:theme', theme);
35
28
  }
36
29
  catch { /* Theme still applies for this page. */ }
37
30
  }
38
- if (action === 'menu') {
39
- host.state.menu = !host.state.menu;
40
- }
31
+ const link = target.closest('a[href]');
32
+ close(link ? undefined : target);
33
+ if (link)
34
+ host.root.querySelector('#documentation-navigation:popover-open')?.hidePopover();
41
35
  };
36
+ // The page sits inside the shell, so this sees every click: one outside a dropdown closes it.
42
37
  host.root.addEventListener('click', click);
43
38
  return () => host.root.removeEventListener('click', click);
44
39
  });
@@ -1 +1 @@
1
- {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/controllers/shell.ts"],"names":[],"mappings":"AAGA,8FAA8F;AAC9F,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,IAAmB;IAC/C,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;QACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,WAAY,CAAC;QACrC,IAAI,KAAK,GAAkB,IAAI,CAAC;QAChC,IAAI,CAAC;YAAC,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,kEAAkE,CAAC,CAAC;QAC7I,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,KAAK,MAAM,IAAI,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC,CAAC,OAAO,CAAC,CAAC;QACpH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,4BAA4B,CAAE,CAAC;QACvE,MAAM,UAAU,GAAG,GAAG,EAAE;YACtB,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CA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AO,CAAC;gBACjD,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;gBAC/C,IAAI,CAAC;oBAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,wCAAwC,CAAC,CAAC;YACpH,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACjC,IAAI,IAAI;gBAAE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAc,wCAAwC,CAAC,EAAE,WAAW,EAAE,CAAC;QAC1G,CAAC,CAAC;QACF,8FAA8F;QAC9F,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  export { compileMarkdown } from './content.js';
2
- export type { CompiledMarkdown, MarkdownOptions } from './content.js';
3
- export { buildSite, devSite, prepareSite, previewSite } from './site.js';
4
- export type { DocumentationPage, DocumentationVersion, MarkupressOptions, PreparedSite } from './site.js';
2
+ export type { CompiledMarkdown, FrontMatter, MarkdownOptions, OutlineItem } from './content.js';
3
+ export { markdown } from './markdown.js';
4
+ export type { MarkdownPluginOptions } from './markdown.js';
5
+ export type { Link, NavItem, SidebarItem, SidebarNode } from './navigation.js';
6
+ export { buildSite, devSite, markupress, previewSite, siteOptions } from './site.js';
7
+ export type { DocumentationPage, DocumentationVersion, MarkupressOptions } from './site.js';
5
8
  export { snapshotVersion, versionLinks } from './versions.js';
6
9
  export type { VersionLink } from './versions.js';
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACzE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACrF,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Public exports are introduced with implemented, verified product behavior.
2
2
  export { compileMarkdown } from './content.js';
3
- export { buildSite, devSite, prepareSite, previewSite } from './site.js';
3
+ export { markdown } from './markdown.js';
4
+ export { buildSite, devSite, markupress, previewSite, siteOptions } from './site.js';
4
5
  export { snapshotVersion, versionLinks } from './versions.js';
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAErF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,24 @@
1
+ import type { HtmlKitPlugin } from '@nextwebwg/htmlkit';
2
+ import { type CompiledMarkdown, type FrontMatter } from './content.js';
3
+ export interface MarkdownPluginOptions {
4
+ /** Directory that a page's root-relative images and files (/logo.svg) come from; without one they stay site URLs. */
5
+ readonly publicDir?: (file: string) => string | undefined;
6
+ /** Called with each compiled page and its URL, for example to catalog documents. */
7
+ readonly onPage?: (page: CompiledMarkdown & {
8
+ readonly file: string;
9
+ readonly href: string | undefined;
10
+ }) => void;
11
+ /** Stylesheet files every Markdown page component imports, such as a theme's prose styles. */
12
+ readonly styles?: readonly string[];
13
+ /** Number the lines of every highlighted code block unless its fence says `:no-line-numbers`. */
14
+ readonly lineNumbers?: boolean;
15
+ /** Front matter for a page that its own fields override, such as a folder's label and position on its index page. */
16
+ readonly frontmatter?: (file: string) => FrontMatter | undefined;
17
+ }
18
+ /**
19
+ * An HTMLKit page plugin: each .md file compiles to an HTML Next page, which HTMLKit routes, orders,
20
+ * renders, and builds like an .html page. Links to other .md files and referenced files resolve
21
+ * through HTMLKit, so the plugin holds no routing of its own.
22
+ */
23
+ export declare function markdown(options?: MarkdownPluginOptions): HtmlKitPlugin;
24
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAmB,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAExF,MAAM,WAAW,qBAAqB;IACpC,qHAAqH;IACrH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC1D,oFAAoF;IACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,KAAK,IAAI,CAAC;IAClH,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,iGAAiG;IACjG,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,qHAAqH;IACrH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;CAClE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,qBAA0B,GAAG,aAAa,CAkB3E"}
@@ -0,0 +1,54 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { compileMarkdown } from './content.js';
4
+ /**
5
+ * An HTMLKit page plugin: each .md file compiles to an HTML Next page, which HTMLKit routes, orders,
6
+ * renders, and builds like an .html page. Links to other .md files and referenced files resolve
7
+ * through HTMLKit, so the plugin holds no routing of its own.
8
+ */
9
+ export function markdown(options = {}) {
10
+ return { name: 'markdown', pages: { extensions: ['.md'], async compile(source, page) {
11
+ const href = page.href(page.file);
12
+ // The URL, not the machine's path, names the page, so builds are reproducible.
13
+ const pageName = 'page-md-' + createHash('sha256').update(href ?? page.file).digest('hex').slice(0, 20);
14
+ // compileMarkdown also passes through links it already resolved; return those unchanged.
15
+ const resolved = new Set();
16
+ const frontmatter = options.frontmatter?.(page.file);
17
+ const compiled = await compileMarkdown(source, { file: page.file, pageName, ...(options.styles ? { styles: options.styles } : {}),
18
+ ...(options.lineNumbers === undefined ? {} : { lineNumbers: options.lineNumbers }), ...(frontmatter ? { frontmatter } : {}), resolveLink(target, kind) {
19
+ if (resolved.has(target))
20
+ return target;
21
+ const url = link(target, kind, page, options);
22
+ resolved.add(url);
23
+ return url;
24
+ } });
25
+ options.onPage?.({ ...compiled, file: page.file, href });
26
+ return compiled.resource;
27
+ } } };
28
+ }
29
+ function link(href, kind, page, options) {
30
+ if (/^(?:[A-Za-z][A-Za-z\d+.-]*:|#|\/\/)/.test(href))
31
+ return href;
32
+ if (href.startsWith('/') && kind === 'link')
33
+ return href;
34
+ const [path, suffix = ''] = href.split(/(?=[?#])/, 2);
35
+ let target;
36
+ if (path.startsWith('/')) {
37
+ const directory = options.publicDir?.(page.file);
38
+ if (directory === undefined)
39
+ return href;
40
+ target = resolve(directory, '.' + decodeURIComponent(path));
41
+ }
42
+ else
43
+ target = resolve(dirname(page.file), decodeURIComponent(path));
44
+ if (path.endsWith('.md')) {
45
+ const url = page.href(target);
46
+ if (url === undefined)
47
+ throw new Error(`${page.file}: missing document ${href}.`);
48
+ return url + suffix;
49
+ }
50
+ if (kind === 'asset' || path.includes('.'))
51
+ return page.asset(target) + suffix;
52
+ return href;
53
+ }
54
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,eAAe,EAA2C,MAAM,cAAc,CAAC;AAexF;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAO,GAA0B,EAAE;IAC1D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI;gBACjF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAClC,+EAA+E;gBAC/E,MAAM,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACxG,yFAAyF;gBACzF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;gBACnC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC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AI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACzC,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;;QAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IACtE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,sBAAsB,IAAI,GAAG,CAAC,CAAC;QAClF,OAAO,GAAG,GAAG,MAAM,CAAC;IACtB,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC/E,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { NavigationItem, NavigationNode } from '@nextwebwg/htmlkit';
2
+ import type { FrontMatter } from './content.js';
3
+ /** A top navigation or footer link. A path starting with `/` is a page of the selected version. */
4
+ export interface Link {
5
+ readonly label: string;
6
+ readonly href: string;
7
+ }
8
+ /** A top navigation entry: a link, or a dropdown of links. */
9
+ export type NavItem = Link | {
10
+ readonly label: string;
11
+ readonly items: readonly Link[];
12
+ };
13
+ /** An explicit sidebar entry: a page by its path in the version (`/guide/install/`), a link, or a group. */
14
+ export type SidebarItem = string | Link | {
15
+ readonly label: string;
16
+ readonly items: readonly SidebarItem[];
17
+ readonly collapsed?: boolean;
18
+ };
19
+ /** A sidebar entry as `<hk-nav>` renders it: a page or link with `href`, and a folder or group with `children`. */
20
+ export interface SidebarNode {
21
+ readonly label: string;
22
+ readonly href?: string;
23
+ readonly current: string;
24
+ readonly open: boolean;
25
+ readonly depth: number;
26
+ readonly children: readonly SidebarNode[];
27
+ }
28
+ /** Whether a Markdown file is its folder's index page. */
29
+ export declare const isIndex: (file: string) => boolean;
30
+ interface Category {
31
+ readonly label?: string;
32
+ readonly position?: number;
33
+ readonly collapsed?: boolean;
34
+ }
35
+ /** A folder's group metadata. YAML also reads Docusaurus's JSON. */
36
+ export declare function category(directory: string): Category;
37
+ /**
38
+ * The front matter a folder's `_category` gives its index page: the label and position that HTMLKit's navigation
39
+ * tree reads from the index page as the folder's own. `top` is the version's content directory, whose index page
40
+ * is the version home and has no folder to order.
41
+ */
42
+ export declare function categoryFrontMatter(file: string, top: string): FrontMatter | undefined;
43
+ /**
44
+ * HTMLKit's navigation tree with Markupress's group policy: a folder stays open unless its `_category` collapses
45
+ * it, and one holding the current page is always open. `collapsed` tells whether a folder's index page URL starts closed.
46
+ */
47
+ export declare function generatedSidebar(tree: readonly NavigationNode[], collapsed: (href: string) => boolean): SidebarNode[];
48
+ /** A configured sidebar, resolved against the version's pages so entries get their labels and current page. */
49
+ export declare function configuredSidebar(entries: readonly SidebarItem[], items: readonly NavigationItem[], href: (path: string) => string, current: string, depth?: number): SidebarNode[];
50
+ export {};
51
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,mGAAmG;AACnG,MAAM,WAAW,IAAI;IAA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GAAG,SAAS,CAWtF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,WAAW,EAAE,CAGrH;AAED,+GAA+G;AAC/G,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,WAAW,EAAE,CAc9K"}
@@ -0,0 +1,71 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { basename, dirname, join } from 'node:path';
3
+ import { parse } from 'yaml';
4
+ const index = /^(?:\d+\.)?index\.md$/;
5
+ /** Whether a Markdown file is its folder's index page. */
6
+ export const isIndex = (file) => index.test(basename(file));
7
+ // Markupress's own name, and Docusaurus's, so a migrated folder keeps its metadata.
8
+ const categoryFiles = ['_category.yml', '_category_.yml', '_category_.json'];
9
+ /** A folder's group metadata. YAML also reads Docusaurus's JSON. */
10
+ export function category(directory) {
11
+ const file = categoryFiles.map(name => join(directory, name)).find(existsSync);
12
+ if (file === undefined)
13
+ return {};
14
+ const value = parse(readFileSync(file, 'utf8'));
15
+ const fields = (value ?? {});
16
+ if (typeof fields !== 'object' || Array.isArray(fields))
17
+ throw new Error(`${file}: must be a mapping.`);
18
+ for (const [name, type] of [['label', 'string'], ['position', 'number'], ['collapsed', 'boolean']]) {
19
+ if (fields[name] !== undefined && typeof fields[name] !== type)
20
+ throw new Error(`${file}: ${name} must be a ${type}.`);
21
+ }
22
+ // HTMLKit's hk:order is a whole number, as a file's number prefix is.
23
+ if (fields.position !== undefined && !(Number.isSafeInteger(fields.position) && fields.position >= 0))
24
+ throw new Error(`${file}: position must be a whole number.`);
25
+ return fields;
26
+ }
27
+ /**
28
+ * The front matter a folder's `_category` gives its index page: the label and position that HTMLKit's navigation
29
+ * tree reads from the index page as the folder's own. `top` is the version's content directory, whose index page
30
+ * is the version home and has no folder to order.
31
+ */
32
+ export function categoryFrontMatter(file, top) {
33
+ // HTMLKit labels and orders a folder only through its index page, so a _category without one could not apply.
34
+ for (let directory = dirname(file); directory.length > top.length; directory = dirname(directory)) {
35
+ const metadata = categoryFiles.map(name => join(directory, name)).find(existsSync);
36
+ if (metadata !== undefined && !readdirSync(directory).some(name => index.test(name))) {
37
+ throw new Error(`${metadata}: a folder's label, position and collapsed state apply through its index page; add an index.md to ${directory}.`);
38
+ }
39
+ }
40
+ if (!isIndex(file) || dirname(file) === top)
41
+ return undefined;
42
+ const { label, position } = category(dirname(file));
43
+ return { ...(label === undefined ? {} : { sidebarLabel: label }), ...(position === undefined ? {} : { sidebarPosition: position }) };
44
+ }
45
+ /**
46
+ * HTMLKit's navigation tree with Markupress's group policy: a folder stays open unless its `_category` collapses
47
+ * it, and one holding the current page is always open. `collapsed` tells whether a folder's index page URL starts closed.
48
+ */
49
+ export function generatedSidebar(tree, collapsed) {
50
+ return tree.map(node => ({ ...node, open: node.open || (node.children.length > 0 && !(node.href !== undefined && collapsed(node.href))),
51
+ children: generatedSidebar(node.children, collapsed) }));
52
+ }
53
+ /** A configured sidebar, resolved against the version's pages so entries get their labels and current page. */
54
+ export function configuredSidebar(entries, items, href, current, depth = 0) {
55
+ return entries.map(entry => {
56
+ if (typeof entry === 'string') {
57
+ const page = items.find(item => item.href === href(entry));
58
+ if (page === undefined)
59
+ throw new Error(`sidebar: no page at ${entry}.`);
60
+ return { label: page.label, href: page.href, current: page.current, open: false, depth, children: [] };
61
+ }
62
+ if ('items' in entry) {
63
+ const children = configuredSidebar(entry.items, items, href, current, depth + 1);
64
+ return { label: entry.label, current: 'false', open: entry.collapsed !== true || children.some(holdsCurrent), depth, children };
65
+ }
66
+ const target = href(entry.href);
67
+ return { label: entry.label, href: target, current: target === current ? 'page' : 'false', open: false, depth, children: [] };
68
+ });
69
+ }
70
+ const holdsCurrent = (node) => node.current === 'page' || node.children.some(holdsCurrent);
71
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAoB7B,MAAM,KAAK,GAAG,uBAAuB,CAAC;AACtC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,oFAAoF;AACpF,MAAM,aAAa,GAAG,CAAC,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;AAG7E,oEAAoE;AACpE,MAAM,UAAU,QAAQ,CAAC,SAAiB;IACxC,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/E,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAClC,MAAM,KAAK,GAAY,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE,CAA4B,CAAC;IACxD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,sBAAsB,CAAC,CAAC;IACxG,KAAK,MAAM,CAAC,IAAI,EAAE,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AAC"}
package/dist/site.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type ApplicationOptions, type ApplicationServer, type BuildResult } from '@nextwebwg/htmlkit';
1
+ import { type ApplicationOptions, type ApplicationServer, type BuildResult, type HtmlKitPlugin, type ServerOptions } from '@nextwebwg/htmlkit';
2
+ import { type Link, type NavItem, type SidebarItem } from './navigation.js';
2
3
  export interface DocumentationVersion {
3
4
  readonly id: string;
4
5
  readonly label?: string;
@@ -16,23 +17,59 @@ export interface MarkupressOptions {
16
17
  readonly defaultVersion?: string;
17
18
  readonly host?: string;
18
19
  readonly port?: number;
20
+ /** Number the lines of every highlighted code block unless its fence says `:no-line-numbers`. */
21
+ readonly lineNumbers?: boolean;
22
+ /**
23
+ * An HTML Next layout component, relative to the root, that replaces the Markupress shell. It receives the
24
+ * loader data its `<prop>` declarations name: see "Layout data" in the README.
25
+ */
26
+ readonly layout?: string;
27
+ /** The logo before the title: one image, or one per theme. Paths starting with `/` are files in `public/`. */
28
+ readonly logo?: string | {
29
+ readonly light: string;
30
+ readonly dark?: string;
31
+ };
32
+ /** The site's icon, such as `/favicon.svg` from `public/`. */
33
+ readonly favicon?: string;
34
+ /** Top navigation: links, and dropdowns of links. A path starting with `/` is a page of the version being read. */
35
+ readonly nav?: readonly NavItem[];
36
+ /** Links at the end of the top navigation, each shown as its `icon` image (from `public/`) or its label. */
37
+ readonly social?: readonly (Link & {
38
+ readonly icon?: string;
39
+ })[];
40
+ /** Text of the badge beside the title. Without it, a site with several versions shows the selected version's label. */
41
+ readonly versionBadge?: string;
42
+ /** Explicit sidebars by section path (`/`, `/editor/`). Every other section's sidebar is generated from its folder. */
43
+ readonly sidebar?: Readonly<Record<string, readonly SidebarItem[]>>;
44
+ /** Footer link columns and a copyright line. */
45
+ readonly footer?: {
46
+ readonly columns?: readonly {
47
+ readonly title: string;
48
+ readonly items: readonly Link[];
49
+ }[];
50
+ readonly copyright?: string;
51
+ };
19
52
  }
20
53
  export interface DocumentationPage {
21
54
  readonly id: string;
22
55
  readonly version: string;
23
56
  readonly source: string;
57
+ /** Application-relative URL in its version, such as /v/current/guide/install/. */
24
58
  readonly pathname: string;
25
- readonly label: string;
26
- readonly pageName: string;
27
59
  }
28
- export interface PreparedSite {
29
- readonly application: ApplicationOptions;
30
- readonly documents: readonly DocumentationPage[];
31
- readonly sourceFiles: readonly string[];
32
- }
33
- /** Compile author content into an owned HTMLKit application, preserving original import locations. */
34
- export declare function prepareSite(options?: MarkupressOptions): Promise<PreparedSite>;
60
+ /**
61
+ * Versioned documentation as an HTMLKit plugin. Markdown pages come from the markdown plugin, and
62
+ * HTMLKit routes them: each version's directory serves /v/<id>/, and the default version's also
63
+ * serves the site root. Markupress keeps only the version catalog its switcher needs.
64
+ */
65
+ export declare function markupress(options?: MarkupressOptions): HtmlKitPlugin;
66
+ /**
67
+ * HTMLKit options for a Markupress site, as the CLI runs it: the site's own HTMLKit options (its `htmlkit.config.ts`)
68
+ * with `markupress()` added after their plugins. Markupress's own `base` and `outDir`, when set, win over HTMLKit's.
69
+ */
70
+ export declare function siteOptions(options?: MarkupressOptions, htmlkit?: ApplicationOptions): ServerOptions;
35
71
  export declare function buildSite(options?: MarkupressOptions): Promise<BuildResult>;
36
72
  export declare function previewSite(options?: MarkupressOptions): Promise<ApplicationServer>;
73
+ /** HTMLKit's watcher recompiles Markdown and reloads open pages after each edit. */
37
74
  export declare function devSite(options?: MarkupressOptions): Promise<ApplicationServer>;
38
75
  //# sourceMappingURL=site.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwD,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAI7J,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ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