Skip to content
parsec-htmlPublic

About

parsec.tools and docs.parsec.tools: the website and documentation for Parsec

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

parsec.tools

The website at parsec.tools and the documentation at docs.parsec.tools, for Parsec, the parsing foundation for the web. Both are Astro sites, deployed to Cloudflare Pages from this one repository.

packages/brand   design tokens, fonts, the logo and social cards, and the
                 header, footer, SEO head and analytics both sites share
apps/site        parsec.tools (Astro)
apps/docs        docs.parsec.tools (Astro + Starlight)
scripts/         screenshots, Lighthouse and the header check, for review

Running it locally

You need Node 22.12 or later and pnpm 11 (corepack enable gives you the version pinned in package.json).

pnpm install
pnpm dev:site      # http://localhost:4321
pnpm dev:docs      # http://localhost:4322

pnpm build builds both apps and pnpm check runs astro check on both. pnpm preview:site and pnpm preview:docs serve the built output, which is what the review scripts below expect.

The logo

The mark is defined once, in packages/brand/src/mark.mjs: a tree between two angle brackets on a 32-unit grid, with one 3-unit stroke. The wordmark is "Parsec" in Geist Bold, outlined into paths, which the Open Font License allows in a logo, so nothing that shows it needs the font. pnpm --filter @parsec/brand logos runs scripts/make-logos.mjs, which draws the logo files, favicons, org avatar, social cards and the animated README header that parsec-html/parsec uses, and writes the wordmark's path data to src/wordmark.mjs for Logo.astro. Edit the script and run it again rather than editing those files.

Where the numbers come from

Nothing on the site that can be measured is typed in by hand, with one exception, the benchmark figures, and each of those says where and when it's from.

What From When
Package versions the crates.io, PyPI and npm APIs every build (apps/site/src/lib/data.ts)
Conformance counts conformance/baseline.json on Parsec's main, the counts a release must match or beat every build (apps/site/src/lib/data.ts)
The homepage's parse tree and errors the published parsec-web package, parsing the example every build (apps/site/scripts/hero.mjs)
Benchmark figures Parsec's Benchmarks and Real-world benchmarks pages, with date and machine copied by hand into apps/site/src/data/benchmarks.ts
Each technology page's example the first doc example in the crate's lib.rs at the released tag, which cargo test runs every build (getExample in apps/site/src/lib/data.ts)
Which crate may reach which the rows of Parsec's scripts/check-crate-deps.sh, which CI enforces every build (getCrateRows)
When the baseline last changed the GitHub API's last commit to conformance/baseline.json every build (getBaselineDate)
The roadmap and changelog pages Parsec's ROADMAP.md and CHANGELOG.md on main, rendered every build (apps/site/src/content.config.ts)

A fetch that fails fails the build, so a deploy never shows a number nobody checked. hero.mjs also fails the build if the parser stops building the tree the page's words describe.

Adding pages

  • Site: a page is a file in apps/site/src/pages/. Give it an entry in pages in apps/site/src/lib/site.ts; that entry's title and description go in its head, and src/pages/og/[...slug].png.ts draws its social card from it. Data a page needs goes in src/lib/data.ts (fetched at build) or src/data/. Most inner pages use src/layouts/InnerPage.astro, which takes the page's key, and wide tables go in src/components/Table.astro so they scroll on a phone. The six technology pages come from one route, src/pages/[tech].astro, and src/data/technologies.ts. A conformance suite new to Parsec's baseline fails the build until src/data/suites.ts says what it is.
  • Docs: a page is a Markdown or MDX file in apps/docs/src/content/docs/, with a title and description in its frontmatter. Add its slug to sidebar in apps/docs/astro.config.mjs. Every page gets a social card and JSON-LD from src/routeData.ts.

Checks

pnpm check            # astro check, both apps
pnpm check:headers    # headers and CSP on every built page, both apps
pnpm screenshots      # every page at four widths, into plans/screenshots
pnpm lighthouse       # Lighthouse, mobile and desktop, into plans/lighthouse

check:headers needs a build first. It parses each app's dist/_headers, hashes every inline script and style on every page and confirms each is in the policy, then serves the build with wrangler pages dev and loads every page in Chromium, failing on any missing header, CSP violation or console error.

Environment variables

Variable Where Does
PUBLIC_CF_ANALYTICS_TOKEN build, both apps Cloudflare Web Analytics token, for a host where Cloudflare doesn't inject the beacon itself. Empty leaves the beacon out; the policy allows its hosts either way.
NODE_VERSION build, both apps 22.23.3, set in each app's wrangler.toml and .node-version.

Cloudflare Pages

Two Pages projects: parsec-site for parsec.tools and parsec-docs for docs.parsec.tools. Each project's name matches name in its app's wrangler.toml, which also sets its variables.

Setting parsec.tools docs.parsec.tools
Project name parsec-site parsec-docs
Root directory apps/site apps/docs
Build command npm run build npm run build
Output directory dist dist
Custom domain parsec.tools (and www.parsec.tools redirecting to it) docs.parsec.tools

About

parsec.tools and docs.parsec.tools: the website and documentation for Parsec

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages