Skip to content
DocsFor version 1.1.x

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.

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.

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)
  1. 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.
  2. 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.
  3. Links between things are slugs. A listing names its categories by slug (categories: ["finance"]). Renaming a listing keeps its old slug in previous_slugs, which becomes a redirect.
  4. Descriptions are Markdown, turned into HTML by the data layer, with unsafe links and images removed (src/lib/markdown.ts).
  5. Search and filters read one index. /listings-index.json holds every listing’s summary and filter values; Pagefind indexes the built pages for full-text search.
  6. 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”.
  7. Addresses come from one helper. routes.listing(slug) and the rest read the route names from the settings, so renaming /listings to /tools is 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 -- --live checks your host serves it that way.
  8. 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.
  9. Light and dark: colours that differ are light-dark() pairs; bg-light and bg-surface follow the page, bg-dark keeps the ink’s. Use the colour tokens on light sections, never text-white, bg-white or a hex; a panel painted another way takes tone-paper. Check a new part in both modes (THEME_CATALOG.md → Light and dark; npm run qa:look and the QA’s dark mode job).
  1. A change is made: in the content editor (a commit to GitHub), or in the files and pushed.
  2. 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.
  3. The host deploys dist/ and the functions. A build that fails never replaces the live site.
  4. A daily rebuild (.github/workflows/daily-rebuild.yml) starts and ends placements on their dates.
  • A new field on listings: add it to the listing schema in src/lib/directory/schema.ts, give it an editor field in src/lib/cms/fields.ts if 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 in filters to 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: routes in directory.config.json. Add redirects for the old ones if the site is already live.
  • Another host: hosting.provider in directory.config.json, then Hosting.
  • Another form service: forms in directory.config.json (Forms).

Before you commit, run npm run qa:quick: the type check, the build, and the tests for what you changed.

These docs describe SixtyList 1.1.x.