feat: add markdown content pipeline with build script
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
33
src/lib/content.ts
Normal file
33
src/lib/content.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { Language } from './translations';
|
||||
|
||||
export interface ContentMeta {
|
||||
slug: string;
|
||||
title: string;
|
||||
description: string;
|
||||
date: string;
|
||||
tags: string[];
|
||||
order?: number;
|
||||
cover?: string;
|
||||
}
|
||||
|
||||
export interface ContentManifest {
|
||||
en: ContentMeta[];
|
||||
zh: ContentMeta[];
|
||||
}
|
||||
|
||||
export interface ContentItem {
|
||||
meta: ContentMeta;
|
||||
html: string;
|
||||
}
|
||||
|
||||
const BASE = '/content';
|
||||
|
||||
export async function loadManifest(type: 'docs' | 'blog'): Promise<ContentManifest> {
|
||||
const res = await fetch(`${BASE}/${type}-manifest.json`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function loadContent(type: 'docs' | 'blog', lang: Language, slug: string): Promise<ContentItem> {
|
||||
const res = await fetch(`${BASE}/${type}/${lang}/${slug}.json`);
|
||||
return res.json();
|
||||
}
|
||||
Reference in New Issue
Block a user