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
71 changes: 62 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,64 @@
# astrowind

Vercel's [AstroWind](https://github.com/arthelokyo/astrowind) template — an
Astro + Tailwind CSS marketing site and blog — on **Cloudflare Workers +
Static Assets**, 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 [AstroWind](https://github.com/arthelokyo/astrowind) template — a
free Astro + Tailwind CSS marketing site and blog: a home page, about,
pricing, services and contact pages, six landing-page and four home-page
demos, and a Markdown/MDX blog with categories, tags, an RSS feed and a
sitemap — 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 (AW2).

AstroWind builds fully static, and its own README deploys it to Cloudflare
Workers as static assets with no adapter; that is the port. `astro build`
writes every page, post, feed, sitemap and optimised image to `dist/`, and
one small Worker sits in front of the assets for what matches no file. The
pages, the widgets, the blog and the theme do not change; the site's name
moves into one module, and `vercel.json`'s clean URLs and cache header
become the Worker's asset settings and `public/_headers`. See [`specs/epics/astrowind`](specs/epics/astrowind/README.md) for the
design, the milestones and the as-built status.

## What is here (the site)

| Surface | Where |
|---|---|
| The site's name (the header's logo text, every page's title template) | `apps/web/src/site.ts` |
| Site URL, metadata, blog options, analytics | `apps/web/src/config.yaml` |
| Pages, landing and home demos | `apps/web/src/pages` |
| Blog posts | `apps/web/src/data/post` |
| Widgets, layouts, theme | `apps/web/src/components`, `apps/web/src/layouts`, `apps/web/vendor/integration` |
| The Worker in front of the assets, its config, deploy contract | `apps/web/worker/index.ts`, `apps/web/wrangler.jsonc`, `apps/web/public/_headers`, `apps/web/component.yaml` |
| Tests (Astro container API, the Worker) | `apps/web/src/test` |

## Getting started

```bash
pnpm install
pnpm typecheck # astro check
pnpm lint # eslint
pnpm test # vitest over the container API
pnpm build # astro build → 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
```

## 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`) |
| `vercel.json` `cleanUrls` + `trailingSlash: false` | `assets.html_handling: drop-trailing-slash` — `/about` serves `about/index.html`, `/about/` redirects to it |
| `vercel.json` `/_astro/*` immutable `Cache-Control` | `public/_headers`, which the assets upload honours |
| Vercel's 404 for an unknown path | the Worker hands it to the assets, which answer `dist/404.html` with a 404 (`not_found_handling: 404-page`) |
| Image optimisation | Unchanged: `astro build` optimises local images with sharp, and remote ones go through Unpic to their CDN |
| `site: https://astrowind.vercel.app` | Each deploy builds for its own origin — the environment's `SITE_URL`, else its workers.dev URL — so canonical links, the sitemap and the RSS feed name the site where it is served; `src/config.yaml`'s `site:` 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 |
3 changes: 3 additions & 0 deletions apps/web/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AstroWind reads no environment variable: its site URL, metadata, blog and
# analytics options (Google Analytics id, partytown) are src/config.yaml, and
# its name is src/site.ts. A variable a later change adds is listed here.
4 changes: 4 additions & 0 deletions apps/web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
node_modules
.github
.changeset
13 changes: 13 additions & 0 deletions apps/web/.prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('prettier').Config} */
export default {
printWidth: 120,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,

plugins: ['prettier-plugin-astro'],

overrides: [{ files: '*.astro', options: { parser: 'astro' } }],
};
21 changes: 21 additions & 0 deletions apps/web/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 onWidget

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.
31 changes: 31 additions & 0 deletions apps/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# apps/web — the site

An [AstroWind](https://github.com/arthelokyo/astrowind) site (MIT) — Astro 7
and Tailwind CSS 4 — built fully static and served as Cloudflare Workers
Static Assets:

- `/`, `/about`, `/pricing`, `/services`, `/contact`, `/terms`, `/privacy`
- `/homes/*` (SaaS, startup, mobile app, personal) and `/landing/*` (six
landing-page demos)
- the blog: `/blog`, a page per post (`src/data/post/*.md|mdx`),
`/category/*`, `/tag/*`, `/rss.xml`; `/sitemap-index.xml`, `/robots.txt`

The site's name — the header's logo text and every page's title template — is
`src/site.ts`. Its URL, metadata, blog options and analytics are
`src/config.yaml`; header and footer links are `src/navigation.ts`; colours
and fonts are `src/components/CustomStyles.astro` and `astro.config.ts`.

```bash
pnpm dev # astro dev on http://localhost:4321
pnpm test # vitest over Astro's container API (src/test)
pnpm build # astro build → dist/
pnpm preview # wrangler dev over dist/ and the Worker
```

`wrangler.jsonc` is what deploys: the Worker (`worker/index.ts`) and `dist/`
as its assets. A request that matches a file is served from the assets; one
that does not reaches the Worker, which hands it back to the assets for the
site's 404 page. `public/_headers` sets the immutable cache on `/_astro/*`.

How it is deployed — per environment, on merge to `main` — is the
repository's README and `component.yaml` beside this file.
140 changes: 140 additions & 0 deletions apps/web/astro.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import path from 'path';
import { fileURLToPath } from 'url';

import { defineConfig, fontProviders } from 'astro/config';

import { unified } from '@astrojs/markdown-remark';

import sitemap from '@astrojs/sitemap';
import tailwindcss from '@tailwindcss/vite';
import mdx from '@astrojs/mdx';
import partytown from '@astrojs/partytown';
import icon from 'astro-icon';
import compress from 'astro-compress';
import type { AstroIntegration } from 'astro';

import theme from './vendor/integration';

import { readingTimeRemarkPlugin, responsiveTablesRehypePlugin } from './src/utils/frontmatter';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const hasExternalScripts = false;
const whenExternalScripts = (items: (() => AstroIntegration) | (() => AstroIntegration)[] = []) =>
hasExternalScripts ? (Array.isArray(items) ? items.map((item) => item()) : [items()]) : [];

export default defineConfig({
output: 'static',

// Prefetch links as they enter the viewport for snappier navigations
// (works together with <ClientRouter />, which enables prefetch by default).
prefetch: {
prefetchAll: true,
defaultStrategy: 'viewport',
},

// Native Fonts API: self-hosts + subsets + preloads Inter and generates
// metric-adjusted fallbacks. Injected via <Font /> in Layout.astro and
// consumed through the `--font-inter` CSS variable in CustomStyles.astro.
fonts: [
{
provider: fontProviders.fontsource(),
name: 'Inter',
cssVariable: '--font-inter',
weights: ['100 900'],
styles: ['normal'],
subsets: ['latin'],
fallbacks: ['sans-serif'],
},
],

integrations: [
sitemap(),
mdx(),
icon({
// Local SVG icons (used as <Icon name="file-name" />) live next to the other assets.
iconDir: 'src/assets/icons',
include: {
tabler: ['*'],
'flat-color-icons': [
'template',
'gallery',
'approval',
'document',
'advertising',
'currency-exchange',
'voice-presentation',
'business-contact',
'database',
],
},
}),

...whenExternalScripts(() =>
partytown({
config: { forward: ['dataLayer.push'] },
})
),

compress({
// csso off on purpose: its parser doesn't understand the media range
// syntax Tailwind v4 emits for breakpoints (`@media (width>=48rem)`) and
// silently drops every one of those blocks — the site then renders as if
// all `md:`/`lg:` classes were missing. lightningcss parses it correctly.
CSS: { csso: false, lightningcss: { minify: true } },
HTML: {
'html-minifier-terser': {
removeAttributeQuotes: false,
},
},
Image: false,
JavaScript: true,
SVG: false,
Logger: 1,
}),

theme({
config: './src/config.yaml',
}),
],

image: {
// Astro's default Sharp service handles local images.
//
// Most remote CDN images (Unsplash, Cloudinary, Imgix…) are routed by
// src/components/common/Image.astro through `unpic`, which rewrites the
// URL with CDN-side query parameters and serves it straight from the
// provider — Astro never downloads it, so they don't need to be listed.
//
// `domains` only matters for remote URLs that fall through to Astro's
// native <Image /> (i.e. providers Unpic can't detect, like Pixabay).
// Listed entries are authorized to be processed by Sharp.
// Unsplash is listed so post covers can be rendered as real 1200×626 Open Graph images.
domains: ['cdn.pixabay.com', 'images.unsplash.com'],

// Emit responsive styles for the native <Image layout=…> used by
// src/components/common/Image.astro (local images). Utility classes on
// each usage still win, since these styles use low-specificity selectors.
responsiveStyles: true,
},

markdown: {
processor: unified({
remarkPlugins: [readingTimeRemarkPlugin],
rehypePlugins: [responsiveTablesRehypePlugin],
}),
shikiConfig: {
// Code blocks follow the site theme; see the `.astro-code` rules in tailwind.css.
themes: { light: 'github-light', dark: 'github-dark' },
},
},

vite: {
plugins: [tailwindcss()],
resolve: {
alias: {
'~': path.resolve(__dirname, './src'),
},
},
},
});
89 changes: 89 additions & 0 deletions apps/web/component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apiVersion: sourceplane.io/v1
kind: Component
metadata:
name: web
description: The AstroWind site (a static Astro + Tailwind CSS build on Cloudflare Workers + Static Assets, per environment)
spec:
type: cloudflare-workers-assets-turbo
lifecycle: production
owner: platform
# Its pages, attached to it in the workspace's catalog: what the Docs
# library shows for it, and what the catalog's docs and runbook checks read.
# Generated from what this manifest and its sources declare.
docs:
overview: docs/overview.md
pages:
- { path: docs/architecture.md, role: architecture, title: Architecture }
- { path: docs/runbook.md, role: runbook, title: Runbook }
# `app`, not `web`: a domain and a component share one name space in the
# catalog, and a domain called `web` hid this component from it.
domain: app
path: apps/web
# Its own lane per environment: the site's build is the longest job in the
# plan, and a shared lane would wait on it.
lane: isolated
subscribe:
environments:
- name: dev
profile: verify
- name: stage
profile: verify
profileRules:
- profile: deploy
when:
triggerRef: github-push-main
- name: prod
profile: verify
profileRules:
- profile: deploy
when:
triggerRef: github-push-main
parameters:
nodeVersion: "22"
pnpmVersion: "10.12.1"

workspaceDir: ../..
appDir: .

turboFilter: "@app/web"
# The config the dry run and the deploy hand to wrangler: the Worker
# (worker/index.ts) and the static build in dist/ as its assets.
# AstroWind builds fully static, so there is no adapter and no generated
# config — this committed file is the one wrangler deploys.
wranglerConfig: wrangler.jsonc

# `astro build` (output: 'static') writes every page, feed, sitemap and
# optimised image to dist/. The Worker is a source file wrangler bundles
# at deploy; the lane checks it exists after the build like any entry.
workerEntrypoint: worker/index.ts
assetsDir: dist

# Per-env worker name: astrowind-web-{dev,stage,prod}.
workerName: astrowind-web
environmentAwareWorkerName: true

# The account's workers.dev subdomain; exported to the smoke step as
# ${WORKERS_DEV_SUBDOMAIN} and used to build ${DEPLOYED_URL}.
workersDevSubdomain: your-workers-subdomain

installCommand: pnpm install --frozen-lockfile
# The site's public origin (canonical links, the sitemap and the RSS feed
# are absolute): the environment's SITE_URL when intent.yaml sets one (a
# custom domain), else its workers.dev URL. The subdomain is written out
# rather than read from ${WORKERS_DEV_SUBDOMAIN}, which the composition
# exports to the smoke step only. ${ORUN_ENVIRONMENT} the runner sets for
# every step. The theme's config builder reads PUBLIC_SITE_URL over
# src/config.yaml's `site:`.
buildCommand: PUBLIC_SITE_URL="${SITE_URL:-https://astrowind-web-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev}" pnpm exec turbo run build --filter=@app/web

# Smoke: the home page carries the template's hero ("Free template for"),
# the blog index lists posts, and an unknown path answers the site's own
# 404 page with a 404 status (served by the assets through the Worker).
# Each response is buffered before grep so an early match cannot SIGPIPE
# curl.
smokeCommand: "html=$(curl -sfL \"${DEPLOYED_URL}/\") && echo \"${html}\" | grep -q 'Free template for' && blog=$(curl -sfL \"${DEPLOYED_URL}/blog\") && echo \"${blog}\" | grep -q '/get-started-website-with-astro-tailwind-css' && test \"$(curl -s -o /dev/null -w '%{http_code}' \"${DEPLOYED_URL}/no-such-page\")\" = 404"
labels:
team: platform
layer: delivery
surface: web
runtime: cloudflare
16 changes: 16 additions & 0 deletions apps/web/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# web — architecture

Built by the turbo pipeline from `apps/web` and deployed with wrangler.

| | |
| ------------------- | ----------------------------------------------- |
| Worker config | `apps/web/wrangler.jsonc` |
| Entry | `./worker/index.ts` |
| Compatibility date | `2026-10-01` |
| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` |

## Bindings

| Binding | Kind | Source |
| -------- | ------------- | -------- |
| `ASSETS` | Static assets | `./dist` |
Loading
Loading