跳到正文
Skillpedia
网站与界面(前端)56k · #3280

build-ghost-app

它能做什么

这个技能引导 AI 智能体构建在 Ghost Admin 内运行的 Ghost 应用。适合希望向 Ghost 添加自己页面或工具的开发者。

适用场景

  • ✓当你开始一个新的 Ghost 应用,并希望它出现在 Ghost Admin 中的时候。
  • ✓当你需要编写告诉 Ghost 你的应用信息的清单文件的时候。
  • ✓当你想用应用 SDK 将应用连接到 Ghost Admin 并进行安装的时候。

技能链接

https://github.com/TryGhost/Ghost/blob/main/apps/shade/dev-skill/ghost-app-ui-dev-setup/build-ghost-app/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/TryGhost/Ghost/blob/main/apps/shade/dev-skill/ghost-app-ui-dev-setup/build-ghost-app/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我用 Vite 和 React 启动一个 Ghost 应用,让它显示在我的 Ghost Admin 中。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会搭建一个 Vite 和 React 项目,安装 Ghost 应用 SDK,并编写一个清单文件。然后它会在固定的本地端口上提供应用,以便 Ghost Admin 加载它。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Build a Ghost app

A Ghost app runs as a full page in a frame inside Ghost Admin. Build it in this folder, the one with AGENTS.md, as a Vite, React and TypeScript app with npm. These steps make it show up in Admin. For its screens, use the build-ghost-app-ui skill.

npm create vite won't scaffold into a folder that already has files without --overwrite, which deletes them. Scaffold into a new subfolder, then move its files up into this folder and remove the subfolder.

Connect the app

  1. SDK. @tryghost/app-sdk isn't on npm yet. Install it from the folder: npm install ./vendor/tryghost-app-sdk.tgz. It brings its one dependency, @quilted/threads.

  2. Fixed port. In vite.config.ts, set server: { port: 5190, strictPort: true }. The install link depends on the port.

  3. Manifest. Serve it as public/ghost-app.json, so it's at http://localhost:5190/ghost-app.json:

    {
      "id": "org.example.<app-slug>",
      "name": "<App name>",
      "description": "<One sentence on what the app does.>",
      "author": { "name": "<Author>", "url": "https://example.com" },
      "accent_color": "#<six-digit hex>",
      "icon": { "name": "<icon-name>" },
      "surfaces": [{ "type": "admin_page", "url": "/" }]
    }
    

    Every field is required, author.url too, and Admin rejects fields it doesn't know. icon.name is any Lucide icon name in kebab case, such as megaphone or layout-list; Admin draws it on accent_color.

  4. Connect before rendering. Admin keeps the frame hidden until the app calls connect(), and gives up after 10 seconds. In src/main.tsx, await it before rendering React:

    import { connect, GhostAppError } from '@tryghost/app-sdk'
    
    try {
      const ghost = await connect()
      // apply ghost.theme.mode (step 5), then render the app
    } catch (error) {
      if (error instanceof GhostAppError && error.code === 'not_framed') {
        // Opened outside Admin: render only a short "Open this app in Ghost Admin" message
      } else {
        // Render a short "Couldn't connect to Ghost" message with error.message
      }
    }
    

    Opened directly at http://localhost:5190/, the page isn't framed, so it shows only that message. That's expected.

  5. Theme. ghost.theme.mode is 'light' or 'dark', and ghost.onThemeChange(theme => …) fires when the publisher switches; it returns a function that unsubscribes. Apply the mode before the first render and follow changes. How Shade takes the mode is in the build-ghost-app-ui skill, at its "Light and dark theme" step.

  6. Install link. With npm run dev running, the publisher installs the app from: http://localhost:2368/ghost/#/apps/install?manifest=http%3A%2F%2Flocalhost%3A5190%2Fghost-app.json

Hand over

You can't open Ghost Admin yourself, so the publisher checks the app there. When you're done, check that npm run dev starts on port 5190 and npm run build passes, stop the dev server, and give them the install link with anything they should check in Admin.

常见问题

应用使用哪个端口?

该技能在严格模式下将应用设置为 5190 端口,因为安装链接依赖该端口。

清单文件放在哪里?

它放在 public 文件夹中,名为 ghost-app.json,因此会在应用的本地地址下提供。

这个技能涵盖应用的界面吗?

不涵盖。该技能会指向另一个 build-ghost-app-ui 技能来处理界面。

详情

作者的原始描述

Connect a Ghost app to Ghost Admin with the app SDK, and serve its manifest and install link. Use when building a Ghost app, connecting it to Admin, writing its manifest or installing it.

repo: TryGhost/Ghost

热度

GitHub 星标
56k
排名
#3280
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能