ghostcn 1.5.0 → 1.6.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 (50) hide show
  1. package/dist/commands/create.js +10 -3
  2. package/dist/commands/diff.js +47 -5
  3. package/dist/commands/init.js +17 -8
  4. package/dist/commands/list.js +22 -4
  5. package/dist/registry/components/accordion.json +66 -0
  6. package/dist/registry/components/announcement-bar.json +79 -0
  7. package/dist/registry/components/archive-header.json +1 -1
  8. package/dist/registry/components/author-card.json +2 -2
  9. package/dist/registry/components/author-list.json +1 -1
  10. package/dist/registry/components/avatar.json +62 -0
  11. package/dist/registry/components/breadcrumbs.json +59 -0
  12. package/dist/registry/components/button.json +1 -1
  13. package/dist/registry/components/featured-posts.json +2 -2
  14. package/dist/registry/components/input.json +8 -2
  15. package/dist/registry/components/member-cta.json +1 -1
  16. package/dist/registry/components/newsletter-form.json +12 -3
  17. package/dist/registry/components/pagination.json +2 -2
  18. package/dist/registry/components/post-card.json +2 -2
  19. package/dist/registry/components/post-grid.json +1 -1
  20. package/dist/registry/components/post-header.json +2 -2
  21. package/dist/registry/components/pricing-table.json +24 -4
  22. package/dist/registry/components/reading-progress.json +73 -0
  23. package/dist/registry/components/related-posts.json +6 -0
  24. package/dist/registry/components/share-buttons.json +76 -0
  25. package/dist/registry/components/site-footer.json +2 -2
  26. package/dist/registry/components/site-header.json +1 -1
  27. package/dist/registry/components/table-of-contents.json +12 -2
  28. package/dist/registry/components/tag-grid.json +1 -1
  29. package/dist/registry/components/tag-list.json +1 -1
  30. package/dist/registry/components/theme-toggle.json +65 -0
  31. package/dist/registry/components/visibility-badge.json +71 -0
  32. package/dist/registry/index.json +89 -4
  33. package/dist/templates/playground/index.html +2 -2
  34. package/dist/templates/playground/playground.css +8 -1
  35. package/dist/templates/playground/playground.js +39 -5
  36. package/dist/templates/playground/preview.css +1 -0
  37. package/dist/templates/theme-tools.mjs +62 -24
  38. package/dist/utils/component-diff.d.ts +1 -1
  39. package/dist/utils/component-diff.js +46 -17
  40. package/dist/utils/component-files.js +3 -2
  41. package/dist/utils/component-history.js +1 -1
  42. package/dist/utils/playground-server.js +34 -12
  43. package/dist/utils/preview-renderer.d.ts +5 -0
  44. package/dist/utils/preview-renderer.js +20 -6
  45. package/dist/utils/registry.js +15 -5
  46. package/dist/utils/theme-files.js +14 -7
  47. package/dist/utils/theme-project.js +6 -4
  48. package/dist/utils/theme-scaffold.js +22 -7
  49. package/dist/utils/theme.js +39 -32
  50. package/package.json +1 -1
@@ -9,13 +9,13 @@
9
9
  "name": "site-footer.hbs",
10
10
  "type": "partial",
11
11
  "target": "partials/components/site-footer.hbs",
12
- "content": "{{!-- Styling parameters: class, innerClass, navClass, socialClass --}}\n{{#with this as |ghostcnStyles|}}\n{{!-- Component: Site Footer | Usage: {{> \"components/site-footer\"}} --}}\n<footer class=\"ghcn-footer{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\">\n <div class=\"ghcn-footer__inner{{#if ghostcnStyles.innerClass}} {{ghostcnStyles.innerClass}}{{/if}} ghcn-container\">\n <div class=\"ghcn-footer__brand\">\n <a href=\"{{@site.url}}\">{{@site.title}}</a>\n {{#if @site.description}}<p>{{@site.description}}</p>{{/if}}\n </div>\n <nav class=\"ghcn-footer__nav{{#if ghostcnStyles.navClass}} {{ghostcnStyles.navClass}}{{/if}}\" aria-label=\"Footer navigation\">{{navigation type=\"secondary\"}}</nav>\n <div class=\"ghcn-footer__social{{#if ghostcnStyles.socialClass}} {{ghostcnStyles.socialClass}}{{/if}}\">\n {{#if @site.facebook}}<a href=\"{{social_url type=\"facebook\"}}\" target=\"_blank\" rel=\"noopener\">Facebook</a>{{/if}}\n {{#if @site.twitter}}<a href=\"{{social_url type=\"twitter\"}}\" target=\"_blank\" rel=\"noopener\">X</a>{{/if}}\n <a href=\"{{@site.url}}/rss/\">RSS</a>\n </div>\n </div>\n <div class=\"ghcn-footer__legal ghcn-container\">\n <span>&copy; {{date format=\"YYYY\"}} {{@site.title}}</span>\n <span>Published with <a href=\"https://ghost.org\" target=\"_blank\" rel=\"noopener\">Ghost</a></span>\n </div>\n</footer>\n{{/with}}"
12
+ "content": "{{!-- Styling parameters: class, innerClass, navClass, socialClass --}}\n{{#with this as |ghostcnStyles|}}\n{{!-- Component: Site Footer | Usage: {{> \"components/site-footer\"}} --}}\n<footer class=\"ghcn-footer{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\">\n <div class=\"ghcn-footer__inner{{#if ghostcnStyles.innerClass}} {{ghostcnStyles.innerClass}}{{/if}} ghcn-container\">\n <div class=\"ghcn-footer__brand\">\n <a href=\"{{@site.url}}\">{{@site.title}}</a>\n {{#if @site.description}}<p>{{@site.description}}</p>{{/if}}\n </div>\n <nav class=\"ghcn-footer__nav{{#if ghostcnStyles.navClass}} {{ghostcnStyles.navClass}}{{/if}}\" aria-label=\"Footer navigation\">{{navigation type=\"secondary\"}}</nav>\n <div class=\"ghcn-footer__social{{#if ghostcnStyles.socialClass}} {{ghostcnStyles.socialClass}}{{/if}}\">\n {{#if @site.facebook}}<a href=\"{{social_url type=\"facebook\"}}\" target=\"_blank\" rel=\"noopener\">Facebook</a>{{/if}}\n {{#if @site.twitter}}<a href=\"{{social_url type=\"twitter\"}}\" target=\"_blank\" rel=\"noopener\">X</a>{{/if}}\n <a href=\"{{#match @site.url \"/\"}}/rss/{{else}}{{@site.url}}/rss/{{/match}}\">RSS</a>\n </div>\n </div>\n <div class=\"ghcn-footer__legal ghcn-container\">\n <span>&copy; {{date format=\"YYYY\"}} {{@site.title}}</span>\n <span>Published with <a href=\"https://ghost.org\" target=\"_blank\" rel=\"noopener\">Ghost</a></span>\n </div>\n</footer>\n{{/with}}"
13
13
  },
14
14
  {
15
15
  "name": "site-footer.css",
16
16
  "type": "style",
17
17
  "target": "assets/css/components/site-footer.css",
18
- "content": "/* ghostcn: Site Footer */\n.ghcn-footer { box-sizing: border-box; border-top: 1px solid var(--border); color: var(--foreground); background: var(--card); font-family: inherit; font-size: 16px; line-height: 1.5; isolation: isolate; }\n.ghcn-footer *, .ghcn-footer *::before, .ghcn-footer *::after { box-sizing: border-box; }\n.ghcn-footer__inner { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) auto; gap: var(--ghcn-section-gap, 20px); padding-block: var(--ghcn-section-space, clamp(24px, 4vw, 48px)); }\n.ghcn-footer__brand a { color: var(--foreground); font-size: 1.125em; font-weight: 800; text-decoration: none; }\n.ghcn-footer__brand p { max-width: 30em; margin: 0.5em 0 0; color: var(--muted-foreground); font-size: 0.875em; }\n.ghcn-footer .nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0.5em 1.5em; margin: 0; padding: 0; list-style: none; }\n.ghcn-footer a { color: var(--muted-foreground); font-size: 0.875em; text-decoration: none; }\n.ghcn-footer a:hover { color: var(--foreground); }\n.ghcn-footer__social { display: flex; flex-direction: column; gap: 0.5em; }\n.ghcn-footer__legal { display: flex; justify-content: space-between; gap: 1em; border-top: 1px solid var(--border); padding-block: 1.25em; color: var(--muted-foreground); font-size: 0.75em; }\n@media (max-width: 720px) { .ghcn-footer__inner { grid-template-columns: 1fr; gap: 2em; } .ghcn-footer__social { flex-direction: row; flex-wrap: wrap; } }\n@media (max-width: 480px) { .ghcn-footer__legal { align-items: flex-start; flex-direction: column; } }\n"
18
+ "content": "/* ghostcn: Site Footer */\n.ghcn-footer { box-sizing: border-box; border-top: 1px solid var(--border); color: var(--foreground); background: var(--card); font-family: inherit; font-size: 16px; line-height: 1.5; isolation: isolate; }\n.ghcn-footer *, .ghcn-footer *::before, .ghcn-footer *::after { box-sizing: border-box; }\n.ghcn-footer__inner { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr) auto; gap: var(--ghcn-section-gap, 20px); padding-block: var(--ghcn-section-space, clamp(24px, 4vw, 48px)); }\n.ghcn-footer__brand a { color: var(--foreground); font-size: 18px; font-weight: 800; text-decoration: none; }\n.ghcn-footer__brand p { max-width: 480px; margin: 8px 0 0; color: var(--muted-foreground); font-size: 14px; }\n.ghcn-footer .nav { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 24px; margin: 0; padding: 0; list-style: none; }\n.ghcn-footer a { color: var(--muted-foreground); font-size: 14px; text-decoration: none; }\n.ghcn-footer a:hover { color: var(--foreground); }\n.ghcn-footer__social { display: flex; flex-direction: column; gap: 8px; }\n.ghcn-footer__legal { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); padding-block: 20px; color: var(--muted-foreground); font-size: 12px; }\n@media (max-width: 720px) { .ghcn-footer__inner { grid-template-columns: 1fr; gap: 32px; } .ghcn-footer__social { flex-direction: row; flex-wrap: wrap; } }\n@media (max-width: 480px) { .ghcn-footer__legal { align-items: flex-start; flex-direction: column; } }\n"
19
19
  }
20
20
  ],
21
21
  "gscan": {
@@ -15,7 +15,7 @@
15
15
  "name": "site-header.css",
16
16
  "type": "style",
17
17
  "target": "assets/css/components/site-header.css",
18
- "content": "/* ghostcn: Site Header */\n.ghcn-header { box-sizing: border-box; position: relative; z-index: 30; border-bottom: 1px solid var(--border); color: var(--foreground); background: color-mix(in srgb, var(--background) 92%, transparent); font-family: inherit; font-size: 16px; line-height: 1.5; isolation: isolate; }\n.ghcn-header *, .ghcn-header *::before, .ghcn-header *::after { box-sizing: border-box; }\n.ghcn-header__inner { display: flex; min-height: 64px; align-items: center; gap: var(--ghcn-grid-gap, 16px); }\n.ghcn-header__brand { display: inline-flex; flex: 0 0 auto; align-items: center; color: var(--foreground); font-size: 1.125em; font-weight: 800; letter-spacing: -0.025em; text-decoration: none; }\n.ghcn-header__brand img { display: block; width: auto; max-width: 11em; max-height: 2.25em; }\n.ghcn-header__nav { min-width: 0; flex: 1; }\n.ghcn-header .nav { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25em; margin: 0; padding: 0; list-style: none; }\n.ghcn-header .nav a, .ghcn-header__signin { color: var(--muted-foreground); font-size: 0.875em; font-weight: 600; text-decoration: none; }\n.ghcn-header .nav a:hover, .ghcn-header .nav-current a, .ghcn-header__signin:hover { color: var(--foreground); }\n.ghcn-header__actions { display: flex; align-items: center; gap: 0.75em; }\n.ghcn-header .gh-search-icon:focus-visible { border-radius: var(--radius); box-shadow: 0 0 0 2px var(--ring); }\n.ghcn-header__mobile { display: none; margin-left: auto; }\n.ghcn-header__mobile summary { list-style: none; }\n.ghcn-header__mobile summary::-webkit-details-marker { display: none; }\n.ghcn-header__panel { box-sizing: border-box; min-width: 0; overflow-wrap: anywhere; border: 1px solid var(--border, #e4e4e7); border-radius: var(--ghcn-panel-radius, min(var(--radius, 8px), 24px)); background: var(--card, #fff); color: var(--card-foreground, #09090b); position: absolute; top: calc(100% + 8px); right: 16px; left: 16px; padding: 16px; background: var(--popover); color: var(--popover-foreground); box-shadow: 0 8px 24px #0002; }\n.ghcn-header__panel .nav { align-items: stretch; flex-direction: column; gap: 0.25em; }\n.ghcn-header__panel .nav a { display: block; border-radius: var(--radius); padding: 0.625em 0.75em; }\n.ghcn-header__panel .nav a:hover { background: var(--muted); }\n.ghcn-header__mobile-actions { display: grid; grid-template-columns: auto 1fr 1fr; gap: 0.5em; margin-top: 1em; padding-top: 1em; border-top: 1px solid var(--border); }\n@media (max-width: 800px) { .ghcn-header__nav, .ghcn-header__actions { display: none; } .ghcn-header__mobile { display: block; } }\n"
18
+ "content": "/* ghostcn: Site Header */\n.ghcn-header { box-sizing: border-box; position: relative; z-index: 30; border-bottom: 1px solid var(--border); color: var(--foreground); background: color-mix(in srgb, var(--background) 92%, transparent); font-family: inherit; font-size: 16px; line-height: 1.5; isolation: isolate; }\n.ghcn-header *, .ghcn-header *::before, .ghcn-header *::after { box-sizing: border-box; }\n.ghcn-header__inner { display: flex; min-height: 64px; align-items: center; gap: var(--ghcn-grid-gap, 16px); }\n.ghcn-header__brand { display: inline-flex; flex: 0 0 auto; align-items: center; color: var(--foreground); font-size: 18px; font-weight: 800; letter-spacing: -0.025em; text-decoration: none; }\n.ghcn-header__brand img { display: block; width: auto; max-width: 176px; max-height: 36px; }\n.ghcn-header__nav { min-width: 0; flex: 1; }\n.ghcn-header .nav { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin: 0; padding: 0; list-style: none; }\n.ghcn-header .nav a, .ghcn-header__signin { color: var(--muted-foreground); font-size: 14px; font-weight: 600; text-decoration: none; }\n.ghcn-header .nav a:hover, .ghcn-header .nav-current a, .ghcn-header__signin:hover { color: var(--foreground); }\n.ghcn-header__actions { display: flex; align-items: center; gap: 12px; }\n.ghcn-header .gh-search-icon:focus-visible { border-radius: var(--radius); box-shadow: 0 0 0 2px var(--ring); }\n.ghcn-header__mobile { display: none; margin-left: auto; }\n.ghcn-header__mobile summary { list-style: none; }\n.ghcn-header__mobile summary::-webkit-details-marker { display: none; }\n.ghcn-header__panel { box-sizing: border-box; min-width: 0; overflow-wrap: anywhere; border: 1px solid var(--border, #e4e4e7); border-radius: var(--ghcn-panel-radius, min(var(--radius, 8px), 24px)); background: var(--card, #fff); color: var(--card-foreground, #09090b); position: absolute; top: calc(100% + 8px); right: 16px; left: 16px; padding: 16px; background: var(--popover); color: var(--popover-foreground); box-shadow: 0 8px 24px #0002; }\n.ghcn-header__panel .nav { align-items: stretch; flex-direction: column; gap: 4px; }\n.ghcn-header__panel .nav a { display: block; border-radius: var(--radius); padding: 10px 12px; }\n.ghcn-header__panel .nav a:hover { background: var(--muted); }\n.ghcn-header__mobile-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }\n.ghcn-header__mobile-actions .ghcn-button { flex: 1 1 auto; }\n@media (max-width: 800px) { .ghcn-header__nav, .ghcn-header__actions { display: none; } .ghcn-header__mobile { display: block; } }\n"
19
19
  }
20
20
  ],
21
21
  "gscan": {
@@ -4,12 +4,22 @@
4
4
  "description": "Progressively enhanced h2/h3 navigation with collision-safe anchors and keyboard focus.",
5
5
  "dependencies": [],
6
6
  "ghost_version": ">=5.0.0",
7
+ "parameters": {
8
+ "heading": {
9
+ "description": "Optional heading for the table of contents.",
10
+ "default": "On this page"
11
+ },
12
+ "contentSelector": {
13
+ "description": "CSS selector for the article container to scan.",
14
+ "default": ".ghcn-article-content"
15
+ }
16
+ },
7
17
  "files": [
8
18
  {
9
19
  "name": "table-of-contents.hbs",
10
20
  "type": "partial",
11
21
  "target": "partials/components/table-of-contents.hbs",
12
- "content": "{{!-- Styling parameters: class, titleClass, listClass --}}\n{{#with this as |ghostcnStyles|}}\n{{!-- add manages the deferred script in default.hbs. Set contentSelector for existing themes. --}}\n<nav class=\"ghcn-toc{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" data-ghcn-toc data-toc-content=\"{{#if contentSelector}}{{contentSelector}}{{else}}.ghcn-article-content{{/if}}\" data-link-class=\"{{linkClass}}\" aria-label=\"{{#if heading}}{{heading}}{{else}}On this page{{/if}}\" hidden>\n <h2 class=\"ghcn-toc__title{{#if ghostcnStyles.titleClass}} {{ghostcnStyles.titleClass}}{{/if}}\"><svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\"><path d=\"M5 5h11M5 10h8M5 15h5M2 5h.01M2 10h.01M2 15h.01\"/></svg>{{#if heading}}{{heading}}{{else}}On this page{{/if}}</h2>\n <ol class=\"ghcn-toc__list{{#if ghostcnStyles.listClass}} {{ghostcnStyles.listClass}}{{/if}}\" data-toc-list></ol>\n</nav>\n{{/with}}"
22
+ "content": "{{!-- Styling parameters: class, titleClass, listClass, linkClass --}}\n{{#with this as |ghostcnStyles|}}\n{{!-- add manages the deferred script in default.hbs. Set contentSelector for existing themes. --}}\n<nav class=\"ghcn-toc{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" data-ghcn-toc data-toc-content=\"{{#if contentSelector}}{{contentSelector}}{{else}}.ghcn-article-content{{/if}}\" data-link-class=\"{{linkClass}}\" aria-label=\"{{#if heading}}{{heading}}{{else}}On this page{{/if}}\" hidden>\n <h2 class=\"ghcn-toc__title{{#if ghostcnStyles.titleClass}} {{ghostcnStyles.titleClass}}{{/if}}\"><svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\"><path d=\"M5 5h11M5 10h8M5 15h5M2 5h.01M2 10h.01M2 15h.01\"/></svg>{{#if heading}}{{heading}}{{else}}On this page{{/if}}</h2>\n <ol class=\"ghcn-toc__list{{#if ghostcnStyles.listClass}} {{ghostcnStyles.listClass}}{{/if}}\" data-toc-list></ol>\n</nav>\n{{/with}}"
13
23
  },
14
24
  {
15
25
  "name": "table-of-contents.css",
@@ -21,7 +31,7 @@
21
31
  "name": "table-of-contents.js",
22
32
  "type": "js",
23
33
  "target": "assets/js/components/table-of-contents.js",
24
- "content": "/* ghostcn table of contents: no dependencies, no HTML injection, repeat-safe. */\n(() => {\n function setCurrent(group, index) {\n if (index === group.current) return;\n group.views.forEach(links => {\n links[group.current]?.removeAttribute('aria-current');\n links[index]?.setAttribute('aria-current', 'location');\n });\n group.current = index;\n }\n\n function currentFromScroll(group) {\n const { headings } = group;\n const offset = Math.max(0, parseFloat(getComputedStyle(headings[0]).scrollMarginBlockStart) || 0);\n const limit = Math.min(offset + 4, window.innerHeight / 2);\n let index = 0;\n for (let i = 0; i < headings.length; i++) {\n if (headings[i].getBoundingClientRect().top > limit) break;\n index = i;\n }\n // The final heading may never reach the activation line on a short section.\n const page = document.scrollingElement;\n if (page && page.scrollHeight > page.clientHeight + 2 &&\n page.scrollTop + page.clientHeight >= page.scrollHeight - 2 &&\n headings.at(-1).getBoundingClientRect().top < window.innerHeight) {\n index = headings.length - 1;\n }\n setCurrent(group, index);\n }\n\n const init = () => {\n const groups = new Map();\n const used = new Set([...document.querySelectorAll('[id]')].map(el => el.id));\n document.querySelectorAll('[data-ghcn-toc]').forEach(nav => {\n if (nav.dataset.ghcnTocReady) return;\n let content;\n try { content = document.querySelector(nav.dataset.tocContent); } catch { return; }\n if (!content) return;\n const list = nav.querySelector('[data-toc-list]');\n if (!list) return;\n let group = groups.get(content);\n if (!group) {\n // Editor card UI titles are not article sections.\n const headings = [...content.querySelectorAll('h2, h3')]\n .filter(h => h.textContent.trim() && !h.closest('.kg-card, [hidden], [data-ghcn-toc]'));\n if (headings.length < 2) return;\n headings.forEach((heading, index) => {\n if (!heading.id) {\n const base = 'ghcn-' + (heading.textContent.toLowerCase().normalize('NFKD').replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'section-' + (index + 1));\n let id = base, suffix = 2;\n while (used.has(id)) id = base + '-' + suffix++;\n heading.id = id; used.add(id);\n }\n heading.setAttribute('data-ghcn-toc-heading', '');\n });\n group = { headings, views: [], current: -1, jumpY: null };\n groups.set(content, group);\n }\n const links = group.headings.map((heading, index) => {\n const item = document.createElement('li');\n item.className = 'ghcn-toc__item' + (heading.tagName === 'H3' ? ' ghcn-toc__item--nested' : '');\n const link = document.createElement('a');\n link.className = 'ghcn-toc__link';\n if (nav.dataset.linkClass) nav.dataset.linkClass.split(/\\s+/).filter(Boolean).forEach(value => link.classList.add(value));\n link.href = '#' + encodeURIComponent(heading.id);\n link.textContent = heading.textContent.trim();\n link.addEventListener('click', event => {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n heading.scrollIntoView({ behavior: 'instant', block: 'start' });\n if (!heading.hasAttribute('tabindex')) {\n heading.setAttribute('tabindex', '-1');\n heading.addEventListener('blur', () => heading.removeAttribute('tabindex'), { once: true });\n }\n heading.focus({ preventScroll: true });\n try { history.replaceState(null, '', '#' + encodeURIComponent(heading.id)); } catch {}\n group.jumpY = window.scrollY;\n setCurrent(group, index);\n });\n item.append(link); list.append(item);\n return link;\n });\n group.views.push(links);\n nav.dataset.ghcnTocReady = 'true'; nav.hidden = false;\n });\n if (!groups.size) return;\n\n function syncHash() {\n let id = '';\n try { id = decodeURIComponent(location.hash.slice(1)); } catch {}\n groups.forEach(group => {\n const index = group.headings.findIndex(heading => heading.id === id);\n group.jumpY = index < 0 ? null : window.scrollY;\n if (index < 0) currentFromScroll(group);\n else setCurrent(group, index);\n });\n }\n\n let frame = 0;\n const schedule = () => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n groups.forEach(group => {\n if (group.jumpY !== null && Math.abs(group.jumpY - window.scrollY) < 2) return;\n group.jumpY = null;\n currentFromScroll(group);\n });\n });\n };\n syncHash();\n window.addEventListener('scroll', schedule, { passive: true });\n window.addEventListener('resize', schedule);\n window.addEventListener('load', schedule, { once: true });\n window.addEventListener('hashchange', syncHash);\n };\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init, { once: true }); else init();\n})();"
34
+ "content": "/* ghostcn table of contents: no dependencies, no HTML injection, repeat-safe. */\n(() => {\n function setCurrent(group, index) {\n if (index === group.current) return;\n group.views.forEach(links => {\n links[group.current]?.removeAttribute('aria-current');\n links[index]?.setAttribute('aria-current', 'location');\n });\n group.current = index;\n }\n\n function currentFromScroll(group) {\n const { headings } = group;\n const offset = Math.max(0, parseFloat(getComputedStyle(headings[0]).scrollMarginBlockStart) || 0);\n const limit = Math.min(offset + 4, window.innerHeight / 2);\n let index = 0;\n for (let i = 0; i < headings.length; i++) {\n if (headings[i].getBoundingClientRect().top > limit) break;\n index = i;\n }\n // The final heading may never reach the activation line on a short section.\n const page = document.scrollingElement;\n if (page && page.scrollHeight > page.clientHeight + 2 &&\n page.scrollTop + page.clientHeight >= page.scrollHeight - 2 &&\n headings.at(-1).getBoundingClientRect().top < window.innerHeight) {\n index = headings.length - 1;\n }\n setCurrent(group, index);\n }\n\n const init = () => {\n const groups = new Map();\n const used = new Set([...document.querySelectorAll('[id]')].map(el => el.id));\n document.querySelectorAll('[data-ghcn-toc]').forEach(nav => {\n if (nav.dataset.ghcnTocReady) return;\n let content;\n try { content = document.querySelector(nav.dataset.tocContent); } catch { return; }\n if (!content) return;\n const list = nav.querySelector('[data-toc-list]');\n if (!list) return;\n let group = groups.get(content);\n if (!group) {\n // Editor card UI titles are not article sections.\n const headings = [...content.querySelectorAll('h2, h3')]\n .filter(h => h.textContent.trim() && !h.closest('.kg-card, [hidden], [data-ghcn-toc]'));\n if (headings.length < 2) return;\n headings.forEach((heading, index) => {\n if (!heading.id) {\n const slug = heading.textContent.toLowerCase().normalize('NFKD').replace(/[̀-ͯ]/g, '').replace(/[^p{L}p{N}]+/gu, '-').replace(/^-|-$/g, '');\n const base = 'ghcn-' + (slug || 'section-' + (index + 1));\n let id = base, suffix = 2;\n while (used.has(id)) id = base + '-' + suffix++;\n heading.id = id; used.add(id);\n }\n heading.setAttribute('data-ghcn-toc-heading', '');\n });\n group = { headings, views: [], current: -1, jumpY: null };\n groups.set(content, group);\n }\n const links = group.headings.map((heading, index) => {\n const item = document.createElement('li');\n item.className = 'ghcn-toc__item' + (heading.tagName === 'H3' ? ' ghcn-toc__item--nested' : '');\n const link = document.createElement('a');\n link.className = 'ghcn-toc__link';\n if (nav.dataset.linkClass) nav.dataset.linkClass.split(/\\s+/).filter(Boolean).forEach(value => link.classList.add(value));\n link.href = '#' + encodeURIComponent(heading.id);\n link.textContent = heading.textContent.trim();\n link.addEventListener('click', event => {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n heading.scrollIntoView({ behavior: 'instant', block: 'start' });\n if (!heading.hasAttribute('tabindex')) {\n heading.setAttribute('tabindex', '-1');\n heading.addEventListener('blur', () => heading.removeAttribute('tabindex'), { once: true });\n }\n heading.focus({ preventScroll: true });\n try { history.replaceState(null, '', '#' + encodeURIComponent(heading.id)); } catch {}\n group.jumpY = window.scrollY;\n setCurrent(group, index);\n });\n item.append(link); list.append(item);\n return link;\n });\n group.views.push(links);\n nav.dataset.ghcnTocReady = 'true'; nav.hidden = false;\n });\n if (!groups.size) return;\n\n function syncHash() {\n let id = '';\n try { id = decodeURIComponent(location.hash.slice(1)); } catch {}\n groups.forEach(group => {\n const index = group.headings.findIndex(heading => heading.id === id);\n group.jumpY = index < 0 ? null : window.scrollY;\n if (index < 0) currentFromScroll(group);\n else setCurrent(group, index);\n });\n }\n\n let frame = 0;\n const schedule = () => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n groups.forEach(group => {\n if (group.jumpY !== null && Math.abs(group.jumpY - window.scrollY) < 2) return;\n group.jumpY = null;\n currentFromScroll(group);\n });\n });\n };\n syncHash();\n window.addEventListener('scroll', schedule, { passive: true });\n window.addEventListener('resize', schedule);\n window.addEventListener('load', schedule, { once: true });\n window.addEventListener('hashchange', syncHash);\n };\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init, { once: true }); else init();\n})();"
25
35
  }
26
36
  ],
27
37
  "gscan": {
@@ -29,7 +29,7 @@
29
29
  "name": "tag-grid.hbs",
30
30
  "type": "partial",
31
31
  "target": "partials/components/tag-grid.hbs",
32
- "content": "{{!-- Styling parameters: class, titleClass, gridClass --}}\n{{#with this as |ghostcnStyles|}}\n{{#get \"tags\" filter=\"visibility:public\" limit=\"100\" include=\"count.posts\"}}\n{{#if tags}}<section class=\"ghcn-tag-grid{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" aria-label=\"Topics\">\n {{#if ghostcnStyles.heading}}<h2 class=\"ghcn-tag-grid__title{{#if ghostcnStyles.titleClass}} {{ghostcnStyles.titleClass}}{{/if}}\">{{ghostcnStyles.heading}}</h2>{{/if}}\n <div class=\"ghcn-tag-grid__grid{{#if ghostcnStyles.gridClass}} {{ghostcnStyles.gridClass}}{{/if}}\">{{#foreach tags visibility=\"public\"}}\n {{#> \"components/card\" heading=name description=description class=ghostcnStyles.cardClass titleClass=ghostcnStyles.cardTitleClass descriptionClass=ghostcnStyles.descriptionClass variant=ghostcnStyles.cardVariant}}\n {{> \"components/button\" href=url text=\"Explore topic\" variant=\"outline\" size=\"sm\" class=ghostcnStyles.buttonClass}}\n {{/components/card}}\n {{/foreach}}</div>\n</section>{{else}}{{#if ghostcnStyles.emptyText}}<section class=\"ghcn-tag-grid{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\"><p class=\"ghcn-tag-grid__empty\">{{ghostcnStyles.emptyText}}</p></section>{{/if}}{{/if}}\n{{/get}}\n{{/with}}"
32
+ "content": "{{!-- Styling parameters: class, titleClass, gridClass, cardClass, cardTitleClass, descriptionClass, buttonClass --}}\n{{#with this as |ghostcnStyles|}}\n{{#get \"tags\" filter=\"visibility:public\" limit=\"100\" include=\"count.posts\"}}\n{{#if tags}}<section class=\"ghcn-tag-grid{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" aria-label=\"Topics\">\n {{#if ghostcnStyles.heading}}<h2 class=\"ghcn-tag-grid__title{{#if ghostcnStyles.titleClass}} {{ghostcnStyles.titleClass}}{{/if}}\">{{ghostcnStyles.heading}}</h2>{{/if}}\n <div class=\"ghcn-tag-grid__grid{{#if ghostcnStyles.gridClass}} {{ghostcnStyles.gridClass}}{{/if}}\">{{#foreach tags visibility=\"public\"}}\n {{#> \"components/card\" heading=name description=description class=ghostcnStyles.cardClass titleClass=ghostcnStyles.cardTitleClass descriptionClass=ghostcnStyles.descriptionClass variant=ghostcnStyles.cardVariant}}\n {{> \"components/button\" href=url text=\"Explore topic\" ariaLabel=name variant=\"outline\" size=\"sm\" class=ghostcnStyles.buttonClass}}\n {{/components/card}}\n {{/foreach}}</div>\n</section>{{else}}{{#if ghostcnStyles.emptyText}}<section class=\"ghcn-tag-grid{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\"><p class=\"ghcn-tag-grid__empty\">{{ghostcnStyles.emptyText}}</p></section>{{/if}}{{/if}}\n{{/get}}\n{{/with}}"
33
33
  },
34
34
  {
35
35
  "name": "tag-grid.css",
@@ -15,7 +15,7 @@
15
15
  "name": "tag-list.css",
16
16
  "type": "style",
17
17
  "target": "assets/css/components/tag-list.css",
18
- "content": "\n.ghcn-tag-list { box-sizing: border-box; min-width: 0; margin-block: var(--ghcn-section-space, clamp(24px, 4vw, 48px)); font-family: inherit; font-size: var(--ghcn-text-body, 16px); line-height: 1.5; color: var(--foreground); }\n.ghcn-tag-list__items { display: flex; flex-wrap: wrap; gap: .5em; list-style: none; padding: 0; margin: 0; }\n.ghcn-tag-list__link { display: block; padding: 5px 10px; background: var(--secondary); color: var(--secondary-foreground); border: 1px solid var(--border); border-radius: 999px; font-size: var(--ghcn-text-meta, 13px); font-weight: 600; text-decoration: none; }\n.ghcn-tag-list__link:hover { background: var(--secondary); text-decoration: underline; }\n.ghcn-tag-list__link:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }\n"
18
+ "content": "\n.ghcn-tag-list { box-sizing: border-box; min-width: 0; margin-block: var(--ghcn-section-space, clamp(24px, 4vw, 48px)); font-family: inherit; font-size: var(--ghcn-text-body, 16px); line-height: 1.5; color: var(--foreground); }\n.ghcn-tag-list__items { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }\n.ghcn-tag-list__link { display: block; padding: 5px 10px; background: var(--secondary); color: var(--secondary-foreground); border: 1px solid var(--border); border-radius: 999px; font-size: var(--ghcn-text-meta, 13px); font-weight: 600; text-decoration: none; }\n.ghcn-tag-list__link:hover { background: var(--secondary); text-decoration: underline; }\n.ghcn-tag-list__link:focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }\n"
19
19
  }
20
20
  ],
21
21
  "gscan": {
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "theme-toggle",
3
+ "type": "components:layout",
4
+ "description": "Light, dark, and system theme switcher syncing .dark-mode and .auto-color with localStorage persistence.",
5
+ "dependencies": [],
6
+ "ghost_version": ">=5.0.0",
7
+ "parameters": {
8
+ "variant": {
9
+ "description": "Visual treatment; segmented 3-way pill, compact icon, or outline button.",
10
+ "options": [
11
+ "default",
12
+ "compact",
13
+ "outline"
14
+ ],
15
+ "default": "default"
16
+ },
17
+ "size": {
18
+ "description": "Control scale.",
19
+ "options": [
20
+ "sm",
21
+ "default",
22
+ "lg"
23
+ ],
24
+ "default": "default"
25
+ },
26
+ "ariaLabel": {
27
+ "description": "Accessible label for the theme toggle group.",
28
+ "default": "Color theme"
29
+ }
30
+ },
31
+ "files": [
32
+ {
33
+ "name": "theme-toggle.hbs",
34
+ "type": "partial",
35
+ "target": "partials/components/theme-toggle.hbs",
36
+ "content": "{{!-- Styling parameters: class, buttonClass --}}\n{{#with this as |ghostcnStyles|}}\n<div class=\"ghcn-theme-toggle{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" data-ghcn-theme-toggle data-variant=\"{{#match variant \"compact\"}}compact{{else}}{{#match variant \"outline\"}}outline{{else}}default{{/match}}{{/match}}\" data-size=\"{{#match size \"sm\"}}sm{{else}}{{#match size \"lg\"}}lg{{else}}default{{/match}}{{/match}}\" role=\"group\" aria-label=\"{{#if ariaLabel}}{{ariaLabel}}{{else}}Color theme{{/if}}\">\n {{#match variant \"compact\"}}\n <button type=\"button\" class=\"ghcn-theme-toggle__btn{{#if ghostcnStyles.buttonClass}} {{ghostcnStyles.buttonClass}}{{/if}} ghcn-theme-toggle__btn--cycle\" data-theme-cycle aria-label=\"Toggle color theme\"><svg class=\"ghcn-theme-toggle__sun\" aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"10\" cy=\"10\" r=\"3.5\"/><path d=\"M10 2.5v1.5M10 16v1.5M4.7 4.7l1.1 1.1M14.2 14.2l1.1 1.1M2.5 10H4M16 10h1.5M4.7 15.3l1.1-1.1M14.2 5.8l1.1-1.1\"/></svg><svg class=\"ghcn-theme-toggle__moon\" aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16.5 12.2A6.5 6.5 0 0 1 7.8 3.5a6.5 6.5 0 1 0 8.7 8.7Z\"/></svg></button>\n {{else}}{{#match variant \"outline\"}}\n <button type=\"button\" class=\"ghcn-theme-toggle__btn{{#if ghostcnStyles.buttonClass}} {{ghostcnStyles.buttonClass}}{{/if}} ghcn-theme-toggle__btn--cycle\" data-theme-cycle aria-label=\"Toggle color theme\"><svg class=\"ghcn-theme-toggle__sun\" aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"10\" cy=\"10\" r=\"3.5\"/><path d=\"M10 2.5v1.5M10 16v1.5M4.7 4.7l1.1 1.1M14.2 14.2l1.1 1.1M2.5 10H4M16 10h1.5M4.7 15.3l1.1-1.1M14.2 5.8l1.1-1.1\"/></svg><svg class=\"ghcn-theme-toggle__moon\" aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16.5 12.2A6.5 6.5 0 0 1 7.8 3.5a6.5 6.5 0 1 0 8.7 8.7Z\"/></svg><span data-theme-label>Theme</span></button>\n {{else}}\n <button type=\"button\" class=\"ghcn-theme-toggle__btn{{#if ghostcnStyles.buttonClass}} {{ghostcnStyles.buttonClass}}{{/if}}\" data-theme-value=\"light\" aria-label=\"Light theme\" aria-pressed=\"false\"><svg class=\"ghcn-theme-toggle__sun\" aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"10\" cy=\"10\" r=\"3.5\"/><path d=\"M10 2.5v1.5M10 16v1.5M4.7 4.7l1.1 1.1M14.2 14.2l1.1 1.1M2.5 10H4M16 10h1.5M4.7 15.3l1.1-1.1M14.2 5.8l1.1-1.1\"/></svg></button>\n <button type=\"button\" class=\"ghcn-theme-toggle__btn{{#if ghostcnStyles.buttonClass}} {{ghostcnStyles.buttonClass}}{{/if}}\" data-theme-value=\"system\" aria-label=\"System theme\" aria-pressed=\"false\"><svg class=\"ghcn-theme-toggle__system\" aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2.5\" y=\"3.5\" width=\"15\" height=\"10\" rx=\"1.5\"/><path d=\"M7 16.5h6M10 13.5v3\"/></svg></button>\n <button type=\"button\" class=\"ghcn-theme-toggle__btn{{#if ghostcnStyles.buttonClass}} {{ghostcnStyles.buttonClass}}{{/if}}\" data-theme-value=\"dark\" aria-label=\"Dark theme\" aria-pressed=\"false\"><svg class=\"ghcn-theme-toggle__moon\" aria-hidden=\"true\" viewBox=\"0 0 20 20\" width=\"16\" height=\"16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M16.5 12.2A6.5 6.5 0 0 1 7.8 3.5a6.5 6.5 0 1 0 8.7 8.7Z\"/></svg></button>\n {{/match}}{{/match}}\n</div>\n{{/with}}"
37
+ },
38
+ {
39
+ "name": "theme-toggle.css",
40
+ "type": "style",
41
+ "target": "assets/css/components/theme-toggle.css",
42
+ "content": ".ghcn-theme-toggle { box-sizing: border-box; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 9999px; background: var(--secondary); color: var(--foreground); font-family: inherit; font-size: var(--ghcn-text-small, 14px); line-height: 1; }\n.ghcn-theme-toggle *, .ghcn-theme-toggle *::before, .ghcn-theme-toggle *::after { box-sizing: border-box; }\n.ghcn-theme-toggle:where([data-variant=\"compact\"]), .ghcn-theme-toggle:where([data-variant=\"outline\"]) { padding: 0; background: transparent; border-color: transparent; }\n.ghcn-theme-toggle__btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 9999px; background: transparent; color: var(--muted-foreground); font: inherit; font-weight: 600; cursor: pointer; transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease; }\n.ghcn-theme-toggle:where([data-size=\"sm\"]) .ghcn-theme-toggle__btn { min-width: 28px; height: 28px; padding: 0 6px; font-size: 12px; }\n.ghcn-theme-toggle:where([data-size=\"lg\"]) .ghcn-theme-toggle__btn { min-width: 38px; height: 38px; padding: 0 12px; font-size: 15px; }\n.ghcn-theme-toggle__btn:hover { color: var(--foreground); }\n.ghcn-theme-toggle__btn[aria-pressed=\"true\"] { background: var(--background); color: var(--foreground); border-color: var(--border); box-shadow: 0 1px 2px #0001; }\n.ghcn-theme-toggle:where([data-variant=\"compact\"]) .ghcn-theme-toggle__btn--cycle,\n.ghcn-theme-toggle:where([data-variant=\"outline\"]) .ghcn-theme-toggle__btn--cycle { border-color: var(--border); background: var(--card); color: var(--foreground); border-radius: var(--ghcn-control-radius, var(--radius, 8px)); padding: 0 10px; }\n.ghcn-theme-toggle:where([data-variant=\"compact\"]) .ghcn-theme-toggle__btn--cycle { padding: 0; }\n.ghcn-theme-toggle:where([data-variant=\"compact\"]) .ghcn-theme-toggle__btn--cycle:hover,\n.ghcn-theme-toggle:where([data-variant=\"outline\"]) .ghcn-theme-toggle__btn--cycle:hover { background: var(--muted); }\n.ghcn-theme-toggle__btn--cycle .ghcn-theme-toggle__moon { display: none; }\n.ghcn-theme-toggle[data-resolved=\"dark\"] .ghcn-theme-toggle__btn--cycle .ghcn-theme-toggle__sun { display: none; }\n.ghcn-theme-toggle[data-resolved=\"dark\"] .ghcn-theme-toggle__btn--cycle .ghcn-theme-toggle__moon { display: block; }\n.ghcn-theme-toggle:focus-visible, :where(.ghcn-theme-toggle) :focus-visible { outline: 2px solid var(--ring, currentColor); outline-offset: 2px; }\n@media (prefers-reduced-motion: reduce) { .ghcn-theme-toggle__btn { transition: none; } }\n"
43
+ },
44
+ {
45
+ "name": "theme-toggle.js",
46
+ "type": "js",
47
+ "target": "assets/js/components/theme-toggle.js",
48
+ "content": "/* ghostcn theme toggle: persists light/dark/system preference, repeat-safe, no dependencies. */\n(() => {\n const KEY = 'ghcn-theme';\n const root = document.documentElement;\n const media = window.matchMedia('(prefers-color-scheme: dark)');\n\n function readPreference() {\n try {\n const saved = localStorage.getItem(KEY);\n if (saved === 'light' || saved === 'dark' || saved === 'system') return saved;\n } catch {}\n if (root.classList.contains('dark-mode') || root.classList.contains('dark')) return 'dark';\n if (root.classList.contains('auto-color')) return 'system';\n return 'light';\n }\n\n function applyTheme(mode, persist) {\n const resolved = mode === 'system' ? (media.matches ? 'dark' : 'light') : mode;\n root.classList.toggle('auto-color', mode === 'system');\n root.classList.toggle('dark-mode', resolved === 'dark');\n root.classList.toggle('dark', resolved === 'dark');\n root.setAttribute('data-theme', resolved);\n if (persist) {\n try { localStorage.setItem(KEY, mode); } catch {}\n }\n document.querySelectorAll('[data-ghcn-theme-toggle]').forEach(container => {\n container.dataset.mode = mode;\n container.dataset.resolved = resolved;\n container.querySelectorAll('[data-theme-value]').forEach(btn => {\n btn.setAttribute('aria-pressed', String(btn.dataset.themeValue === mode));\n });\n const cycle = container.querySelector('[data-theme-cycle]');\n if (cycle) {\n const next = resolved === 'dark' ? 'light' : 'dark';\n cycle.setAttribute('aria-label', 'Switch to ' + next + ' theme');\n const label = cycle.querySelector('[data-theme-label]');\n if (label) label.textContent = resolved === 'dark' ? 'Dark' : 'Light';\n }\n });\n }\n\n function init() {\n const mode = readPreference();\n applyTheme(mode, false);\n document.querySelectorAll('[data-ghcn-theme-toggle]').forEach(container => {\n if (container.dataset.ghcnThemeReady) return;\n container.dataset.ghcnThemeReady = 'true';\n container.querySelectorAll('[data-theme-value]').forEach(btn => {\n btn.addEventListener('click', () => applyTheme(btn.dataset.themeValue, true));\n });\n const cycle = container.querySelector('[data-theme-cycle]');\n if (cycle) {\n cycle.addEventListener('click', () => {\n const isDark = root.classList.contains('dark-mode') || root.classList.contains('dark');\n applyTheme(isDark ? 'light' : 'dark', true);\n });\n }\n });\n media.addEventListener?.('change', () => {\n if (readPreference() === 'system') applyTheme('system', false);\n });\n }\n\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', init, { once: true });\n else init();\n})();"
49
+ }
50
+ ],
51
+ "gscan": {
52
+ "rules_satisfied": [
53
+ "GS010-PJ-VALID"
54
+ ],
55
+ "notes": "Syncs html.dark-mode and html.auto-color with localStorage; zero external dependencies."
56
+ },
57
+ "styleSlots": {
58
+ "class": [
59
+ ".ghcn-theme-toggle"
60
+ ],
61
+ "buttonClass": [
62
+ ".ghcn-theme-toggle__btn"
63
+ ]
64
+ }
65
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "visibility-badge",
3
+ "type": "components:members",
4
+ "description": "Ghost-native access indicator pill for members-only, paid-only, tier-restricted, or public posts.",
5
+ "dependencies": [],
6
+ "ghost_version": ">=5.0.0",
7
+ "parameters": {
8
+ "variant": {
9
+ "description": "Visual treatment.",
10
+ "options": [
11
+ "default",
12
+ "outline",
13
+ "subtle"
14
+ ],
15
+ "default": "default"
16
+ },
17
+ "size": {
18
+ "description": "Badge scale.",
19
+ "options": [
20
+ "sm",
21
+ "default",
22
+ "lg"
23
+ ],
24
+ "default": "default"
25
+ },
26
+ "showPublic": {
27
+ "description": "Boolean. Render a Public badge for public posts (hidden by default)."
28
+ },
29
+ "membersLabel": {
30
+ "description": "Custom label for members-only posts.",
31
+ "default": "Members only"
32
+ },
33
+ "paidLabel": {
34
+ "description": "Custom label for paid-only posts.",
35
+ "default": "Paid only"
36
+ },
37
+ "tiersLabel": {
38
+ "description": "Custom label for specific-tier posts.",
39
+ "default": "Specific tiers"
40
+ },
41
+ "publicLabel": {
42
+ "description": "Custom label for public posts when showPublic=true.",
43
+ "default": "Public"
44
+ }
45
+ },
46
+ "files": [
47
+ {
48
+ "name": "visibility-badge.hbs",
49
+ "type": "partial",
50
+ "target": "partials/components/visibility-badge.hbs",
51
+ "content": "{{!-- Styling parameters: class --}}\n{{#with this as |ghostcnStyles|}}\n{{#match visibility \"members\"}}\n<span class=\"ghcn-visibility-badge{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" data-visibility=\"members\" data-variant=\"{{#match variant \"outline\"}}outline{{else}}{{#match variant \"subtle\"}}subtle{{else}}default{{/match}}{{/match}}\" data-size=\"{{#match size \"sm\"}}sm{{else}}{{#match size \"lg\"}}lg{{else}}default{{/match}}{{/match}}\"><svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"7\" width=\"10\" height=\"7\" rx=\"1.5\"/><path d=\"M5.5 7V5a2.5 2.5 0 0 1 5 0v2\"/></svg><span>{{#if membersLabel}}{{membersLabel}}{{else}}Members only{{/if}}</span></span>\n{{else}}{{#match visibility \"paid\"}}\n<span class=\"ghcn-visibility-badge{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" data-visibility=\"paid\" data-variant=\"{{#match variant \"outline\"}}outline{{else}}{{#match variant \"subtle\"}}subtle{{else}}default{{/match}}{{/match}}\" data-size=\"{{#match size \"sm\"}}sm{{else}}{{#match size \"lg\"}}lg{{else}}default{{/match}}{{/match}}\"><svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"m8 2.2 1.8 3.6 4 .6-2.9 2.8.7 4L8 11.3l-3.6 1.9.7-4-2.9-2.8 4-.6L8 2.2Z\"/></svg><span>{{#if paidLabel}}{{paidLabel}}{{else}}Paid only{{/if}}</span></span>\n{{else}}{{#match visibility \"tiers\"}}\n<span class=\"ghcn-visibility-badge{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" data-visibility=\"tiers\" data-variant=\"{{#match variant \"outline\"}}outline{{else}}{{#match variant \"subtle\"}}subtle{{else}}default{{/match}}{{/match}}\" data-size=\"{{#match size \"sm\"}}sm{{else}}{{#match size \"lg\"}}lg{{else}}default{{/match}}{{/match}}\"><svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"m8 2.2 1.8 3.6 4 .6-2.9 2.8.7 4L8 11.3l-3.6 1.9.7-4-2.9-2.8 4-.6L8 2.2Z\"/></svg><span>{{#if tiersLabel}}{{tiersLabel}}{{else}}Specific tiers{{/if}}</span></span>\n{{else}}{{#if showPublic}}\n<span class=\"ghcn-visibility-badge{{#if ghostcnStyles.class}} {{ghostcnStyles.class}}{{/if}}\" data-visibility=\"public\" data-variant=\"{{#match variant \"outline\"}}outline{{else}}{{#match variant \"subtle\"}}subtle{{else}}default{{/match}}{{/match}}\" data-size=\"{{#match size \"sm\"}}sm{{else}}{{#match size \"lg\"}}lg{{else}}default{{/match}}{{/match}}\"><svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" width=\"12\" height=\"12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"8\" cy=\"8\" r=\"5.5\"/><path d=\"M2.5 8h11M8 2.5a8.5 8.5 0 0 1 0 11 8.5 8.5 0 0 1 0-11Z\"/></svg><span>{{#if publicLabel}}{{publicLabel}}{{else}}Public{{/if}}</span></span>\n{{/if}}{{/match}}{{/match}}{{/match}}\n{{/with}}"
52
+ },
53
+ {
54
+ "name": "visibility-badge.css",
55
+ "type": "style",
56
+ "target": "assets/css/components/visibility-badge.css",
57
+ "content": ".ghcn-visibility-badge { box-sizing: border-box; display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 9999px; background: var(--secondary); color: var(--secondary-foreground); font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1.25; white-space: nowrap; }\n.ghcn-visibility-badge:where([data-visibility=\"paid\"]),\n.ghcn-visibility-badge:where([data-visibility=\"tiers\"]) { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }\n.ghcn-visibility-badge:where([data-size=\"sm\"]) { font-size: 11px; padding: 2px 7px; gap: 4px; }\n.ghcn-visibility-badge:where([data-size=\"lg\"]) { font-size: 14px; padding: 4px 11px; gap: 6px; }\n.ghcn-visibility-badge:where([data-variant=\"outline\"]) { background: transparent; color: var(--foreground); border-color: var(--border); }\n.ghcn-visibility-badge:where([data-variant=\"outline\"][data-visibility=\"paid\"]),\n.ghcn-visibility-badge:where([data-variant=\"outline\"][data-visibility=\"tiers\"]) { border-color: var(--primary); color: var(--primary); }\n.ghcn-visibility-badge:where([data-variant=\"subtle\"]) { background: transparent; border-color: transparent; padding-inline: 2px; color: var(--muted-foreground); }\n.ghcn-visibility-badge:where([data-variant=\"subtle\"][data-visibility=\"paid\"]),\n.ghcn-visibility-badge:where([data-variant=\"subtle\"][data-visibility=\"tiers\"]) { color: var(--foreground); }\n"
58
+ }
59
+ ],
60
+ "gscan": {
61
+ "rules_satisfied": [
62
+ "GS010-PJ-VALID"
63
+ ],
64
+ "notes": "Uses native Ghost post {{visibility}} property (public, members, paid, tiers)."
65
+ },
66
+ "styleSlots": {
67
+ "class": [
68
+ ".ghcn-visibility-badge"
69
+ ]
70
+ }
71
+ }
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "name": "newsletter-form",
4
4
  "description": "A native Ghost members subscription form with state handling.",
5
- "category": "components:ui",
5
+ "category": "components:members",
6
6
  "ghost_version": ">=5.0.0",
7
7
  "files": [
8
8
  "newsletter-form.hbs",
@@ -11,12 +11,13 @@
11
11
  },
12
12
  {
13
13
  "name": "pricing-table",
14
- "description": "Membership tiers and pricing plans with native Ghost Portal checkout triggers.",
15
- "category": "components:ui",
14
+ "description": "Live Ghost tiers, prices, currencies, benefits, and progressive monthly/yearly toggle with Portal checkout.",
15
+ "category": "components:members",
16
16
  "ghost_version": ">=5.0.0",
17
17
  "files": [
18
18
  "pricing-table.hbs",
19
- "pricing-table.css"
19
+ "pricing-table.css",
20
+ "pricing-table.js"
20
21
  ]
21
22
  },
22
23
  {
@@ -190,6 +191,26 @@
190
191
  "alert.css"
191
192
  ]
192
193
  },
194
+ {
195
+ "name": "avatar",
196
+ "description": "A reusable author or user avatar with image and initials fallback.",
197
+ "category": "components:ui",
198
+ "ghost_version": ">=5.0.0",
199
+ "files": [
200
+ "avatar.hbs",
201
+ "avatar.css"
202
+ ]
203
+ },
204
+ {
205
+ "name": "accordion",
206
+ "description": "Zero-JS collapsible disclosure built on native details and summary elements.",
207
+ "category": "components:ui",
208
+ "ghost_version": ">=5.0.0",
209
+ "files": [
210
+ "accordion.hbs",
211
+ "accordion.css"
212
+ ]
213
+ },
193
214
  {
194
215
  "name": "post-grid",
195
216
  "description": "A responsive grid using post-card; pass posts from a loop, archive or get query.",
@@ -229,5 +250,69 @@
229
250
  "archive-header.hbs",
230
251
  "archive-header.css"
231
252
  ]
253
+ },
254
+ {
255
+ "name": "theme-toggle",
256
+ "description": "Light, dark, and system theme switcher syncing .dark-mode and .auto-color with localStorage persistence.",
257
+ "category": "components:layout",
258
+ "ghost_version": ">=5.0.0",
259
+ "files": [
260
+ "theme-toggle.hbs",
261
+ "theme-toggle.css",
262
+ "theme-toggle.js"
263
+ ]
264
+ },
265
+ {
266
+ "name": "announcement-bar",
267
+ "description": "Dismissible top publication announcement bar with optional link and session persistence.",
268
+ "category": "components:layout",
269
+ "ghost_version": ">=5.0.0",
270
+ "files": [
271
+ "announcement-bar.hbs",
272
+ "announcement-bar.css",
273
+ "announcement-bar.js"
274
+ ]
275
+ },
276
+ {
277
+ "name": "reading-progress",
278
+ "description": "Thin scroll-linked reading progress bar tracking article scroll depth.",
279
+ "category": "components:content",
280
+ "ghost_version": ">=5.0.0",
281
+ "files": [
282
+ "reading-progress.hbs",
283
+ "reading-progress.css",
284
+ "reading-progress.js"
285
+ ]
286
+ },
287
+ {
288
+ "name": "share-buttons",
289
+ "description": "Accessible article share links (Copy link, Bluesky, X, LinkedIn, Email, and native Web Share).",
290
+ "category": "components:content",
291
+ "ghost_version": ">=5.0.0",
292
+ "files": [
293
+ "share-buttons.hbs",
294
+ "share-buttons.css",
295
+ "share-buttons.js"
296
+ ]
297
+ },
298
+ {
299
+ "name": "breadcrumbs",
300
+ "description": "Accessible breadcrumb navigation with Schema.org BreadcrumbList microdata for posts, tags, and authors.",
301
+ "category": "components:content",
302
+ "ghost_version": ">=5.0.0",
303
+ "files": [
304
+ "breadcrumbs.hbs",
305
+ "breadcrumbs.css"
306
+ ]
307
+ },
308
+ {
309
+ "name": "visibility-badge",
310
+ "description": "Ghost-native access indicator pill for members-only, paid-only, tier-restricted, or public posts.",
311
+ "category": "components:members",
312
+ "ghost_version": ">=5.0.0",
313
+ "files": [
314
+ "visibility-badge.hbs",
315
+ "visibility-badge.css"
316
+ ]
232
317
  }
233
318
  ]
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
2
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Ghostcn playground</title><link rel="stylesheet" href="/playground.css"><script defer src="/playground.js"></script></head>
3
3
  <body><header><p class="eyebrow">LOCAL COMPONENT PLAYGROUND</p><h1>Build it your way.</h1><p>Installed theme files. Synthetic content. No emails, payments or Ghost settings changes.</p></header>
4
- <main><aside aria-label="Preview controls"><label>Component<select id="component"></select></label><p id="description"></p><label>Theme<select id="scheme"><option value="light">Light</option><option value="dark">Dark</option><option value="auto">Auto</option></select></label><label>Member state<select id="state"><option value="visitor">Visitor</option><option value="free">Free member</option><option value="paid">Paid member</option><option value="disabled">Membership disabled</option><option value="invite">Invite only</option><option value="restricted">Self-signup restricted</option></select></label><div id="parameters"></div><button id="reload" type="button">Reload preview</button><p id="status" role="status"></p></aside>
5
- <section aria-label="Component preview"><iframe id="preview" title="Installed component preview" sandbox="allow-scripts"></iframe><h2>Use in your template</h2><pre><code id="usage"></code></pre><p>Classes only preview if your CSS defines them. For Tailwind, put utilities in a scanned .hbs file and keep <code>npm run dev</code> running. Verify real data, editor cards and member behavior in Ghost.</p><p>Preview changes are temporary. Copy the usage into your theme to keep them.</p></section></main></body></html>
4
+ <main><aside aria-label="Preview controls"><label>Component<select id="component"></select></label><p id="description"></p><label>Theme<select id="scheme"><option value="light">Light</option><option value="dark">Dark</option><option value="auto">Auto</option></select></label><label>Viewport<select id="viewport"><option value="full">Full width</option><option value="desktop">Desktop (1024px)</option><option value="tablet">Tablet (768px)</option><option value="mobile">Mobile (375px)</option></select></label><label>Member state<select id="state"><option value="visitor">Visitor</option><option value="free">Free member</option><option value="paid">Paid member</option><option value="free-only">Free-only site</option><option value="disabled">Membership disabled</option><option value="invite">Invite only</option><option value="restricted">Self-signup restricted</option></select></label><label>Post access<select id="access"><option value="true">Public / accessible</option><option value="false">Protected (paywall)</option></select></label><div id="parameters"></div><button id="reload" type="button">Reload preview</button><p id="status" role="status"></p></aside>
5
+ <section aria-label="Component preview"><div id="frame-stage" data-viewport="full"><iframe id="preview" title="Installed component preview" sandbox="allow-scripts"></iframe></div><div class="usage-header"><h2>Use in your template</h2><button id="copy-usage" type="button" class="copy-button">Copy snippet</button></div><pre><code id="usage"></code></pre><p>Classes only preview if your CSS defines them. For Tailwind, put utilities in a scanned .hbs file and keep <code>npm run dev</code> running. Verify real data, editor cards and member behavior in Ghost.</p><p>Preview changes are temporary. Copy the usage into your theme to keep them.</p></section></main></body></html>
@@ -13,6 +13,13 @@ input, select, button { font: inherit; width: 100%; min-width: 0; padding: 10px;
13
13
  button { cursor: pointer; }
14
14
  input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid #bca1f8; outline-offset: 3px; }
15
15
  label small, #description { color: #a0bdcf; }
16
- iframe { width: 100%; height: 650px; border: 1px solid #516475; border-radius: 8px; background: #fff; }
16
+ #frame-stage { display: flex; justify-content: center; }
17
+ #frame-stage[data-viewport="desktop"] iframe { max-width: 1024px; }
18
+ #frame-stage[data-viewport="tablet"] iframe { max-width: 768px; }
19
+ #frame-stage[data-viewport="mobile"] iframe { max-width: 375px; }
20
+ .usage-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
21
+ .usage-header h2 { margin: 0; }
22
+ .copy-button { width: auto; padding: 6px 14px; font-size: 13px; }
23
+ iframe { width: 100%; height: 650px; border: 1px solid #516475; border-radius: 8px; background: #fff; transition: max-width 200ms ease; }
17
24
  pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #1d2731; padding: 20px; border-radius: 8px; }
18
25
  @media(max-width:760px) { main { grid-template-columns: 1fr; } aside { border-right: 0; border-bottom: 1px solid #34414e; } header, aside, section { padding: 20px; } }
@@ -1,21 +1,39 @@
1
1
  const component = document.querySelector('#component');
2
2
  const parameters = document.querySelector('#parameters');
3
3
  const status = document.querySelector('#status');
4
+ const viewport = document.querySelector('#viewport');
5
+ const frameStage = document.querySelector('#frame-stage');
6
+ const copyUsage = document.querySelector('#copy-usage');
4
7
  const controls = new Map();
5
- let catalog = [], revision, busy = false;
8
+ const booleanParams = new Set(['disabled', 'required', 'invalid', 'urgent', 'decorative', 'open', 'hideDismiss', 'showPublic']);
9
+ let catalog = [], revision, busy = false, debounceTimer;
6
10
  const current = () => catalog.find(item => item.name === component.value);
7
11
  function render() {
8
12
  const item = current();
9
13
  if (!item) return;
10
- const query = new URLSearchParams({ scheme: document.querySelector('#scheme').value, state: document.querySelector('#state').value });
14
+ const query = new URLSearchParams({
15
+ scheme: document.querySelector('#scheme').value,
16
+ state: document.querySelector('#state').value,
17
+ access: document.querySelector('#access')?.value || 'true'
18
+ });
11
19
  const args = [];
12
20
  for (const [name, input] of controls) {
13
21
  query.set(name, input.value);
14
- if (input.value) args.push(`${name}=${['disabled','required','invalid','urgent'].includes(name) ? input.value : JSON.stringify(input.value)}`);
22
+ if (booleanParams.has(name)) {
23
+ if (input.value === 'true') args.push(`${name}=true`);
24
+ } else if (input.value) {
25
+ args.push(`${name}=${JSON.stringify(input.value)}`);
26
+ }
15
27
  }
16
28
  document.querySelector('#preview').src = `/preview/${item.name}?${query}`;
17
29
  const context = item.name === 'author-card' ? ' primary_author' : item.name === 'pagination' ? ' pagination' : '';
18
- document.querySelector('#usage').textContent = `{{> "${item.partial}"${context}${args.map(arg => `\n ${arg}`).join('')}\n}}`;
30
+ document.querySelector('#usage').textContent = args.length
31
+ ? `{{> "${item.partial}"${context}${args.map(arg => `\n ${arg}`).join('')}\n}}`
32
+ : `{{> "${item.partial}"${context}}}`;
33
+ }
34
+ function scheduleRender() {
35
+ clearTimeout(debounceTimer);
36
+ debounceTimer = setTimeout(render, 180);
19
37
  }
20
38
  function selectComponent() {
21
39
  controls.clear(); parameters.replaceChildren();
@@ -24,7 +42,7 @@ function selectComponent() {
24
42
  document.querySelector('#description').textContent = item.description;
25
43
  const definitions = { ...item.parameters, ...Object.fromEntries(Object.keys(item.styleSlots).map(key => [key, { description: key === 'class' ? 'Root classes for this instance.' : `Classes for ${item.styleSlots[key].join(', ')}.` }])) };
26
44
  for (const [name, definition] of Object.entries(definitions)) {
27
- const boolean = ['disabled','required','invalid','urgent'].includes(name);
45
+ const boolean = booleanParams.has(name);
28
46
  const label = document.createElement('label'); label.append(document.createTextNode(name));
29
47
  const input = document.createElement(definition.options || boolean ? 'select' : 'input');
30
48
  input.name = name;
@@ -33,6 +51,7 @@ function selectComponent() {
33
51
  const help = document.createElement('small'); help.textContent = definition.description;
34
52
  label.append(input, help); parameters.append(label); controls.set(name, input);
35
53
  input.addEventListener('change', render);
54
+ if (input.tagName === 'INPUT') input.addEventListener('input', scheduleRender);
36
55
  }
37
56
  status.textContent = 'Read-only preview. Your files have not been changed.';
38
57
  render();
@@ -50,6 +69,21 @@ async function loadCatalog() {
50
69
  component.addEventListener('change', selectComponent);
51
70
  document.querySelector('#scheme').addEventListener('change', render);
52
71
  document.querySelector('#state').addEventListener('change', render);
72
+ document.querySelector('#access')?.addEventListener('change', render);
73
+ viewport?.addEventListener('change', () => {
74
+ if (frameStage) frameStage.dataset.viewport = viewport.value;
75
+ });
76
+ copyUsage?.addEventListener('click', async () => {
77
+ const snippet = document.querySelector('#usage')?.textContent || '';
78
+ if (!snippet) return;
79
+ try {
80
+ await navigator.clipboard.writeText(snippet);
81
+ copyUsage.textContent = 'Copied';
82
+ setTimeout(() => { copyUsage.textContent = 'Copy snippet'; }, 1500);
83
+ } catch {
84
+ status.textContent = 'Copy manually from the template snippet below.';
85
+ }
86
+ });
53
87
  document.querySelector('#reload').addEventListener('click', render);
54
88
  loadCatalog().catch(error => { status.textContent = error.message; });
55
89
  setInterval(async () => {
@@ -1,4 +1,5 @@
1
1
  /* Only the preview shell, never component defaults. */
2
+ :root { --ghost-accent-color: #385bc6; }
2
3
  body { margin: 0; background: var(--background); color: var(--foreground); font: 16px/1.5 ui-sans-serif,system-ui,sans-serif; }
3
4
  .playground-preview { padding: 24px; overflow-wrap: anywhere; }
4
5
  #preview-feedback { font-size: 14px; color: var(--muted-foreground); margin-top: 16px; }