中文: README.zh.md
The theme package is an open-source Blocklet-oriented theme development framework for building, previewing, and packaging GLofter-style public-site themes (minimal, magazine, …). Everything you need ships in this repo: a ThemeShell preview UI, mock APIs under api/, and build scripts for distributable theme artifacts—no private Studio tree is required to start from Minimal.
- Public mirror (if forked): https://github.com/shenxiuqiang/glofter-theme
- Live preview —
blocklet dev+ Vite client; themes load viagetThemeByIdfromsrc/core/themes.ts. - Mock public data —
theme/api/mock-data/*.jsonandtheme/api/src/routes/mock-theme.tsapproximate Studio public endpoints when no upstream Studio URL is configured. - Per-theme builds —
pnpm minimal/pnpm magazinerunscripts/build-theme.mjs(output underbuild/and packaged zips underpackage/per script). - Blocklet lifecycle —
bundle,deploy,uploadscripts for the Theme blocklet itself (seepackage.json).
- Node.js 24.
- pnpm (this repo’s root when cloned standalone).
From the repository root of this project (standalone clone = project root):
pnpm install # first time or after dependency changes
pnpm dev # typecheck + blocklet dev: ThemeShell preview + mock APILint, per-theme builds, etc. (still from this repo root):
pnpm dev # same as above: preview + mock API
pnpm lint # tsc --noEmit + eslint (src + api/src)
pnpm minimal # build-theme.mjs minimal
pnpm magazine # build-theme.mjs magazine
pnpm magazine:local # example: build magazine + copy into local Studio data/themes (machine-specific path in script)
pnpm theme:check # alias for lintThere is no theme:build script; use minimal / magazine, or extend scripts/build-theme.mjs for new theme ids. Blocklet packaging and release: see bundle, deploy, and upload in package.json.
| Path | Purpose |
|---|---|
src/core/themes.ts |
Theme registry for preview: themes, getThemeById, default theme. |
src/themes/<id>/ |
Theme source (minimal, magazine, …): index.tsx, pages/, components/, options.schema.json, locale files. |
api/mock-data/ |
JSON fixtures for albums, photographers, services, videos, etc. |
api/src/routes/mock-theme.ts |
Express routes that serve mock data or proxy to a real Studio when configured. |
scripts/build-theme.mjs |
Packages a theme id into build/<id>-<version>/ and zip under package/. |
Per-theme developer docs:
- Minimal — README.md (English, default) · README.zh.md (中文)
- Magazine — README.md (English guide) · README.zh.md (中文)
- This package — Add the theme module under
src/themes/<your-id>/, export aThemeDefinition, then register it insrc/core/themes.ts. - Host app (optional) — If you ship the theme into GLofter Studio or another host that keeps its own registry, register the same
ThemeDefinitionthere (in the full GLofter monorepo that is typicallystudio/src/themes/index.ts). Open-source contributors working only in this repo do not need astudio/tree.
Details: when this folder sits inside the GLofter monorepo, see docs/tech/theme-system.md and docs/tech/themes/system.md. In a standalone clone, read the same files in the main GLofter repository.
src/themes/minimal in this repository is the reference implementation and the recommended base. Copy it to a new id and iterate—no access to any private studio/ path is required.
Example (from this repo root):
cp -R src/themes/minimal src/themes/my-theme
# Then replace id/displayName in src/themes/my-theme/index.tsx,
# register in src/core/themes.ts, and adjust options.schema.json / pages as needed.
pnpm lintKeep minimal itself as the shared reference; fork under a new directory name so upgrades and diffs stay easy to follow.
When a GLofter Studio instance installs a theme from the marketplace or a zip, unpacked files are usually served from a per-id version directory on disk (often data/themes/<id>/<version>/ under that Studio’s data root). That tree is typically gitignored and is runtime content, not part of this theme framework source.
Theme ZIP distribution expects author signing + Hub secondary signature. Do not weaken CSP or validation to “make previews work” in production.
Paths below assume this package lives next to docs/ in the GLofter monorepo. In a standalone glofter-theme clone, open the same relative paths in the main GLofter repository.
- Theme system (technical)
- Themes — system details
- Preview flow
- Themes — product overview
- Theme status flow
- Theme system todo / roadmap
Code is licensed under the MIT License.