テーマを作る
テーマは React のコンポーネントの集まりです。6 つのコンポーネントを書いて defineTheme に渡すだけで完成します。
最小のテーマ
import { defineTheme } from "@typress/theme-sdk";
export default defineTheme({
manifest: {
id: "com.example.minimal",
displayName: "Minimal",
version: "0.1.0",
entry: "dist/index.js",
},
Layout, Home, Single, Page, Archive, NotFound,
});Layout: 全ページ共通の外枠(site,title,childrenなど)Home: トップ(recentPosts)Single: 投稿(post,terms,commentsなど)Page: 固定ページ(page)Archive: カテゴリ・タグの一覧(term,posts)NotFound: 404
site にはタイトル、ナビ、フォント、CSP 用の nonce などが入っています。コメント欄は SDK の CommentSection をそのまま使えます。
パックと署名
# 鍵を作る(最初の 1 回)
bun tools/tpkg/src/main.ts keygen --label dev
# ビルドしてパック、署名
bun build themes/my-theme/src/index.tsx --target=bun --format=esm \
--outfile=themes/my-theme/dist/index.js
bun tools/tpkg/src/main.ts pack themes/my-theme
bun tools/tpkg/src/main.ts sign themes/my-theme/com.example.minimal-0.1.0.tpkg --key dev~/.typress/keys/dev.pub の中身を管理画面の「信頼済みキー」に登録すると、その .tpkg をインストールできます。
テーマはプラグインと違い、閉じ込めずに本体のプロセスで動きます。