Simple conetent + restyled

This commit is contained in:
2026-09-21 17:59:29 +02:00
parent 0772462742
commit 467bf77d34
55 changed files with 2162 additions and 2070 deletions
+2 -1
View File
@@ -4,8 +4,9 @@
// URLs, mailto:, data: and pure-#fragment links are out of scope.
import { readdirSync, readFileSync, existsSync, statSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
const DIST = new URL('../dist', import.meta.url).pathname;
const DIST = fileURLToPath(new URL('../dist', import.meta.url));
if (!existsSync(DIST)) { console.error('dist/ not found — run `npm run build` first'); process.exit(1); }
const htmlFiles = [];
+34
View File
@@ -0,0 +1,34 @@
// Copy the four editable files into Astro's ignored content directory.
// --ensure seeds only a fresh checkout; an incomplete existing set fails loudly.
import { cpSync, existsSync, mkdirSync, readFileSync } from 'node:fs';
import { resolve, join } from 'node:path';
import { fileURLToPath } from 'node:url';
const root = fileURLToPath(new URL('../', import.meta.url));
const examples = JSON.parse(readFileSync(join(root, 'src/data/examples.json'), 'utf8'));
const ensure = process.argv.includes('--ensure');
const source = resolve(process.argv[2] && !ensure ? process.argv[2] : join(root, 'sample-content'));
const pages = join(root, 'src/content/pages');
const uploads = join(root, 'public/uploads');
function validate(directory) {
for (const { slug } of examples) {
if (!existsSync(join(directory, `${slug}.md`))) {
throw new Error(`Missing ${join(directory, `${slug}.md`)}. Run npm run content:setup or npm run content:sync -- <content-clone>.`);
}
}
}
if (ensure && existsSync(pages)) {
validate(pages);
} else {
validate(join(source, 'pages'));
if (!existsSync(join(source, 'uploads'))) throw new Error(`Missing uploads directory in ${source}`);
mkdirSync(pages, { recursive: true });
mkdirSync(uploads, { recursive: true });
for (const { slug } of examples) {
cpSync(join(source, 'pages', `${slug}.md`), join(pages, `${slug}.md`));
}
cpSync(join(source, 'uploads'), uploads, { recursive: true });
console.log(`Example content copied from ${source}`);
}
+2 -12
View File
@@ -1,17 +1,7 @@
#!/usr/bin/env bash
# Local dev: put the content repo's files where the build expects them.
# Usage: ./scripts/link-content.sh [path-to-content-clone] (default ../ctao-content)
# Copies (not symlinks) so the dev tree behaves exactly like the machine
# build overlay; re-run after pulling content changes.
# Cross-platform implementation is shared with npm run content:sync.
set -euo pipefail
cd "$(dirname "$0")/.."
src="${1:-../ctao-content}"
for d in news pages uploads; do
[ -d "$src/$d" ] || { echo "content clone incomplete: $src/$d missing (git clone <gitea>/ctao/content.git first)"; exit 1; }
done
rm -rf src/content/news src/content/pages public/uploads
mkdir -p src/content public
cp -a "$src/news" src/content/news
cp -a "$src/pages" src/content/pages
cp -a "$src/uploads" public/uploads
echo "content linked from $src"
node scripts/content.mjs "${1:-../ctao-content}"
+19
View File
@@ -0,0 +1,19 @@
// Prepare a disposable content repository for Sveltia's local folder picker.
import { cpSync, existsSync, mkdirSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { join } from 'node:path';
const root = fileURLToPath(new URL('../', import.meta.url));
const local = join(root, '.tmp/content');
if (!existsSync(local)) {
mkdirSync(local, { recursive: true });
cpSync(join(root, 'sample-content/pages'), join(local, 'pages'), { recursive: true });
cpSync(join(root, 'sample-content/uploads'), join(local, 'uploads'), { recursive: true });
}
if (!existsSync(join(local, '.git'))) {
execFileSync('git', ['init', '--quiet', '--initial-branch=simple', local], { stdio: 'inherit' });
}
execFileSync(process.execPath, [join(root, 'scripts/content.mjs'), local], { stdio: 'inherit' });
console.log(`In Sveltia, choose Work with Local Repository and select: ${local}`);
console.log('After saving, run: npm run content:sync -- .tmp/content');
+13
View File
@@ -0,0 +1,13 @@
// Derive editor body styles from the mockup CSS so the preview cannot drift.
import { readFileSync, writeFileSync } from 'node:fs';
const css = readFileSync(new URL('../src/styles/global.css', import.meta.url), 'utf8');
const base = css.slice(0, css.indexOf('/* Utilities'));
const prose = css.slice(css.indexOf('/* Prose'), css.indexOf('/* Footer'));
const markdown = css.slice(css.indexOf('.prose { overflow-wrap:'), css.indexOf('.submenu a[aria-current="page"]'));
const preview = (base + prose + markdown).replace(/\.prose\b/g, 'body');
writeFileSync(new URL('../public/admin/preview.css', import.meta.url),
'/* Generated by scripts/preview-styles.mjs; edit src/styles/global.css. */\n' + preview + `
body { display: block; min-height: 0; max-width: 64rem; margin: 0 auto; padding: 1.5rem; }
h1 { color: var(--galaxy-blue); font-family: var(--font-head); font-weight: 500; line-height: 1.05; }
`);