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
34 changes: 34 additions & 0 deletions .vscode/astro-paper.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"Frontmatter": {
"scope": "markdown",
"prefix": "frontmatter",
"body": [
"---",
"author: $1",
"pubDatetime: $CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}T$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND.000$CURRENT_TIMEZONE_OFFSET",
"modDatetime: $3",
"title: $4",
"featured: ${5|false,true|}",
"draft: ${6|true,false|}",
"tags:",
" - $7",
"description: $8",
"---",
],
"description": "Adds the frontmatter block for a blog post",
},
"Blog Template": {
"scope": "markdown",
"prefix": "template",
"body": [
"${1:frontmatter}",
"",
"${2: Introductory Sentence}",
"",
"## Table of contents",
"",
"## ${3: heading 1}",
],
"description": "Adds the template for a blog post. You will need to trigger the snippet modal on the 'frontmatter' line to insert the other snipper.",
},
}
76 changes: 68 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,70 @@
# astro-paper

[Vercel's AstroPaper template](https://github.com/satnaing/astro-paper) 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 [AstroPaper](https://github.com/satnaing/astro-paper) template — a
minimal, responsive, accessible and SEO-friendly Astro blog theme: posts in
Markdown and MDX with tags, archives and pagination, full-text search with
Pagefind, a dynamic Open Graph image for the site and for every post, light
and dark mode, 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 (AP2).

AstroPaper builds fully static: `astro build` writes every page, post, tag
page, feed, sitemap and Open Graph image (satori and sharp, at build time) to
`dist/`, and Pagefind indexes the built pages into `dist/pagefind`. That
folder is uploaded as Workers Static Assets with one small Worker in front
for what matches no file; no adapter and no server code. The pages, the
posts, the search and the theme do not change; the site's name moves into
one module, and each deploy builds for its own origin.
See [`specs/epics/astro-paper`](specs/epics/astro-paper/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, every page's title, the OG image, the feed) | `apps/web/src/site.ts` |
| The theme's configuration (description, author, features, socials, share links) | `apps/web/astro-paper.config.ts` |
| Posts and the about page | `apps/web/src/content/posts`, `apps/web/src/content/pages` |
| Pages, layouts, components, the OG image routes | `apps/web/src/pages`, `apps/web/src/layouts`, `apps/web/src/components` |
| The Worker in front of the assets, 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 # eslint
pnpm test # vitest over Astro's container API
pnpm build # astro build + pagefind → apps/web/dist
```

```bash
pnpm --filter @app/web dev # http://localhost:4321 (search needs one build first)
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`) |
| The template's build (`astro check && astro build && pagefind --site dist`) | Unchanged but for `astro check`, which runs as the `typecheck` step: `astro build`, then Pagefind into `dist/pagefind`, then the index copied to `public/` for `astro dev` |
| Open Graph images rendered by satori + sharp at build time | Unchanged: `/og.png` and each post's `index.png` are files in `dist/` |
| Directory URLs (`/posts/<slug>/`), as the theme's own Cloudflare Pages demo serves them | `assets.html_handling: auto-trailing-slash` — `/about/` serves `about/index.html`, `/about` redirects to it |
| The host'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`) |
| `site.url: https://astro-paper.pages.dev/` | Each deploy builds for its own origin — the environment's `SITE_URL`, else its workers.dev URL — so canonical and Open Graph links, the sitemap, robots.txt and the RSS feed name the site where it is served; `astro-paper.config.ts`'s `site.url` 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 [satnaing/astro-paper](https://github.com/satnaing/astro-paper)
by Sat Naing (MIT — `apps/web/LICENSE`), at `35cfa7f` (v6.1.0 and one fix).
6 changes: 6 additions & 0 deletions apps/web/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# The site reads one optional variable: PUBLIC_GOOGLE_SITE_VERIFICATION, the
# Google Search Console verification code (astro.config.ts's env schema; or
# set `site.googleVerification` in astro-paper.config.ts). Its name is
# src/site.ts, and everything else it is configured with is
# astro-paper.config.ts. A deploy sets PUBLIC_SITE_URL itself (component.yaml).
# PUBLIC_GOOGLE_SITE_VERIFICATION=
17 changes: 17 additions & 0 deletions apps/web/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Ignore everything
/*

# Except these files & folders
!/src
!/public
!/.github
!tsconfig.json
!astro.config.ts
!package.json
!.prettierrc
!eslint.config.js
!README.md
!.vscode

# Ignore MDX files
*.mdx
20 changes: 20 additions & 0 deletions apps/web/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"arrowParens": "avoid",
"semi": true,
"tabWidth": 2,
"printWidth": 80,
"singleQuote": false,
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"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) 2023 Sat Naing

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

A blog on Sat Naing's Astro theme
([satnaing/astro-paper](https://github.com/satnaing/astro-paper), MIT) —
Astro 7 and Tailwind CSS 4 — built fully static and served as Cloudflare
Workers Static Assets:

- `/` (the featured and recent posts), `/about/`, `/archives/`, `/search/`
- the posts: `/posts/` (paginated: `/posts/2/` …), a page per post
(`src/content/posts/**/*.md|mdx`) with its own Open Graph image
(`/posts/<slug>/index.png`), `/tags/` and `/tags/<tag>/`
- `/rss.xml`, `/sitemap-index.xml`, `/robots.txt`, the site's Open Graph
image `/og.png`, and the Pagefind search index under `/pagefind/`

The site's name — the header, every page's title, the Open Graph image and
the feed — is `src/site.ts`. Its description, author, timezone, features,
socials and share links are `astro-paper.config.ts`; the about page is
`src/content/pages/about.md`; colours and typography are `src/styles/`.

```bash
pnpm dev # astro dev on http://localhost:4321 (search needs one build first)
pnpm test # vitest over Astro's container API (src/test)
pnpm build # astro build + pagefind → dist/ (and the index copied to public/ for dev)
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. Pages are directories: `/about` redirects to `/about/`.

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

export default defineAstroPaperConfig({
site: {
// The origin a local build links to. A deploy builds for its own
// environment's origin instead: astro.config.ts takes PUBLIC_SITE_URL
// over this, and the rest of the site reads Astro's resolved `site`.
url: "https://astro-paper.example.com/",
title: SITE_NAME,
description: "A minimal, responsive and SEO-friendly Astro blog theme.",
author: "Sat Naing",
profile: "https://satna.ing",
ogImage: "default-og.jpg",
lang: "en",
timezone: "Asia/Bangkok",
dir: "ltr",
},
posts: {
perPage: 4,
perIndex: 4,
scheduledPostMargin: 15 * 60 * 1000,
},
features: {
lightAndDarkMode: true,
dynamicOgImage: true,
showArchives: true,
showBackButton: true,
editPost: {
enabled: true,
url: "https://github.com/sourceplane/astro-paper/edit/main/apps/web/",
},
search: "pagefind",
},
socials: [
{ name: "github", url: "https://github.com/sourceplane/astro-paper" },
{ name: "x", url: "https://x.com/username" },
{ name: "linkedin", url: "https://www.linkedin.com/in/username/" },
{ name: "mail", url: "mailto:yourmail@gmail.com" },
],
shareLinks: [
{ name: "whatsapp", url: "https://wa.me/?text=" },
{ name: "facebook", url: "https://www.facebook.com/sharer.php?u=" },
{ name: "x", url: "https://x.com/intent/post?url=" },
{ name: "telegram", url: "https://t.me/share/url?url=" },
{ name: "pinterest", url: "https://pinterest.com/pin/create/button/?url=" },
{ name: "mail", url: "mailto:?subject=See%20this%20post&body=" },
],
});
89 changes: 89 additions & 0 deletions apps/web/astro.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import {
defineConfig,
envField,
fontProviders,
svgoOptimizer,
} from "astro/config";
import tailwindcss from "@tailwindcss/vite";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import { unified } from "@astrojs/markdown-remark";
import remarkToc from "remark-toc";
import remarkCollapse from "remark-collapse";
import rehypeCallouts from "rehype-callouts";
import {
transformerNotationDiff,
transformerNotationHighlight,
transformerNotationWordHighlight,
} from "@shikijs/transformers";
import { transformerFileName } from "./src/utils/transformers/fileName";
import config from "./astro-paper.config";

export default defineConfig({
// The site's public origin — canonical and Open Graph links, the sitemap and
// the RSS feed are absolute. A deploy sets PUBLIC_SITE_URL to its
// environment's (its SITE_URL, else its workers.dev URL); a local build
// uses astro-paper.config.ts's. src/config.ts reads the result back as
// `import.meta.env.SITE`.
site: process.env.PUBLIC_SITE_URL || config.site.url,
integrations: [
mdx(),
sitemap({
filter: page =>
config.features?.showArchives !== false || !page.endsWith("/archives/"),
}),
],
i18n: {
locales: ["en"],
defaultLocale: "en",
routing: {
prefixDefaultLocale: false,
},
},
markdown: {
processor: unified({
remarkPlugins: [
remarkToc,
[remarkCollapse, { test: "Table of contents" }],
],
rehypePlugins: [rehypeCallouts],
}),
shikiConfig: {
themes: { light: "min-light", dark: "night-owl" },
defaultColor: false,
wrap: false,
transformers: [
transformerFileName({ style: "v2", hideDot: false }),
transformerNotationHighlight(),
transformerNotationWordHighlight(),
transformerNotationDiff({ matchAlgorithm: "v3" }),
],
},
},
vite: {
plugins: [tailwindcss()],
},
fonts: [
{
name: "Google Sans Code",
cssVariable: "--font-google-sans-code",
provider: fontProviders.google(),
fallbacks: ["monospace"],
weights: [300, 400, 500, 600, 700],
styles: ["normal", "italic"],
formats: ["woff", "ttf"],
},
],
env: {
schema: {
PUBLIC_GOOGLE_SITE_VERIFICATION: envField.string({
access: "public",
context: "client",
optional: true,
}),
},
},
experimental: {
svgOptimizer: svgoOptimizer(),
},
});
Loading
Loading