Skip to content

Plugins: drop the pageGate field - #2797

Merged
chalin merged 15 commits into
docsy:mainfrom
chalin:chalin-m24-page-gate-2026-0906
Sep 7, 2026
Merged

chalin merged 15 commits into
docsy:mainfrom
chalin:chalin-m24-page-gate-2026-0906

Conversation

@chalin

@chalin chalin commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator
  • Contributes to Add a JS plugin loading mechanism #2789
  • Scope:
    • the registry loses pageGate; the loop emits every enabled plugin
    • markmap gates itself in its shim on its render hook's flag; the legacy param keeps loading it site-wide
    • the MarkMap guide and 0.18 post teach the head-end flag where they taught pageGate: ''; the design page records the decision
    • the guide documents shims as a plugin file (Plugin files row, Adjust a plugin per page); the implementation page keeps the shim contract
    • the guide's plugin table folds Default and Loads-on into the description column, for a table that reads in one pass
  • Out of scope:
    • a site-facing gate switch (scope: site | page): design of record on the design page, added on a named trigger with no migration
    • the section-print flag gap: pre-existing, Mermaid and KaTeX included
    • tab-persistence gating: its own task
    • wrapping Docsy's shim rather than replacing it: its own task
  • Why no field: a flag name in config was two literals kept in sync by convention, with no site needing to set one; the rationale and the cross-generator comparison are on the design page
  • Where to start: markmap_docsy-shim.html, then plugins.html, then the two paired gate tests in plugins.test.mjs
  • Previews:

@chalin chalin added this to the 0.18.0 milestone Sep 6, 2026
@chalin chalin changed the title Plugins: drop the pageGate field; a plugin gates itself in its shim Plugins: drop the pageGate field Sep 6, 2026
The registry's `pageGate` named a `.Page.Store` flag that a render hook set
elsewhere: two literals kept in sync by convention, a `true` that meant "no
gate", and an env override that became a flag named `false`. No plugin needs a
site-settable gate in 0.18 (one gated plugin, no custom plugins), and the norm
across SSGs is per-page loading decided by the theme with no switch.

The loop emits every enabled plugin. Markmap's shim turns the entry off where
its hook's `hasMarkmap` flag is absent (setter and reader are two files of one
owner, the pattern the dispatcher uses for `hasmermaid` and `hasMath`); the
legacy `params.markmap.enable` still re-enables site-wide through its cycle. A
site that needs MarkMap on a page its hook didn't flag sets the flag from
`hooks/head-end.html`.

Tests: the gate test takes the shim shape; a head-end-clears case is added; the
boolean-gate and gated-missing cases follow the field.
The MarkMap guide and the 0.18 post teach setting `hasMarkmap` from
`hooks/head-end.html` where they taught `pageGate: ''`; the Plugins guide's
security rule and included-content section drop the field; the design page
records the decision (gating lives in the plugin's hook + shim, no registry
field; `scope: site | page` is the design of record if a switch is ever asked
for); the implementation page's shim contract gains the gating branch.
@chalin
chalin force-pushed the chalin-m24-page-gate-2026-0906 branch from f9ab615 to 480eca4 Compare September 7, 2026 09:37
…the gating bullet

The head-end and gated-missing tests build a hook-less twin first, so each
asserts the gate before asserting the widening; a shared fixture shim replaces
three copies. The MarkMap guide lists the authoring paths and says why the head
hook, not the body hook. The design page's gating bullet splits into rule, why
no field, and design of record.
…n page owns the contract

The guide's Plugin files table gains the shim row and a task section, Adjust a
plugin per page: add one for your own plugin or any of Docsy's, the gate shape
as the example, and widening an existing gate by setting its flag. The Security
rule points there. The implementation section keeps the ABI: resolution, call
order relative to the guards, return rule, ownership, and the cleanup rule for
a deprecated parameter; the "two uses" inventory goes. The design page's
registry-shape and override-points items name the shim as a plugin file.
The MarkMap guide no longer says markup from anywhere but the page's own content
misses the hook (a .RenderShortcodes include flags the includer); the shim
contract names the two guards that run after a shim instead of "every guard".
Restated clauses go: the shadowing rule in the shim section, two test comments,
the design page's fragment labels take the colon form, the markmap shim's header
splits its nested references.
…blished flag

The guide says so where it invites the shim, and the shadowing rule names shims;
a 0.17 site that added the example shim for markmap otherwise lost MarkMap
everywhere with no warning. The MarkMap guide states the enabled precondition
and that a shadowed render hook must keep the Store.Set line. A markmap test
pins the `hasMarkmap` literal the guide and the post publish (red under a
consistent rename). The design page's two gating bullets merge, with the
cross-generator observation homed there; the implementation page splits the
shim-order sentence and drops "re-gate" for params; the lowercasing examples
illustrate the point again.
…osis

The guide says which two Docsy plugins have a shim to replace and what a
replacement drops (gate, Prism guard, deprecated parameters), and hands the
shim's ABI back to the implementation page. The MarkMap guide qualifies its
loading claim as the default and notes that a custom render hook must keep
Hugo's code-block markup as well as the flag; the post names the render hook,
not the script, as what stopped seeing the markup. The loop's header says
"enabled plugins"; the plugin table separates default and load scope with a
slash.
- Implementation § Shims: state gating as the shim's contract move
  (return the entry with `enable` false) instead of a policy line
- Markmap shim header: drop the design-rationale link; the contract
  link reaches it in one hop
- Plugins guide: "the theme's file" link named a directory; cut the
  sentence that restated the shim snippet; Configure table header
  and description periods
- markmap test: shorten the `hasMarkmap` literal comment to its pointer
@chalin
chalin merged commit 9f8acf7 into docsy:main Sep 7, 2026
18 checks passed
@chalin
chalin deleted the chalin-m24-page-gate-2026-0906 branch September 7, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant