中文 | English
智能编排 Cogita 主题驱动架构的核心引擎
@cogita/core 是 Cogita 框架的大脑。它自动加载主题、管理插件,并提供类型安全的配置系统,让构建博客就像选择主题一样简单。
- 🎨 主题驱动:主题自动加载所需的插件
- ⚙️ 类型安全:完整的 TypeScript 支持和智能默认值
- 🔧 零配置:开箱即用,需要时可自定义
- ⚡ Rspress 驱动:基于快速现代的 Rspress 基础
pnpm add @cogita/core @cogita/theme-lucid创建 cogita.config.ts:
import { defineConfig } from '@cogita/core';
export default defineConfig({
site: {
title: '我的博客',
description: '使用 Cogita 构建的博客',
},
theme: 'lucid', // 主题处理其他一切!
});在 posts/hello.md 中创建第一篇文章:
---
title: "你好,Cogita!"
createDate: "2024-01-01"
---
# 欢迎来到我的博客!启动开发服务器:
pnpm dev就这样!你的博客已经在 http://localhost:3000 准备好了。
- 加载配置:读取你的
cogita.config.ts - 加载主题:自动加载指定的主题
- 注册插件:主题声明其插件依赖
- 生成配置:创建优化的 Rspress 配置
- 构建/服务:使用 Rspress 为你的博客提供动力
export default defineConfig({
site: {
title: '我的博客', // 站点标题
description: '我的精彩博客', // 元描述
base: '/blog/', // 基础 URL(子路径)
},
theme: 'lucid', // 主题名称
});export default defineConfig({
site: { /* ... */ },
theme: 'lucid',
// 透传给 Rspress 主题配置
themeConfig: {
nav: [
{ text: '首页', link: '/' },
{ text: '关于', link: '/about' },
],
socialLinks: [
{ icon: 'github', mode: 'link', content: 'https://github.com/you' }
],
},
// 透传给 Rspress 构建配置
builderConfig: {
output: { assetPrefix: 'https://cdn.example.com/' }
},
});类型安全的配置助手。
从项目目录加载配置。
interface CogitaConfig {
site?: {
title?: string;
description?: string;
base?: string;
};
theme?: string;
themeConfig?: any; // Rspress 主题配置
builderConfig?: any; // Rspress 构建配置
}lucid(默认)- 简洁、专注内容的博客主题- 更多主题即将推出...
# 开发
pnpm dev
# 构建
pnpm build
# 预览构建结果
pnpm preview- 🚀 @cogita/cli - 命令行界面
- 🎨 @cogita/ui - UI 组件库
- 🌟 @cogita/theme-lucid - 默认主题
MIT © wu9o