Skip to content

Preview as different readers

Serve the docs on your machine, rebuilding on save, and see exactly what each kind of reader gets.

The previewer uses the same build, filter and renderer as hosted delivery. "Preview as" is the real reader filter, not an approximation, so if a paragraph shows for a reader here, it shows for that reader in production.

  1. Start the previewer on your docs folder.
    pnpm opend preview path/to/docs

    It prints any problems, then Serving http://127.0.0.1:4000/ (watching for changes). Open that address. Pages reload when you save a file.

  2. Look at the staff view.

    With no reader options the previewer shows everything that survives the build-time filter, and marks each conditional element with its attributes, such as product=embed. Every alternative of a conditional key is shown, separated by a bar. Readers never see these markers.

  3. Switch reader with Preview as in the banner at the top of each page.

    The list holds the readers in preview-contexts.yaml. The choice is kept in a cookie, so it sticks while you browse. The banner also shows the reader's products, features and version, and a summary of any validation problems.

  4. Or start the previewer as a particular reader.
    • --as admin picks a named reader from preview-contexts.yaml.
    • --product core,embed --feature early-access --version 0.1 describes a reader on the command line. --version defaults to the project's release.
    • --all is the staff view, the default.
  5. Optional: preview a release branch or tag without checking it out.
    pnpm opend preview path/to/docs --ref v1

    A git ref is read once and not watched.

Besides the pages, the previewer serves a few helper pages:

/search?q=…
The search box in the page header: the current reader's pages that match, searched in memory. See Search the docs.
/_opend/publications
Every PDF publication, and whether the current reader can see anything in it.
/pdf/<name>.pdf and /pdf/<name>.html
A publication printed for the current reader, and its print HTML.
/_opend/help-lab
What every context-sensitive help key and route resolves to. See Check context help in the help lab.
/_opend/diagnostics.json
The current validation problems as JSON.

To add your own sample readers, see preview-contexts.yaml reference.