typress
An editorial workshop.日本語

Build a theme

A theme is a set of React components. Write six of them and pass them to defineTheme.

A minimal theme

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: the frame around every page (site, title, children and more)
  • Home: the front page (recentPosts)
  • Single: a post (post, terms, comments and more)
  • Page: a page (page)
  • Archive: a category or tag listing (term, posts)
  • NotFound: 404

site carries the title, navigation, fonts and a CSP nonce. For comments, use the SDK's CommentSection as is.

Pack and sign

# create a key (once)
bun tools/tpkg/src/main.ts keygen --label dev

# build, pack and sign
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

Add the contents of ~/.typress/keys/dev.pub under Trusted keys and the .tpkg can be installed.

Unlike plugins, themes run inside the typress process without the extra lockdown.