Official example plugin β auto-fill article summary on publish when empty. Template for custom ReactPress plugins.
Part of the ReactPress publishing platform Β· plugin system docs
- Plugin id:
hello-world(historical id, unchanged) - Display name: Auto Summary
- Version: see
plugin.json
| Scenario | Behavior |
|---|---|
| Summary already set on publish | No change |
| Summary empty, body has content | Strip Markdown, truncate, write summary |
| Summary and body both empty | Use title if fallbackToTitle is enabled |
Subscribes to a single hook with a focused responsibility:
| Hook | Type | Description |
|---|---|---|
article.beforePublish |
filter | Fill in summary before publish |
Declared via plugin.json β settings.schema, stored in globalSetting.plugins.entries.hello-world.config.
Admin UI strings (plugin name, descriptions, field labels) live in src/locales/ (src/locales/{locale}.json); Chinese strings in plugin.json serve as fallback.
| Field | Type | Default | Description |
|---|---|---|---|
enabled |
boolean | true |
Enable auto summary |
maxLength |
number | 160 |
Max length (40β500) |
suffix |
string | β¦ |
Suffix when truncated |
fallbackToTitle |
boolean | true |
Use title when body is empty |
Update config (admin login required):
curl -X PUT http://localhost:3002/api/extension/plugins/hello-world/config \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"config":{"enabled":true,"maxLength":120}}'Config save triggers an automatic plugin reload β no server restart needed.
pnpm dev(plugins are compiled automatically)- Admin β Plugins β install hello-world β Enable
- Click Settings on the plugin row (or visit
/admin/plugins/hello-world/settings) - Leave summary empty when writing β publish β summary field should be auto-filled
Example server logs:
[PluginService] [hello-world] registered (enabled=true, maxLength=160)
[PluginLoaderService] Loaded plugin "hello-world" v1.2.0
hello-world/
βββ plugin.json
βββ package.json
βββ tsconfig.json
βββ README.md
βββ src/
βββ server/ # Node Hook logic
β βββ index.ts
β βββ config.ts
β βββ summary.ts
β βββ types.ts
βββ locales/ # Admin UI strings
βββ en.json
βββ zh.json
β tsc (server only)
dist/
βββ index.js
# from monorepo root
pnpm --filter @reactpress/plugin-hello-world run build
pnpm --filter @reactpress/plugin-hello-world run typecheck
# after editing src/server, rebuild and deactivate β reactivate in adminDependencies:
@reactpressjs/reactpress-toolkit/plugin/serverβHookService,PluginContexttypes
- Copy this directory to
plugins/my-plugin/ - Update
plugin.jsonid,name,hooks.subscribe - Rewrite
src/server/index.tsand business modules - Add the id to
plugins/package.jsonβlocallist
See ../README.md for the plugin system overview.