Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)14k · #11247

creating-plugins

Skill này làm gì

Skill này hướng dẫn cách xây dựng các phần mở rộng, gọi là plugin, cho hệ thống quản lý nội dung EmDash. Skill dành cho lập trình viên muốn thêm tính năng hoặc màn hình quản trị tùy chỉnh vào trang EmDash.

Khi nào nên dùng

  • ✓Khi bạn muốn thêm một tính năng mới cho trang EmDash thông qua plugin.
  • ✓Khi bạn cần một plugin có màn hình quản trị riêng hoặc các route API.
  • ✓Khi bạn muốn đăng một plugin để người khác cài đặt từ registry.

Liên kết skill

https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/emdash-cms/emdash/blob/main/skills/creating-plugins/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể giúp tôi tạo một plugin EmDash thêm biểu mẫu tùy chỉnh vào khu vực quản trị không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent chọn giữa plugin sandbox và plugin native đáng tin cậy, tạo khung dự án, rồi triển khai các hook, route và trang quản trị. Sau đó agent chạy test của plugin.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Creating EmDash plugins

Build against the API that reaches the intended execution mode. Source types and production-boundary tests take precedence over examples in this skill when they disagree.

Choose a format

Format Runtime source Admin UI Distribution
Sandboxed src/plugin.ts default-exports a SandboxedPlugin Block Kit pages, widgets, saved-entry panels, and actions Plugin CLI and registry
Native definePlugin() / createPlugin() React, Block Kit, and Astro components Trusted site dependency only

Use a sandboxed plugin unless the feature needs host-process access, React admin code, Astro rendering components, raw page fragments, or custom Portable Text block definitions. Native plugins run with the site's authority and cannot be installed from the registry.

Scaffold a sandboxed plugin

pnpm dlx @emdash-cms/plugin-cli init my-plugin
cd my-plugin
pnpm install
pnpm run test

The manifest is the identity and trust contract. Runtime hooks and routes live in src/plugin.ts; the CLI generates descriptors, manifests, and bundles. Do not create a separate descriptor factory or sandbox-entry.ts.

import type { SandboxedPlugin } from "emdash/plugin";

const plugin: SandboxedPlugin = {
	hooks: {
		"content:afterSave": async (event, ctx) => {
			ctx.log.info("Content saved", { id: event.content.id });
		},
	},
};

export default plugin;

Import authoring types from emdash/plugin with import type. The CLI bundles value imports such as pluginRoute() and pluginResponse() from emdash/plugin and portableTextToMarkdown() from emdash/client. Sandboxed runtime code can use Web APIs but not Node.js built-ins.

Declare access

Declare every host API in emdash-plugin.jsonc. Adding authority, exposing a route publicly, or adding MCP tools requires renewed administrator approval.

Capability Grants
schema:read Public collection and field definitions
admin.editor-draft:read Selected unsaved field values after an explicit editor interaction
admin.editor-draft:patch Host-validated unsaved field changes proposed for editor review
content:read Content identity, translations, and published public URLs
content:revisions:read Retained revision data; implies content read
content:write Create, update, delete, and translation creation; implies read
content:publish Revision-fenced publish, unpublish, schedule, and unschedule; implies read
content:restore Revision-fenced reads and restoration of trashed content
hooks.content-policy:register Pre-publish, pre-schedule, and pre-unpublish policy hooks
taxonomies:read Taxonomy definitions, terms, and entry assignments
taxonomies:write Term creation and assignment deltas; implies read
bylines:read Public byline profiles and single or batched entry credits
redirects:read Versioned redirect inspection
redirects:write Versioned redirect creation, update, and deletion; implies read
comments:read Stored non-trashed comments and their personal data
comments:moderate Expected-status moderation; implies read
media:read Ready-media metadata and authenticated asset URLs
media:bytes:read Bounded media bytes and content hashes
`m
Câu hỏi thường gặp

Plugin sandbox và plugin native khác nhau thế nào?

Plugin sandbox chạy với quyền hạn chế và có thể cài từ registry, còn plugin native chạy với toàn quyền của trang và chỉ phù hợp với mã đáng tin cậy.

Skill có cung cấp dự án khởi đầu không?

Có. Một lệnh plugin sẽ tạo dự án khởi đầu.

Plugin có thể thêm màn hình React không?

Plugin native có thể dùng các thành phần React và Astro cho trang quản trị và các trang của site.

Chi tiết

Mô tả gốc của tác giả

Create EmDash CMS plugins with sandboxed hooks, routes, storage, content and media APIs, MCP tools, and declarative admin UI, or native React and Astro extensions. Use when scaffolding or implementing an EmDash plugin.

repo: emdash-cms/emdash

Độ phổ biến

Sao GitHub
14k
Vị trí xếp hạng
#11247
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự