feat: 创建 VitePress 文档与 mjml 邮件模板编译流程
docs 目录包含一个 VitePress 构建的静态文档站点。 mjml 目录包含 HTML 邮件模板。这些模板将被编译为 Jinja2 模板,然后由 NyaHome 动态渲染后发送。
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import {defineConfig} from 'vitepress'
|
||||
|
||||
// https://vitepress.dev/reference/site-config
|
||||
export default defineConfig({
|
||||
title: "NyaHome",
|
||||
description: "自托管 AI 创作聊天室平台",
|
||||
themeConfig: {
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
nav: [
|
||||
{text: '主页', link: '/'},
|
||||
{text: '使用', link: '/use/start'}
|
||||
],
|
||||
|
||||
sidebar: [
|
||||
{
|
||||
text: '使用',
|
||||
items: [
|
||||
{text: '开始', link: '/use/start'},
|
||||
{text: '默认行为', link: '/use/default-action'},
|
||||
{text: '用户系统', link: '/use/user-system'},
|
||||
]
|
||||
},
|
||||
{
|
||||
text: '开发',
|
||||
items: [
|
||||
{text: '后端响应', link: '/dev/backend-response'},
|
||||
]
|
||||
},
|
||||
],
|
||||
|
||||
socialLinks: [
|
||||
{icon: 'github', link: 'https://github.com/vuejs/vitepress'}
|
||||
]
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
:root {
|
||||
--vp-c-brand-1: #64ffc4;
|
||||
--vp-c-brand-2: #9354ff;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import DefaultTheme from 'vitepress/theme'
|
||||
// @ts-ignore
|
||||
import './custom.css'
|
||||
|
||||
export default DefaultTheme
|
||||
@@ -0,0 +1,25 @@
|
||||
# 邮件模板
|
||||
|
||||
NyaHome 希望发送 HTML 邮件,但是用于邮件的 HTML 在 2026 年依然是重灾区。因此,NyaHome 决定采用 mjml 配合 Jinja2 制作并渲染邮件模板。
|
||||
|
||||
## 有关工作流程
|
||||
|
||||
项目根目录下的 `mjml` 内是 mjml 源文件。这是一种类 xaml 格式的文件,采用独特的语法像编写 HTML 一样编写用于邮件的……也是
|
||||
HTML。
|
||||
|
||||
通过以下命令,这些 mjml 源文件将会被编译为 j2 源文件,也就是 Jinja2 的模板文件。
|
||||
|
||||
```bash
|
||||
pnpm mjml mjml/filename.mjml -o public/templates/filename.j2
|
||||
```
|
||||
|
||||
Jinja2 在 NyaHome 进程中读取模板,渲染变量,然后由 aiosmptplib 发送渲染好的 HTML 邮件。
|
||||
|
||||
## 在 PyCharm 中预览 mjml 源文件
|
||||
|
||||
使用 **MJML Support** 插件以支持 mjml 源文件的语法高亮、智能补全和实时预览。
|
||||
|
||||
:::warning
|
||||
MJML Support 插件不支持 JetBrains 远程开发。在远程开发(包括使用 Gateway 进行 WSL 开发)中,IDE client 无法对 mjml
|
||||
源文件进行实时预览。
|
||||
:::
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
# https://vitepress.dev/reference/default-theme-home-page
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "NyaHome"
|
||||
text: "自托管 AI 创作聊天室平台"
|
||||
tagline: 本地创作 | 在线酒馆
|
||||
actions:
|
||||
- theme: brand
|
||||
text: 开始部署
|
||||
link: /use/start
|
||||
- theme: alt
|
||||
text: 开发
|
||||
link: /dev/start
|
||||
|
||||
features:
|
||||
- title: Feature A
|
||||
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||
- title: Feature B
|
||||
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||
- title: Feature C
|
||||
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user