How the site is put together
For developers who want to change or extend the site. To set it up, start with the setup guide; for every setting and content file, For developers.
In one picture
Section titled “In one picture” Content files The data layer Pages ───────────── ────────────── ───── src/content/directory/ ─► src/lib/directory/index.ts ─► src/pages/, src/directory-routes/ listings/*.md getListings() getListing() built ahead of time (static HTML) categories.json, tags… getCategories() getFacets() components: src/components/ placements/*.json getPlacements() … collections/*.json → plain objects (types.ts) src/content/directory/ ─► page copy (pages/*.json) ─► /listings-index.json (search, filters), Pagefind full-text index Settings ──────── src/config/*.json ─► validated at every build (a wrong value stops it, naming the key)
The content editor (/admin/) edits the same files, through GitHub: every save is a commit Small server functions (/api/) the features a static page can't do (below)The site is an Astro project. Every page is built ahead of time into plain
HTML in dist/, so it’s fast, cheap to host and has little to attack. A few features need code
running on the host, and those are small functions beside the pages:
| Function | What it does | Code |
|---|---|---|
/api/submit |
Takes a “Submit a listing” form, checks it, and opens a pull request with the listing as a draft | src/lib/submissions/ (src/lib/submissions) |
/api/cms/… |
Signs editors in to the content editor with GitHub; tells signed-in editors how the keys are doing, Stripe’s permissions, the latest release, and who sent a submission | src/lib/cms/auth.ts |
/api/advertise/… |
The sponsorship checkout and Stripe’s webhook | src/lib/advertise/ (src/lib/advertise) |
One handler answers all of them (src/lib/server/routes.ts), and each
host gets a thin adapter: worker/index.ts for Cloudflare Workers, the files in
adapters/ (adapters) for the others, and a Node server for hosts that run one. Without these
features, the site needs no functions at all. Hosting compares the hosts.
Where things live
Section titled “Where things live”| What | Where |
|---|---|
| Listings, one Markdown file each (the file name is the address) | src/content/directory/listings/<slug>.md |
| Categories, tags, regions, integrations, attributes | src/content/directory/*.json |
| Editor’s picks and sponsored places | src/content/directory/placements/*.json |
| Curated collections | src/content/directory/collections/*.json |
| The directory pages’ words | src/content/directory/pages/<page>.json |
| Blog posts, legal pages | src/content/blog/, src/content/pages/ |
| The owner’s settings (the editor’s Settings pages: name, colours, words, forms, packages, features, analytics, services, the menu, the newsletter) | src/config/settings/*.json, laid over the config files below (src/lib/settings/ (src/lib/settings)) |
| Developer settings, and the fallback for each owner’s setting | src/config/directory.config.json, site.config.json, menu.json (read them through src/config/site.ts and social.ts, which include the settings) |
| The schemas every file is checked against | src/lib/directory/schema.ts and its neighbours |
| Reading the content (the only code that does) | src/lib/directory/index.ts |
| Every directory address | src/lib/directory/routes.ts |
| The directory’s pages | src/directory-routes/ (src/directory-routes) (added by astro.config.mjs, at the names in routes) |
| Components and page types | THEME_CATALOG.md |
| The content editor’s setup (generated) | src/lib/cms/ (src/lib/cms) |
The setup and its checks (npm run setup, npm run doctor) |
scripts/setup/ (scripts/setup), src/lib/setup/ (src/lib/setup) |
The tests (npm run qa:quick, npm run qa:full) |
scripts/qa/ (scripts/qa/README.md) |
The rules that keep it easy to change
Section titled “The rules that keep it easy to change”- Pages never read content files. They ask the data layer (
getListings(),getCategory(), …) and get plain objects back. Where the content comes from can change without touching a page. - One schema per kind of content. The listing schema checks the listing files, the submissions and the editor’s forms: the editor’s configuration is generated from the schemas at every build, so a field can’t exist in one and not the other.
- Links between things are slugs. A listing names its categories by slug (
categories: ["finance"]). Renaming a listing keeps its old slug inprevious_slugs, which becomes a redirect. - Descriptions are Markdown, turned into HTML by the data layer, with unsafe links and images
removed (
src/lib/markdown.ts). - Search and filters read one index.
/listings-index.jsonholds every listing’s summary and filter values; Pagefind indexes the built pages for full-text search. - Placements are records of their own. An Editor’s pick or a sponsored place is a listing, a slot, start and end dates and a label, never a flag on the listing. Paid places are always labelled “Sponsored”.
- Addresses come from one helper.
routes.listing(slug)and the rest read the route names from the settings, so renaming/listingsto/toolsis one change, and the menus, the sitemap, the breadcrumbs and the structured data follow. A page’s address always ends with “/” (/listings/acme/), as its canonical URL does, so hosts serve it without a redirect; a link you write by hand in the menu or a page’s call to action gets the slash added.npm run doctor -- --livechecks your host serves it that way. - Settings are checked at every build. A wrong value in a config file stops the build with the key that’s wrong. A setting saved on a Settings page that the build can’t use doesn’t stop it: that setting keeps the config file’s value, the build warns, and the editor says what to fix.
- Light and dark: colours that differ are
light-dark()pairs;bg-lightandbg-surfacefollow the page,bg-darkkeeps the ink’s. Use the colour tokens on light sections, nevertext-white,bg-whiteor a hex; a panel painted another way takestone-paper. Check a new part in both modes (THEME_CATALOG.md → Light and dark;npm run qa:lookand the QA’s dark mode job).
How a change goes live
Section titled “How a change goes live”- A change is made: in the content editor (a commit to GitHub), or in the files and pushed.
- The host builds the site (
npm run build): it finds the repository and the host by itself (scripts/directory/detect.mjs), checks every setting and content file, builds the pages and the search index, and generates the editor’s configuration. - The host deploys
dist/and the functions. A build that fails never replaces the live site. - A daily rebuild (
.github/workflows/daily-rebuild.yml) starts and ends placements on their dates.
Extending it
Section titled “Extending it”- A new field on listings: add it to the listing schema in
src/lib/directory/schema.ts, give it an editor field insrc/lib/cms/fields.tsif its type needs one (the tests fail, naming it, until every field has one), and show it in the listing page (src/directory-routes/listing.astro) or the card (src/components/directory/ListingCard.astro). - A fact, badge or filter, without code: add an attribute in the editor (Attributes), or in
src/content/directory/attributes.json, and list it infiltersto filter by it. - A new page: an Astro page in
src/pages/, built from the theme’s sections (THEME_CATALOG.md lists them, with the page types they suit). Its words go in a content file, not in the page. - Different addresses:
routesindirectory.config.json. Add redirects for the old ones if the site is already live. - Another host:
hosting.providerindirectory.config.json, then Hosting. - Another form service:
formsindirectory.config.json(Forms).
Before you commit, run npm run qa:quick: the type check, the build, and the tests for what you
changed.