Initialize blog scaffold
Add the CLI, site, and sample content so the project can run locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9d2628b318
commit
b78f4b39c9
40 changed files with 9140 additions and 0 deletions
60
frontend/site/src/lib/siteConfig.ts
Normal file
60
frontend/site/src/lib/siteConfig.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import YAML from 'yaml';
|
||||
|
||||
const siteRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../../..');
|
||||
|
||||
type SiteConfig = {
|
||||
site: {
|
||||
title: string;
|
||||
description: string;
|
||||
base_url: string;
|
||||
language: string;
|
||||
timezone: string;
|
||||
};
|
||||
content: {
|
||||
posts_dir: string;
|
||||
assets_dir: string;
|
||||
};
|
||||
build: {
|
||||
astro_project: string;
|
||||
output_dir: string;
|
||||
};
|
||||
};
|
||||
|
||||
const defaults: SiteConfig = {
|
||||
site: {
|
||||
title: 'Osaet',
|
||||
description: 'Personal blog',
|
||||
base_url: 'http://localhost:4321',
|
||||
language: 'zh-CN',
|
||||
timezone: 'Asia/Shanghai'
|
||||
},
|
||||
content: {
|
||||
posts_dir: 'content/posts',
|
||||
assets_dir: 'content/assets'
|
||||
},
|
||||
build: {
|
||||
astro_project: 'frontend/site',
|
||||
output_dir: 'dist/site'
|
||||
}
|
||||
};
|
||||
|
||||
function loadSiteConfig(): SiteConfig {
|
||||
try {
|
||||
const file = readFileSync(resolve(siteRoot, 'config/site.yaml'), 'utf8');
|
||||
const parsed = YAML.parse(file) ?? {};
|
||||
|
||||
return {
|
||||
site: { ...defaults.site, ...parsed.site },
|
||||
content: { ...defaults.content, ...parsed.content },
|
||||
build: { ...defaults.build, ...parsed.build }
|
||||
};
|
||||
} catch {
|
||||
return defaults;
|
||||
}
|
||||
}
|
||||
|
||||
export const siteConfig = loadSiteConfig();
|
||||
export const site = siteConfig.site;
|
||||
Loading…
Add table
Add a link
Reference in a new issue