Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 77 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,79 @@
# screwfast

[Vercel's ScrewFast template](https://github.com/mearashadowfax/ScrewFast) on
**Cloudflare Workers**, deployed by [Orun](https://github.com/sourceplane/orun) to stage
and prod on every merge, and then packaged as an Orun baseline.

This commit is the repository's frame: `intent.yaml` (with the placeholder
workspace `ws_CHANGE_ME`, so CI plans nothing until it is linked), the Orun
CI workflow, the shared TypeScript and ESLint configuration, and the spec
index. The work is tracked as an epic under [`specs/epics`](specs/epics/README.md).
Vercel's [ScrewFast](https://github.com/mearashadowfax/ScrewFast) template —
an Astro, Tailwind CSS and Preline UI marketing site for a hardware and
construction company: a home page with features, pricing, FAQ and
testimonials, products and a page per product, services, contact, a blog and
customer insights, in English and French, and a Starlight documentation
section in seven languages with its full-text search — running on
**Cloudflare Workers + Static Assets**, deployed by
[Orun](https://github.com/sourceplane/orun) to stage and prod on every merge.
Packaging it as an Orun baseline is the next milestone (SF2).

ScrewFast builds fully static: `astro build` writes every marketing page,
product, post, insight and docs page to `dist/`, optimising every image with
sharp, Starlight's Pagefind indexes the docs into `dist/pagefind`, and the
template's minifier rewrites the pages in place. That folder is uploaded as
Workers Static Assets with one small Worker in front for what matches no
file — the site's 404 page, the French one under `/fr/`, as the template's
Vercel rewrite served it; no adapter and no server code. The pages, the
copy, the languages and the docs do not change; the site's name moves into
one module that the copy reads, and each deploy builds for its own origin.
See [`specs/epics/screwfast`](specs/epics/screwfast/README.md) for the
design, the milestones and the as-built status.

## What is here (the site)

| Surface | Where |
|---|---|
| The site's name (every page's title, the logos' labels, the footer, the Open Graph site name, the manifest, the docs' title, the copy that names the company) | `apps/web/src/site.ts` |
| The marketing copy, per language | `apps/web/src/copy/en.ts`, `apps/web/src/copy/fr.ts` |
| Features, pricing, FAQ, navigation and the site's constants | `apps/web/src/data_files/` (`fr/` for French) |
| Products, posts, insights (English and French) and the docs (seven languages) | `apps/web/src/content/` |
| Pages, views, layouts, components | `apps/web/src/pages`, `apps/web/src/views`, `apps/web/src/layouts`, `apps/web/src/components` |
| The docs' sidebar, languages, search and components | `starlight({…})` in `apps/web/astro.config.mjs`, `apps/web/src/components/ui/starlight` |
| The security headers | `apps/web/public/_headers` |
| The Worker in front of the assets (the 404 pages), its config, deploy contract | `apps/web/worker/index.ts`, `apps/web/wrangler.jsonc`, `apps/web/component.yaml` |
| Tests (the name seam, the origin, the Worker) | `apps/web/src/test` |

## Getting started

```bash
pnpm install
pnpm typecheck # astro check
pnpm lint # prettier --check (the template's format check)
pnpm test # vitest over Astro's container API
pnpm build # astro build (+ the docs' Pagefind index) and the minifier → apps/web/dist
```

```bash
pnpm --filter @app/web dev # http://localhost:4321
pnpm --filter @app/web preview # wrangler dev over the built site and its Worker
pnpm --filter @app/web test:smoke # the template's own smoke over the build
```

## How it maps to Vercel

| Vercel | Here |
|---|---|
| Static output (`dist/`) on Vercel's CDN | Workers Static Assets: `dist/` uploaded with the Worker `<repo>-web-<env>` (`apps/web/wrangler.jsonc`) |
| The template's build (`astro check && astro build && node process-html.mjs`) | Unchanged but for `astro check`, which runs as the `typecheck` step; `process-html.mjs` minifies `dist/` only (it also looked for `.vercel/output/static`) |
| `vercel.json` `headers` (CSP, frame options, HSTS …) | `public/_headers`, the same headers, which Workers Static Assets serve with every asset |
| `vercel.json` rewrite `/fr/:path*` → `/fr/404` | The Worker: a path under `/fr/` matching no file answers `/fr/404/` with a 404 (`apps/web/worker/index.ts`) |
| The host's 404 for any other unknown path | the Worker hands it to the assets, which answer `dist/404.html` with a 404 (`not_found_handling: 404-page`) |
| Directory URLs (`/products/`, the docs) | `assets.html_handling: auto-trailing-slash` — `/products/` serves `products/index.html`, `/products` redirects to it |
| `site: 'https://screwfast.uk'` | Each deploy builds for its own origin — the environment's `SITE_URL`, else its workers.dev URL — so canonical, hreflang and Open Graph links, the sitemap and robots.txt name the site where it is served; the domain placeholder is a local build's |
| Deploy on push | Orun deploys `<repo>-web-{stage,prod}` on merge to `main` (`apps/web/component.yaml`) |
| "Deploy with Vercel" (clone the template) | `orun new --blueprint repo-blueprint.yaml` — a new repository, branded, deployed |

## CI

| Workflow | What it runs | Ships to a site |
|---|---|---|
| `ci.yml` | the Orun pipeline, and the only workflow a site carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the site built and dry-deployed per environment — they do not type-check, lint or run the tests; `baseline.yml`'s e2e tier runs those before each tag, and a site's README asks its developers to run them before a push), except the bootstrap's own landings (`orun/BASE-*`), which are checked in the box before they are pushed (`checks: local`) and whose PR runs `plan` alone; a merge deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does. A manual run (Orunbase's Deploy button, or Run workflow on `main`) plans the environment and components it names under the push-to-main trigger, so they deploy as a merge deploys them | yes |

## Credits

The site is the ScrewFast template
([mearashadowfax/ScrewFast](https://github.com/mearashadowfax/ScrewFast)) by
Emil Gulamov (MIT — `apps/web/LICENSE`), at `86b25a9`.
20 changes: 20 additions & 0 deletions apps/web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# dependencies / lockfiles (Dependabot regenerates these; never format)
pnpm-lock.yaml
package-lock.json
yarn.lock
node_modules/

# build / generated
dist/
.astro/
.vercel/

# env / OS
.env
.env.*
.DS_Store

# the deploy contract and the component docs generated from it
# (tooling/catalog/gen-component-docs.py writes and checks both)
component.yaml
docs/
20 changes: 20 additions & 0 deletions apps/web/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf",
"plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
"overrides": [
{
"files": "*.astro",
"options": {
"parser": "astro"
}
}
]
}
21 changes: 21 additions & 0 deletions apps/web/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Emil Gulamov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions apps/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# apps/web — the site

A marketing site and its documentation on the ScrewFast template
([mearashadowfax/ScrewFast](https://github.com/mearashadowfax/ScrewFast), MIT) —
Astro 7, Tailwind CSS 4, Preline UI and Starlight — built fully static and
served as Cloudflare Workers Static Assets:

- the marketing pages, in English (`/`) and French (`/fr/`): the home page,
`/products/` and a page per product, `/services/`, `/contact/`, `/blog/`
and its posts, and the customer insights (`/insights/<id>/`)
- the docs (Starlight), in English at the root (`/welcome-to-docs/`,
`/guides/…`, `/tools/…`, `/construction/…`, `/advanced/…`) and under
`/de/`, `/es/`, `/fa/`, `/fr/`, `/ja/` and `/zh-cn/`, with their Pagefind
search index under `/pagefind/`
- `/manifest.json`, `/favicon.ico`, `/sitemap-index.xml`, `/robots.txt`, and
the 404 pages (`/404`, and the French one for anything under `/fr/`)

The site's name — every page's title, the logos' labels, the footer, the
Open Graph site name, the manifest, the docs' title and the copy that names
the company — is `src/site.ts`. The words around it are `src/copy/en.ts`
and `src/copy/fr.ts`; features, pricing and the FAQ are
`src/data_files/` (`fr/` for French); the products, posts, insights and docs
are `src/content/`. The docs' sidebar and languages are `starlight({…})` in
`astro.config.mjs`. The demo content is the template's, written as its
fictional company: replace it.

```bash
pnpm dev # http://localhost:4321
pnpm build # astro build + the minifier → dist/
pnpm preview # wrangler dev over dist/ and the Worker
pnpm test # vitest
pnpm test:smoke # the template's own route checks over dist/
pnpm typecheck # astro check
pnpm lint # prettier --check
```

`worker/index.ts` answers what matches no file in `dist/` with the site's
404 page (the French one under `/fr/`); `public/_headers` carries the
template's security headers; `wrangler.jsonc` and `component.yaml` are the
Worker's config and the deploy contract.
154 changes: 154 additions & 0 deletions apps/web/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import { defineConfig } from 'astro/config';
import tailwindcss from '@tailwindcss/vite';
import sitemap from '@astrojs/sitemap';
import starlight from '@astrojs/starlight';

import mdx from '@astrojs/mdx';
import { SITE_NAME } from './src/site.ts';

// The site's public origin: canonical, hreflang and Open Graph links, the
// sitemap and robots.txt are absolute. A deploy sets PUBLIC_SITE_URL to its
// environment's (its SITE_URL, else its workers.dev URL); a local build uses
// LOCAL_ORIGIN, the domain placeholder until the site has a domain. Renaming
// the site rewrites that line, so its layout is not left to its length.
// prettier-ignore
export const LOCAL_ORIGIN = 'https://screwfast.example.com';
const site = process.env.PUBLIC_SITE_URL || LOCAL_ORIGIN;

// https://astro.build/config
export default defineConfig({
// https://docs.astro.build/en/guides/images/#authorizing-remote-images
site,
image: {
domains: ['images.unsplash.com'],
},
// i18n: {
// defaultLocale: "en",
// locales: ["en", "fr"],
// fallback: {
// fr: "en",
// },
// routing: {
// prefixDefaultLocale: false,
// },
// },
prefetch: true,
integrations: [
sitemap({
i18n: {
defaultLocale: 'en', // All urls that don't contain language prefix will be treated as default locale
locales: {
en: 'en', // The `defaultLocale` value must present in `locales` keys
fr: 'fr',
},
},
}),
starlight({
title: `${SITE_NAME} Docs`,
// https://github.com/withastro/starlight/blob/main/packages/starlight/CHANGELOG.md
// If no Astro and Starlight i18n configurations are provided, the built-in default locale is used in Starlight and a matching Astro i18n configuration is generated/used.
// If only a Starlight i18n configuration is provided, an equivalent Astro i18n configuration is generated/used.
// If only an Astro i18n configuration is provided, the Starlight i18n configuration is updated to match it.
// If both an Astro and Starlight i18n configurations are provided, an error is thrown.
locales: {
root: {
label: 'English',
lang: 'en',
},
de: { label: 'Deutsch', lang: 'de' },
es: { label: 'Español', lang: 'es' },
fa: { label: 'Persian', lang: 'fa', dir: 'rtl' },
fr: { label: 'Français', lang: 'fr' },
ja: { label: '日本語', lang: 'ja' },
'zh-cn': { label: '简体中文', lang: 'zh-CN' },
},
// https://starlight.astro.build/guides/sidebar/
sidebar: [
{
label: 'Quick Start Guides',
translations: {
de: 'Schnellstartanleitungen',
es: 'Guías de Inicio Rápido',
fa: 'راهنمای شروع سریع',
fr: 'Guides de Démarrage Rapide',
ja: 'クイックスタートガイド',
'zh-cn': '快速入门指南',
},
items: [{ autogenerate: { directory: 'guides' } }],
},
{
label: 'Tools & Equipment',
// Translated guide intros exist per locale; these pages fall back to English.
translations: {
de: 'Werkzeuge & Ausrüstung',
es: 'Herramientas y Equipo',
fa: 'ابزار و تجهیزات',
fr: 'Outils et Équipement',
ja: 'ツールと機材',
'zh-cn': '工具与设备',
},
items: [
{ label: 'Tool Guides', link: 'tools/tool-guides/' },
{ label: 'Equipment Care', link: 'tools/equipment-care/' },
],
},
{
label: 'Construction Services',
translations: {
de: 'Baudienstleistungen',
es: 'Servicios de Construcción',
fa: 'خدمات ساخت‌وساز',
fr: 'Services de Construction',
ja: '建設サービス',
'zh-cn': '施工服务',
},
items: [{ autogenerate: { directory: 'construction' } }],
},
{
label: 'Advanced Topics',
items: [{ autogenerate: { directory: 'advanced' } }],
},
],
social: [
{
icon: 'github',
label: 'GitHub',
href: 'https://github.com/sourceplane/screwfast',
},
],
disable404Route: true,
customCss: ['./src/assets/styles/starlight.css'],
favicon: '/favicon.ico',
components: {
SiteTitle: './src/components/ui/starlight/SiteTitle.astro',
Head: './src/components/ui/starlight/Head.astro',
MobileMenuFooter:
'./src/components/ui/starlight/MobileMenuFooter.astro',
ThemeSelect: './src/components/ui/starlight/ThemeSelect.astro',
},
head: [
{
tag: 'meta',
attrs: {
property: 'og:image',
content: new URL('/social.webp', site).href,
},
},
{
tag: 'meta',
attrs: {
property: 'twitter:image',
content: new URL('/social.webp', site).href,
},
},
],
}),
mdx(),
],
experimental: {
clientPrerender: true,
},
vite: {
plugins: [tailwindcss()],
},
});
Loading
Loading