All about the Environmental Protection Service site

This is a work in progress and general brain-dump of everything about the site. It will eventually get sorted into a more logical collection of posts.

Architecture Overview

The BIG overview

  • Backend is WordPress Theme (hybrid) + ACF + Gutenberg
    • Plugin handles data fetching from USGS for Water Dashboard
    • Custom Rest Routes are created for frontend
  • Frontend is Astro in ‘server’ mode
    • Most page routes opt in to prerender = true

The Code Overview

  • Monorepo stores all the code in one place
  • /shared for shared configs
  • /backend for all WordPress-y things
  • /frontend for astro

The Deploys

Generally, the deploys work the same as other repos, but there’s an extra build/deploy that’s handled entirely by the WP Engine headless system. It needs to be aware of any secrets (stored in a .env file) for it to work properly (handled via WP Engine Headless dashboard).

Astro & WP Endpoints

Since Astro and WordPress handle routing from opposite directions, it is generally easier to just create a custom endpoint to get the data to the frontend. Here’s a list of endpoints and what they return (in a less-formal structure than JSON Schema).

namespace: cno/v1

Endpoints:

  • /content
    • /content/pages
      • Returns all pages (used for getStaticPaths)
    • /content/pages/<id>
      • Returns the block markup of a specific page (so Astro can build the html properly)
  • /dashboard ⚠️
    • currently returns water dashboard data, but probably needs to be updated to v2/dashboards/water to prep for things like v2/dashboards/air-quality
  • /nav-menus/<location>
    • Returns nav menu items by location

See something inaccurate?