@horizonwing/engine 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -2
- package/drizzle/pg/schema.ts +100 -0
- package/drizzle/postgres/0000_smooth_princess_powerful.sql +34 -0
- package/drizzle/postgres/0001_colossal_morbius.sql +50 -0
- package/drizzle/postgres/README.md +23 -0
- package/drizzle/postgres/meta/0000_snapshot.json +244 -0
- package/drizzle/postgres/meta/0001_snapshot.json +545 -0
- package/drizzle/postgres/meta/_journal.json +20 -0
- package/drizzle/schema.ts +128 -0
- package/drizzle/sqlite/0000_cooing_jackpot.sql +34 -0
- package/drizzle/sqlite/0001_living_ben_urich.sql +49 -0
- package/drizzle/sqlite/meta/0000_snapshot.json +231 -0
- package/drizzle/sqlite/meta/0001_snapshot.json +554 -0
- package/drizzle/sqlite/meta/_journal.json +20 -0
- package/package.json +80 -4
- package/src/account-pages.tsx +152 -0
- package/src/auth.tsx +265 -0
- package/src/cache.ts +199 -0
- package/src/content.ts +448 -0
- package/src/db.ts +107 -0
- package/src/feeds.ts +376 -0
- package/src/guard.ts +126 -0
- package/src/html.ts +20 -0
- package/src/i18n.ts +304 -0
- package/src/index.ts +27 -0
- package/src/md.ts +278 -0
- package/src/media.ts +70 -0
- package/src/password.ts +59 -0
- package/src/platform.node.ts +98 -0
- package/src/platform.postgres.ts +61 -0
- package/src/platform.shared.ts +114 -0
- package/src/platform.ts +24 -0
- package/src/platform.workers.ts +94 -0
- package/src/ratelimit.ts +144 -0
- package/src/section.ts +123 -0
- package/src/sections/blog/index.tsx +93 -0
- package/src/sections/blog/schema.ts +12 -0
- package/src/sections/blog/views/pages.tsx +167 -0
- package/src/sections/docs/index.tsx +67 -0
- package/src/sections/docs/schema.ts +16 -0
- package/src/sections/docs/views/pages.tsx +181 -0
- package/src/sections/landing/index.tsx +42 -0
- package/src/sections/landing/views/pages.tsx +218 -0
- package/src/seo.ts +193 -0
- package/src/server.ts +122 -0
- package/src/services/content.ts +342 -0
- package/src/turnstile.ts +62 -0
- package/src/types.ts +192 -0
- package/src/views/error.tsx +36 -0
- package/src/views/index.tsx +13 -0
- package/src/views/layout.tsx +89 -0
- package/themes/warm/tokens.css +119 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** @jsxImportSource hono/jsx */
|
|
2
|
+
import type { Child } from 'hono/jsx';
|
|
3
|
+
import { raw } from 'hono/html';
|
|
4
|
+
import { safeJsonForScript } from '../html';
|
|
5
|
+
import { tr, langSwitchHref } from '../i18n';
|
|
6
|
+
import type { LocaleSwitchProps } from '../i18n';
|
|
7
|
+
|
|
8
|
+
export interface LayoutProps {
|
|
9
|
+
/** <html lang> 与 paraglide 文案语言(缺省 zh-CN) */
|
|
10
|
+
lang?: string;
|
|
11
|
+
/** engine/seo buildHead() 产出的 SEO 片段(title/meta/og/twitter) */
|
|
12
|
+
head: string;
|
|
13
|
+
/** JSON-LD 对象列表(构造器已保证「缺数据不输出」,这里只渲染非空项) */
|
|
14
|
+
jsonld?: (object | null)[];
|
|
15
|
+
/** 顶栏站点名 */
|
|
16
|
+
brand?: string;
|
|
17
|
+
/** 页脚文案 */
|
|
18
|
+
footerNote?: string;
|
|
19
|
+
/**
|
|
20
|
+
* M3 语言切换器(i18n.ts localeSwitchProps 构造;单语言/null 不渲染)。
|
|
21
|
+
* 各语言链接走 /lang/:code?next=<当前站内路径>(301 + kit_lang cookie)。
|
|
22
|
+
*/
|
|
23
|
+
localeSwitch?: LocaleSwitchProps | null;
|
|
24
|
+
children: Child;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 站点布局(hono/jsx 服务端组件,零客户端运行时):
|
|
29
|
+
* 系统字体栈、显式 body 背景(防 CLS)、tokens/base 两个样式源。
|
|
30
|
+
* M3:导航随 locale 前缀化(/en/**),文案走 paraglide(tr(locale),零运行时)。
|
|
31
|
+
*/
|
|
32
|
+
export function Layout(props: LayoutProps) {
|
|
33
|
+
const locale = props.lang ?? 'zh-CN';
|
|
34
|
+
const t = tr(locale);
|
|
35
|
+
const locales = props.localeSwitch?.locales ?? [];
|
|
36
|
+
const variant = (path: string): string =>
|
|
37
|
+
locale !== (props.localeSwitch?.locales[0] ?? 'zh-CN') && locales.length > 1 ? `/${locale}${path === '/' ? '' : path}` : path;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
{raw('<!doctype html>\n')}
|
|
42
|
+
<html lang={locale}>
|
|
43
|
+
<head>
|
|
44
|
+
<meta charset="utf-8" />
|
|
45
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
46
|
+
{raw(props.head)}
|
|
47
|
+
<link rel="stylesheet" href="/css/tokens.css" />
|
|
48
|
+
<link rel="stylesheet" href="/css/base.css" />
|
|
49
|
+
{(props.jsonld ?? [])
|
|
50
|
+
.filter((obj): obj is object => obj !== null)
|
|
51
|
+
.map((obj) => (
|
|
52
|
+
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: safeJsonForScript(obj) }} />
|
|
53
|
+
))}
|
|
54
|
+
</head>
|
|
55
|
+
<body>
|
|
56
|
+
<header class="site-header">
|
|
57
|
+
<div class="container header-inner">
|
|
58
|
+
<a class="brand" href={variant('/')}>{props.brand ?? 'Sitkit'}</a>
|
|
59
|
+
<nav class="site-nav" aria-label={t.nav_label()}>
|
|
60
|
+
<a href={variant('/')}>{t.nav_home()}</a>
|
|
61
|
+
<a href={variant('/blog')}>{t.nav_blog()}</a>
|
|
62
|
+
<a href={variant('/docs')}>{t.nav_docs()}</a>
|
|
63
|
+
<a href={variant('/search')}>{t.nav_search()}</a>
|
|
64
|
+
</nav>
|
|
65
|
+
{props.localeSwitch && locales.length > 1 && (
|
|
66
|
+
<nav class="lang-switch" aria-label={t.lang_switch_title()}>
|
|
67
|
+
{locales.map((code) =>
|
|
68
|
+
code === props.localeSwitch?.current ? (
|
|
69
|
+
<span class="lang-current" aria-current="true">{code}</span>
|
|
70
|
+
) : (
|
|
71
|
+
<a href={langSwitchHref(code, props.localeSwitch?.nextPath ?? '/')}>{code}</a>
|
|
72
|
+
),
|
|
73
|
+
)}
|
|
74
|
+
</nav>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
</header>
|
|
78
|
+
{/* data-pagefind-body:搜索索引只收录主内容区(排除导航/页脚/语言切换 chrome) */}
|
|
79
|
+
<main class="site-main" data-pagefind-body>{props.children}</main>
|
|
80
|
+
<footer class="site-footer">
|
|
81
|
+
<div class="container footer-inner">
|
|
82
|
+
<p class="footer-note">{props.footerNote ?? `Sitkit · ${t.footer_note()}`}</p>
|
|
83
|
+
</div>
|
|
84
|
+
</footer>
|
|
85
|
+
</body>
|
|
86
|
+
</html>
|
|
87
|
+
</>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* warm 主题 design tokens(值取自 sitengine DESIGN.md,总设计 §7)
|
|
3
|
+
* 仅 CSS custom properties,无构建、无 Tailwind、无网络字体请求。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
/* ---------------- 色彩:画布与墨 ---------------- */
|
|
8
|
+
--canvas: #faf9f5; /* 奶油底色,页面默认背景 */
|
|
9
|
+
--ink: #141413; /* 暖黑,标题与正文 */
|
|
10
|
+
|
|
11
|
+
/* ---------------- 品牌:珊瑚主色 ---------------- */
|
|
12
|
+
--primary: #cc785c;
|
|
13
|
+
--primary-active: #a9583e;
|
|
14
|
+
/* M4 a11y:主按钮 hover / 链接 hover 的更深层(白字对比 7.0:1,WCAG AA) */
|
|
15
|
+
--primary-deep: #8a4531;
|
|
16
|
+
--primary-disabled: #e6dfd8;
|
|
17
|
+
--on-primary: #ffffff;
|
|
18
|
+
|
|
19
|
+
/* ---------------- 表面 ---------------- */
|
|
20
|
+
--surface-card: #efe9de; /* 内容卡片,比画布深一档 */
|
|
21
|
+
--surface-dark: #181715; /* 代码/页脚等深色面 */
|
|
22
|
+
--on-dark: #faf9f5;
|
|
23
|
+
--on-dark-soft: #a09d96;
|
|
24
|
+
|
|
25
|
+
/* ---------------- 分隔 ---------------- */
|
|
26
|
+
--hairline: #e6dfd8; /* 1px 边框基调 */
|
|
27
|
+
|
|
28
|
+
/* ---------------- 强调 ---------------- */
|
|
29
|
+
--accent-teal: #5db8a6;
|
|
30
|
+
--accent-amber: #e8a55a;
|
|
31
|
+
|
|
32
|
+
/* ---------------- 状态 ---------------- */
|
|
33
|
+
--success: #5db872;
|
|
34
|
+
--warning: #d4a017;
|
|
35
|
+
--error: #c64545;
|
|
36
|
+
|
|
37
|
+
/* ---------------- 文本层级 ---------------- */
|
|
38
|
+
--muted: #6a6862; /* M4 a11y 校正(原 #6c6a64 在卡片面 4.49:1 差 0.01 达不到 AA 4.5:1) */
|
|
39
|
+
--muted-soft: #8e8b82;
|
|
40
|
+
|
|
41
|
+
/* ---------------- 圆角(层级式) ---------------- */
|
|
42
|
+
--rounded-xs: 4px;
|
|
43
|
+
--rounded-sm: 6px;
|
|
44
|
+
--rounded-md: 8px;
|
|
45
|
+
--rounded-lg: 12px;
|
|
46
|
+
--rounded-xl: 16px;
|
|
47
|
+
--rounded-pill: 9999px;
|
|
48
|
+
|
|
49
|
+
/* ---------------- 间距(基准 4px) ---------------- */
|
|
50
|
+
--space-xxs: 4px;
|
|
51
|
+
--space-xs: 8px;
|
|
52
|
+
--space-sm: 12px;
|
|
53
|
+
--space-md: 16px;
|
|
54
|
+
--space-lg: 24px;
|
|
55
|
+
--space-xl: 32px;
|
|
56
|
+
--space-xxl: 48px;
|
|
57
|
+
--space-section: 96px;
|
|
58
|
+
|
|
59
|
+
/* ---------------- 字体栈(全部系统栈,零网络请求) ---------------- */
|
|
60
|
+
--font-serif: 'Tiempos Headline', Garamond, 'Times New Roman', serif;
|
|
61
|
+
--font-sans: Inter, system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
|
|
62
|
+
--font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
63
|
+
|
|
64
|
+
/* ---------------- 字阶:display(serif 400,负字距) ---------------- */
|
|
65
|
+
--text-display-xl-size: 64px;
|
|
66
|
+
--text-display-xl-line: 1.05;
|
|
67
|
+
--text-display-xl-tracking: -1.5px;
|
|
68
|
+
|
|
69
|
+
--text-display-lg-size: 48px;
|
|
70
|
+
--text-display-lg-line: 1.1;
|
|
71
|
+
--text-display-lg-tracking: -1px;
|
|
72
|
+
|
|
73
|
+
--text-display-md-size: 36px;
|
|
74
|
+
--text-display-md-line: 1.15;
|
|
75
|
+
--text-display-md-tracking: -0.5px;
|
|
76
|
+
|
|
77
|
+
--text-display-sm-size: 28px;
|
|
78
|
+
--text-display-sm-line: 1.2;
|
|
79
|
+
--text-display-sm-tracking: -0.3px;
|
|
80
|
+
|
|
81
|
+
/* ---------------- 字阶:title(sans 500) ---------------- */
|
|
82
|
+
--text-title-lg-size: 22px;
|
|
83
|
+
--text-title-lg-line: 1.3;
|
|
84
|
+
|
|
85
|
+
--text-title-md-size: 18px;
|
|
86
|
+
--text-title-md-line: 1.4;
|
|
87
|
+
|
|
88
|
+
--text-title-sm-size: 16px;
|
|
89
|
+
--text-title-sm-line: 1.4;
|
|
90
|
+
|
|
91
|
+
/* ---------------- 字阶:body ---------------- */
|
|
92
|
+
--text-body-md-size: 16px;
|
|
93
|
+
--text-body-md-line: 1.55;
|
|
94
|
+
|
|
95
|
+
--text-body-sm-size: 14px;
|
|
96
|
+
--text-body-sm-line: 1.55;
|
|
97
|
+
|
|
98
|
+
--text-caption-size: 13px;
|
|
99
|
+
--text-caption-line: 1.4;
|
|
100
|
+
|
|
101
|
+
--text-code-size: 14px;
|
|
102
|
+
--text-code-line: 1.6;
|
|
103
|
+
|
|
104
|
+
/* ---------------- 图表系列色(chart island 用,--chart-1..8) ---------------- */
|
|
105
|
+
--chart-1: #cc785c; /* coral 主色 */
|
|
106
|
+
--chart-2: #5db8a6; /* accent teal */
|
|
107
|
+
--chart-3: #e8a55a; /* accent amber */
|
|
108
|
+
--chart-4: #8f7ae5; /* 柔紫(暖调衍生) */
|
|
109
|
+
--chart-5: #5b8fd9; /* 灰蓝(暖调衍生) */
|
|
110
|
+
--chart-6: #d4a017; /* warning 金 */
|
|
111
|
+
--chart-7: #5db872; /* success 绿 */
|
|
112
|
+
--chart-8: #a09d96; /* on-dark-soft 中性 */
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* 显式背景与文字色:首帧即成型,防白闪与 CLS */
|
|
116
|
+
body {
|
|
117
|
+
background-color: var(--canvas);
|
|
118
|
+
color: var(--ink);
|
|
119
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"jsxImportSource": "hono/jsx",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noUncheckedIndexedAccess": true,
|
|
12
|
+
"noFallthroughCasesInSwitch": true,
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"esModuleInterop": true,
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"isolatedModules": true,
|
|
19
|
+
"verbatimModuleSyntax": true,
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"allowJs": true,
|
|
22
|
+
"checkJs": false
|
|
23
|
+
},
|
|
24
|
+
"include": [
|
|
25
|
+
"src/**/*.ts",
|
|
26
|
+
"src/**/*.tsx",
|
|
27
|
+
"drizzle/**/*.ts",
|
|
28
|
+
"test/**/*.ts",
|
|
29
|
+
"vitest.config.ts"
|
|
30
|
+
],
|
|
31
|
+
"exclude": ["node_modules", "dist"]
|
|
32
|
+
}
|