Examples

Offline normalization demo

An Eleventy page built from the real wp-awesome API and a fictitious REST response, with no WordPress connection or credentials.

Generated content

Example page

This paragraph comes from a normalized WordPress record.

Public path: /sample-page/

Output file: sample-page/index.html

Source REST record

{
  "id": 42,
  "type": "page",
  "slug": "sample-page",
  "status": "publish",
  "title": {
    "rendered": "Example page"
  },
  "excerpt": {
    "rendered": "<p>A small offline example.</p>"
  },
  "content": {
    "rendered": "<p>This paragraph comes from a <strong>normalized WordPress record</strong>.</p>"
  },
  "link": "https://beautiful.wp.site/sample-page/"
}

Normalized public record

{
  "id": 42,
  "type": "page",
  "slug": "sample-page",
  "status": "publish",
  "title": {
    "html": "Example page",
    "text": "Example page"
  },
  "excerpt": {
    "html": "<p>A small offline example.</p>",
    "text": "A small offline example."
  },
  "content": {
    "html": "<p>This paragraph comes from a <strong>normalized WordPress record</strong>.</p>",
    "source": "rendered-html",
    "hasSerializedBlocks": false,
    "blockTypes": {},
    "unsupportedBlockNames": [],
    "fallbackReason": "rendered-mode-configured"
  },
  "dates": {
    "published": null,
    "modified": null
  },
  "author": null,
  "taxonomies": [],
  "featuredMedia": null,
  "customFields": {},
  "sourceUrl": "https://beautiful.wp.site/sample-page/",
  "route": {
    "path": "/sample-page/",
    "outputPath": "sample-page/index.html",
    "canonicalUrl": "https://beautiful.wp.site/sample-page/"
  }
}

The data file docs-site/src/_data/demo.js calls the package's public normalization API. This template renders the resulting contract. The local relative import is equivalent to require('wp-awesome') in an installed consumer.

Continue with the complete consumer example to replace the fixture with paginated REST requests.