@sullux/markdown-docs 2.0.1 → 2.0.2

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/lib/config.js CHANGED
@@ -62,8 +62,9 @@ const normalizeConfig = (opts = {}) => {
62
62
  const favicon = fileConfig.favicon || opts.favicon || ''
63
63
  const links = fileConfig.links || opts.links || []
64
64
  const theme = { ...(fileConfig.theme || {}), ...(opts.theme || {}) }
65
+ const math = opts.math !== undefined ? opts.math : fileConfig.math
65
66
 
66
- return { input, output, title, baseUrl, logo, favicon, links, theme }
67
+ return { input, output, title, baseUrl, logo, favicon, links, theme, math }
67
68
  }
68
69
 
69
70
  module.exports = { parseArgs, normalizeConfig, loadFileConfig }
package/lib/layout.js CHANGED
@@ -24,16 +24,17 @@ const renderFavicon = (f) => f ? `<link rel="icon" href="${f}" />` : `<link rel=
24
24
 
25
25
  const renderHeaderLinks = (links = []) => links?.length ? `<div class="header-links">` + links.map((l) => `<a href="${l.url}" target="_blank" rel="noopener" class="header-link">${l.title} ↗</a>`).join('') + `</div>` : ''
26
26
 
27
- const renderPageLayout = ({ title, siteTitle, navTree, toc, contentHtml, currentHref, logo, favicon, links, theme }) => {
27
+ const renderPageLayout = ({ title, siteTitle, navTree, toc, contentHtml, currentHref, logo, favicon, links, theme, head = [] }) => {
28
28
  const sidebarNav = renderNavTree(navTree, currentHref)
29
29
  return `<!DOCTYPE html><html lang="en"><head>
30
30
  <meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" />
31
31
  <title>${title}</title>${renderFavicon(favicon)}<style>${getCss(theme)}</style>
32
- <script>
32
+ ${head?.length ? head.join('\n') + '\n' : ''} <script>
33
33
  function setThemeMode(m) {
34
34
  try { localStorage.setItem('sullux-theme-mode', m); } catch(e) {}
35
35
  if (m === 'light' || m === 'dark') document.documentElement.setAttribute('data-theme', m); else document.documentElement.removeAttribute('data-theme');
36
36
  document.querySelectorAll('.theme-opt').forEach(function(b) { b.classList.toggle('active', b.getAttribute('data-mode') === m); });
37
+ try { window.dispatchEvent(new CustomEvent('@sullux/markdown:theme', { detail: { mode: m } })); } catch(e) {}
37
38
  }
38
39
  function toggleDrawer(id) {
39
40
  var d = document.getElementById(id), b = document.getElementById('drawer-backdrop'), open = d?.classList.contains('open');
package/lib/site.js CHANGED
@@ -53,7 +53,7 @@ const generateSite = (options = {}) => {
53
53
  const rawMd = fs.readFileSync(file.fullPath, 'utf8')
54
54
  const ast = parse(rawMd)
55
55
  const toc = extractToc(ast)
56
- const rawHtml = markdownToHtml(ast)
56
+ const { html: rawHtml, head: docHead } = markdownToHtml(ast)
57
57
  const contentHtml = rewriteMarkdownLinks(rawHtml)
58
58
  const relHtmlPath = normalizeHtmlPath(file.relPath)
59
59
  const outHtmlPath = path.join(config.output, relHtmlPath)
@@ -76,6 +76,7 @@ const generateSite = (options = {}) => {
76
76
  favicon: config.favicon,
77
77
  links: config.links,
78
78
  theme: config.theme,
79
+ head: docHead,
79
80
  })
80
81
 
81
82
  fs.writeFileSync(outHtmlPath, fullHtml, 'utf8')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sullux/markdown-docs",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "A zero-dependency, local-first static documentation site generator compiling GitBook-style Markdown docs.",
5
5
  "main": "./index.js",
6
6
  "bin": {