feat: scaffold Astro project replacing Gatsby

- Remove gatsby-config.js, yarn.lock, src/gatsby-theme-blog/
- Create package.json with astro, @astrojs/mdx, @astrojs/rss deps
- Create astro.config.mjs with site/base for GitHub Pages
- Create tsconfig.json extending astro/tsconfigs/strict
- Create src/env.d.ts with astro/client reference
- Create minimal src/pages/index.astro placeholder
- Update .gitignore: replace gatsby section with astro (dist/, .astro/)
- Add scaffold verification tests
- Verified: npm run build succeeds with output in dist/
This commit is contained in:
Ken
2026-05-26 22:32:22 +00:00
parent c36c48b684
commit cf0c07f2a9
12 changed files with 6561 additions and 13183 deletions
+3 -3
View File
@@ -54,9 +54,9 @@ typings/
# dotenv environment variables file # dotenv environment variables file
.env .env
# gatsby files # astro
.cache/ dist/
public .astro/
# Mac files # Mac files
.DS_Store .DS_Store
+10
View File
@@ -0,0 +1,10 @@
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
export default defineConfig({
site: 'https://kenotron.github.io',
base: '/crashtestdev',
integrations: [
mdx(),
],
});
-24
View File
@@ -1,24 +0,0 @@
module.exports = {
plugins: [
{
resolve: `gatsby-theme-blog`,
options: {},
},
],
// Customize your site metadata:
siteMetadata: {
title: `Crash Test Dev`,
author: `Ken Chau`,
description: `Why do I need a description. For a site. The site IS a description.`,
social: [
{
name: `twitter`,
url: `https://twitter.com/kenneth_chau`,
},
{
name: `github`,
url: `https://github.com/kenotron`,
},
],
},
}
+6404
View File
File diff suppressed because it is too large Load Diff
+11 -9
View File
@@ -2,17 +2,19 @@
"name": "crashtestdev", "name": "crashtestdev",
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.1",
"type": "module",
"scripts": { "scripts": {
"develop": "gatsby develop", "dev": "astro dev",
"start": "gatsby develop", "start": "astro dev",
"build": "gatsby build" "build": "astro build",
"preview": "astro preview"
}, },
"dependencies": { "dependencies": {
"gatsby": "^2.13.65", "astro": "^5.8.0",
"gatsby-plugin-emotion": "^4.1.2", "@astrojs/mdx": "^4.3.0",
"gatsby-plugin-mdx": "^1.0.24", "@astrojs/rss": "^4.0.0"
"gatsby-theme-blog": "^1.0.2", },
"react": "^16.9.0", "devDependencies": {
"react-dom": "^16.9.0" "typescript": "^5.8.0"
} }
} }
+1
View File
@@ -0,0 +1 @@
/// <reference types="astro/client" />
@@ -1,7 +0,0 @@
import React, { Fragment } from "react"
/**
* Change the content to add your own bio
*/
export default () => <Fragment>Ken Chau</Fragment>
@@ -1,25 +0,0 @@
import merge from "deepmerge"
import defaultThemeColors from "gatsby-theme-blog/src/gatsby-plugin-theme-ui/colors"
/*
* Want to change your theme colors?
* Try uncommenting the color overrides below
* to go from default purple to a blue theme
*/
const darkBlue = `#007acc`
const lightBlue = `#66E0FF`
const blueGray = `#282c35`
export default merge(defaultThemeColors, {
text: blueGray,
primary: darkBlue,
heading: blueGray,
modes: {
dark: {
background: blueGray,
primary: lightBlue,
highlight: lightBlue,
},
},
})
+14
View File
@@ -0,0 +1,14 @@
---
---
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Crash Test Dev</title>
</head>
<body>
<h1>Crash Test Dev</h1>
<p>Blog by Ken Chau</p>
</body>
</html>
+115
View File
@@ -0,0 +1,115 @@
/**
* Verification test for Astro scaffold (Task 1)
*
* Checks that:
* 1. Gatsby files are removed
* 2. Astro config files exist with correct content
* 3. package.json has correct dependencies
* 4. .gitignore is updated for Astro
* 5. Build output exists in dist/
*/
import { readFileSync, existsSync, statSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const root = join(__dirname, '..');
let passed = 0;
let failed = 0;
function assert(condition, message) {
if (condition) {
console.log(`${message}`);
passed++;
} else {
console.error(`${message}`);
failed++;
}
}
function readJSON(path) {
return JSON.parse(readFileSync(path, 'utf8'));
}
function readText(path) {
return readFileSync(path, 'utf8');
}
// === 1. Gatsby files removed ===
console.log('\n1. Gatsby files removed');
assert(!existsSync(join(root, 'gatsby-config.js')), 'gatsby-config.js removed');
assert(!existsSync(join(root, 'yarn.lock')), 'yarn.lock removed');
assert(!existsSync(join(root, 'src/gatsby-theme-blog')), 'src/gatsby-theme-blog/ removed');
// === 2. package.json correct ===
console.log('\n2. package.json');
const pkgPath = join(root, 'package.json');
assert(existsSync(pkgPath), 'package.json exists');
if (existsSync(pkgPath)) {
const pkg = readJSON(pkgPath);
assert(pkg.dependencies && pkg.dependencies['astro'], 'astro in dependencies');
assert(pkg.dependencies && pkg.dependencies['@astrojs/mdx'], '@astrojs/mdx in dependencies');
assert(pkg.dependencies && pkg.dependencies['@astrojs/rss'], '@astrojs/rss in dependencies');
assert(pkg.devDependencies && pkg.devDependencies['typescript'], 'typescript in devDependencies');
assert(!pkg.dependencies || !pkg.dependencies['gatsby'], 'gatsby NOT in dependencies');
assert(pkg.scripts && pkg.scripts.build, 'build script exists');
assert(pkg.scripts && pkg.scripts.dev, 'dev script exists');
}
// === 3. astro.config.mjs ===
console.log('\n3. astro.config.mjs');
const astroConfigPath = join(root, 'astro.config.mjs');
assert(existsSync(astroConfigPath), 'astro.config.mjs exists');
if (existsSync(astroConfigPath)) {
const config = readText(astroConfigPath);
assert(config.includes("site:") || config.includes("site :") || config.includes("'https://kenotron.github.io'") || config.includes('"https://kenotron.github.io"'), 'site is https://kenotron.github.io');
assert(config.includes("base:") || config.includes("base :") || config.includes("'/crashtestdev'") || config.includes('"/crashtestdev"'), 'base is /crashtestdev');
assert(config.includes('@astrojs/mdx'), 'mdx integration referenced');
}
// === 4. tsconfig.json ===
console.log('\n4. tsconfig.json');
const tsconfigPath = join(root, 'tsconfig.json');
assert(existsSync(tsconfigPath), 'tsconfig.json exists');
if (existsSync(tsconfigPath)) {
const tsconfig = readJSON(tsconfigPath);
assert(tsconfig.extends === 'astro/tsconfigs/strict', 'extends astro/tsconfigs/strict');
}
// === 5. src/env.d.ts ===
console.log('\n5. src/env.d.ts');
const envDtsPath = join(root, 'src/env.d.ts');
assert(existsSync(envDtsPath), 'src/env.d.ts exists');
if (existsSync(envDtsPath)) {
const envDts = readText(envDtsPath);
assert(envDts.includes('astro/client'), 'references astro/client');
}
// === 6. .gitignore updated ===
console.log('\n6. .gitignore');
const gitignorePath = join(root, '.gitignore');
assert(existsSync(gitignorePath), '.gitignore exists');
if (existsSync(gitignorePath)) {
const gitignore = readText(gitignorePath);
assert(gitignore.includes('dist/'), 'dist/ in .gitignore');
assert(gitignore.includes('.astro/'), '.astro/ in .gitignore');
assert(!gitignore.includes('# gatsby'), 'no gatsby section in .gitignore');
}
// === 7. Placeholder page ===
console.log('\n7. Placeholder page');
assert(existsSync(join(root, 'src/pages/index.astro')), 'src/pages/index.astro exists');
// === 8. Build output ===
console.log('\n8. Build output');
assert(existsSync(join(root, 'dist')), 'dist/ directory exists');
// === Summary ===
console.log(`\n${'='.repeat(40)}`);
console.log(`Results: ${passed} passed, ${failed} failed out of ${passed + failed}`);
if (failed > 0) {
process.exit(1);
} else {
console.log('All scaffold verification tests passed!');
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/strict"
}
-13115
View File
File diff suppressed because it is too large Load Diff