poops 1.9.6 → 1.9.7

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/README.md CHANGED
@@ -1093,6 +1093,18 @@ All filters are available in both engines. The only syntax difference is how arg
1093
1093
  ---
1094
1094
  ```
1095
1095
 
1096
+ The same `jsonld` object works in your `site` data, as a site-wide default — useful when every page on the site is one type. A docs site is `TechArticle`, not `WebPage`:
1097
+
1098
+ ```json
1099
+ "markup": {
1100
+ "site": {
1101
+ "jsonld": { "@type": "TechArticle" }
1102
+ }
1103
+ }
1104
+ ```
1105
+
1106
+ Precedence is defaults → `site.jsonld` → `page.jsonld`, so a single page can still opt out (a `FAQPage` inside a `TechArticle` site). A site-wide `@type` also overrides the auto-detected `BlogPosting` on dated pages, so on a site mixing docs and a blog set the type per page instead. Both merge into the page's own block only — the auto-emitted `WebSite` and `BreadcrumbList` blocks are untouched.
1107
+
1096
1108
  poops auto-picks `BlogPosting` (page has a `date`) or `WebPage`. Override `@type` with the `jsonld` object for any schema.org type — common ones search/generative engines act on: `Article`, `NewsArticle`, `HowTo`, `FAQPage`, `QAPage`, `Product`, `Recipe`, `Event`, `Course`, `VideoObject`, `SoftwareApplication`, `Organization`, `Person`, `BreadcrumbList`, `WebSite`. Full list at [schema.org/docs/full](https://schema.org/docs/full.html); validate with the [Rich Results Test](https://search.google.com/test/rich-results). A per-`@type` table with the notable fields is in the [Templating docs](example/src/markup/docs/quick-start/templating-html.md).
1097
1109
 
1098
1110
  - `breadcrumb` — generates a visible breadcrumb `<nav class="breadcrumb"><ol>…</ol></nav>` trail for the page body (blog posts, nested pages), from the same URL-depth data the `jsonld` `BreadcrumbList` uses: the site root, each ancestor folder (humanized, e.g. `docs/static-site` → _Static Site_), then the current page as `aria-current` text. Pass `relativePathPrefix` so links resolve against the current output location (localhost in dev, your deployed subpath in prod) — not the absolute domain.
@@ -532,10 +532,12 @@ export function buildBreadcrumb(page, site = {}, prefix = '') {
532
532
  // gains a `logo` ImageObject when `site.logo` is set — Google Article rich
533
533
  // results require it. On the homepage (page has no `url`) a second `WebSite`
534
534
  // block is emitted, declaring the site name for search results.
535
- // Anything in `page.jsonld` (an object) is merged over the generated defaults,
536
- // so a page can add or replace any field including @type as a full escape
537
- // hatch. Values come from front matter, so the JSON is escaped for a <script>
538
- // context to prevent a `</script>` break-out (XSS).
535
+ // `site.jsonld` and `page.jsonld` (objects) are merged over the generated
536
+ // defaults site-wide first, then the page so a site can set a default
537
+ // @type (a docs site is TechArticle, not WebPage) and a page can still add or
538
+ // replace any field as a full escape hatch. Values come from front matter, so
539
+ // the JSON is escaped for a <script> context to prevent a `</script>`
540
+ // break-out (XSS).
539
541
  export function buildJsonLd(page, site = {}) {
540
542
  page = page || {}
541
543
  site = site || {}
@@ -577,8 +579,10 @@ export function buildJsonLd(page, site = {}) {
577
579
  if (page.wordcount) data.wordCount = page.wordcount
578
580
  }
579
581
 
580
- // page.jsonld extends/overrides. Shallow merge nested schema is rare and
581
- // the escape hatch is meant for whole-key replacement.
582
+ // site.jsonld then page.jsonld extend/overridethe page wins. Shallow
583
+ // merge — nested schema is rare and the escape hatch is meant for whole-key
584
+ // replacement.
585
+ if (site.jsonld && typeof site.jsonld === 'object') Object.assign(data, site.jsonld)
582
586
  if (page.jsonld && typeof page.jsonld === 'object') Object.assign(data, page.jsonld)
583
587
 
584
588
  const blocks = [jsonLdScript(data)]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "poops",
3
3
  "description": "Straightforward, no-bullshit bundler for the web.",
4
- "version": "1.9.6",
4
+ "version": "1.9.7",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "poops.js",