Note: This page was drafted by Claude.
The files I edit are not the files a visitor downloads. I edit source files, Astro builds them into plain web files, and Cloudflare serves those. Browsers only understand three languages: HTML for content, CSS for looks and JavaScript for behavior. Everything else in the project exists to produce those three.
The build runs on my computer when I preview the site, and on Cloudflare after every push to GitHub. The dashed lines are files that are passed along without being changed.
None in the source code, but the finished site has one. What the source does have is TypeScript (.ts) files: the Taipan game in src/lib/taipan/, the helper that lists blog posts in src/lib/posts.ts, and the blog settings in src/content.config.ts.
TypeScript is JavaScript with type labels added, such as "this is a date" or "this is text". The labels let mistakes get caught before anything goes live. Browsers cannot run TypeScript, so the build removes the labels and outputs plain JavaScript.
The one .js file in the finished site is the Taipan game. It is the only page that needs code running in the visitor's browser. Every other page arrives as finished HTML. Two tiny scripts for the light and dark theme button are also written directly into the shared layout.
astro.config.mjs is JavaScript too (.mjs means a modern JavaScript module), but it holds settings for the build and is not part of the site.
A .astro file is a template: HTML with a small code section at the top, fenced off by --- lines. This is a shortened version of the Projects page:
---
// Code: runs during the build only
import Base from '../layouts/Base.astro';
---
<!-- HTML: becomes the page -->
<Base title="Projects">
<h1>Projects</h1>
...
</Base>
<!-- CSS for this page only -->
<style> .soon { ... } </style>Three ideas cover almost everything:
.astro file can use another like a custom tag. <Base> is the shared layout with the header, theme button and footer, and every page wraps itself in it, so a change to the layout appears everywhere. The three-model comparison block on the video experiment pages is a smaller reusable component.src/pages/ is a page.| File | URL |
|---|---|
src/pages/index.astro | / |
src/pages/projects.astro | /projects/ |
src/pages/gaming/taipan.astro | /gaming/taipan/ |
src/pages/blog/[slug].astro | /blog/<each post>/ |
The square brackets in [slug] mean "one page per item". Blog posts are plain Markdown files in src/content/blog/. src/content.config.ts says what every post must have (a title, a date and a description), and the [slug] page turns each post into its own page named after the file. Files whose names start with an underscore are skipped as pages and only pulled into other pages.
public/: copied into the site as it is: the favicon, the resume PDFs and the archived old site.src/assets/: images the build optimizes. The profile photo goes from a 57 KB JPEG to a 9 KB WebP.src/styles/global.css: the styling shared by every page.node_modules/: the toolbox. Astro, Wrangler and everything they depend on, about 11,000 files. It is not part of the site, and Git does not track it.package.json and package-lock.json: the list of tools the project needs, and their exact pinned versions, so every install is identical.dist/: the build output, regenerated every time. Git does not track it either.Wrangler is Cloudflare's command-line tool, and wrangler.jsonc is its settings file. The settings that matter are a few lines:
// The Cloudflare Worker that hosts the site
"name": "danielwakabayashi-com",
"assets": {
// Serve the files Astro built
"directory": "./dist",
// Unknown URLs get the 404 page
"not_found_handling": "404-page"
}When I push to GitHub, Cloudflare's build service pulls the code, installs the tools, runs the Astro build and uses Wrangler with these settings to upload dist/. After that, a visitor's request is answered with the matching pre-built file from a Cloudflare server near them.
So Wrangler mostly works behind the scenes and I never run it myself. I would run it by hand to deploy without pushing, to preview the site exactly as Cloudflare serves it, or later to add server features such as a database.
src/pages/projects.astro and preview it with astro dev, which rebuilds pages as I save.astro build, which writes dist/projects/index.html: plain HTML with the shared header and footer already filled in.dist/, and a minute later the new page is live at /projects/.