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 +12 -0
- package/lib/markup/helpers.js +10 -6
- package/package.json +1 -1
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.
|
package/lib/markup/helpers.js
CHANGED
|
@@ -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
|
-
//
|
|
536
|
-
//
|
|
537
|
-
//
|
|
538
|
-
//
|
|
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
|
|
581
|
-
// the escape hatch is meant for whole-key
|
|
582
|
+
// site.jsonld then page.jsonld extend/override — the 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)]
|