Skip to content

Unit 13: shortcodes + render hooks modernization (Store, render-image, render-heading)#15

Open
stradichenko wants to merge 1 commit intomainfrom
unit-13-shortcodes-render-hooks-modernization
Open

Unit 13: shortcodes + render hooks modernization (Store, render-image, render-heading)#15
stradichenko wants to merge 1 commit intomainfrom
unit-13-shortcodes-render-hooks-modernization

Conversation

@stradichenko
Copy link
Copy Markdown
Owner

Summary

  • shortcodes/cite.html: replace .Page.Scratch.Get/Set with .Page.Store.Get/Set (Hugo 0.85+, well below the 0.136 floor). Refactor printf | safeHTML HTML construction into a dict + inline template partial for cleaner escaping.
  • shortcodes/sidenote.html: same ScratchStore, same printf refactor.
  • _markup/render-inline.html and render-paragraph.html: drop blanket safeHTML; the trust assumption is now documented.
  • _markup/render-link.html: simplify; rely on the render-hook context for resolved URLs instead of manually prepending BaseURL.
  • NEW _markup/render-image.html: emit <img loading=lazy decoding=async> with responsive srcset via images.Process / Resize when the image is a Page Resource, plus width / height from image metadata.
  • NEW _markup/render-heading.html: emit <h{N} id="..."> with an anchor link (¶) and aria-label.
  • recent-posts-grid.html: replace hardcoded ("Type" "posts") filter with site.RegularPages "Section" "in" site.Params.mainSections (defaulted to slice "posts").

Test plan

  • A markdown page with image and heading renders with the new attrs.
  • cite and sidenote shortcodes still produce identical output.
  • Recent-posts respects mainSections config.

Part of the PKB-theme modernization batch (15 units).

- shortcodes/cite.html: replace .Page.Scratch.Get/Set with
  .Page.Store.Get/Set (Hugo 0.85+, well below the 0.136 floor).
  Refactor printf | safeHTML HTML construction into a dict + inline
  template partial for cleaner escaping.
- shortcodes/sidenote.html: same Scratch -> Store, same printf refactor.
- _markup/render-inline.html and render-paragraph.html: drop blanket
  safeHTML; the trust assumption is now documented.
- _markup/render-link.html: simplify; rely on the render-hook context
  for resolved URLs instead of manually prepending BaseURL.
- NEW _markup/render-image.html: emit <img loading=lazy decoding=async>
  with responsive srcset via images.Process / Resize when the image is
  a Page Resource, plus width / height from image metadata.
- NEW _markup/render-heading.html: emit <h{N} id="..."> with an anchor
  link (¶) and aria-label.
- recent-posts-grid.html: replace hardcoded ("Type" "posts") filter
  with site.RegularPages "Section" "in" site.Params.mainSections
  (defaulted to slice "posts").
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