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

webiny-page-settings-extensions

它能做什么

这项技能在你的 AI 为 Webiny Website Builder 的页面设置添加设置标签页或字段时提供指导。适合自定义 Webiny 网站的开发者。

适用场景

  • ✓当你希望在页面设置抽屉中添加新标签页,例如发布或分析的时候。
  • ✓当你需要在现有页面设置分组(如 SEO)中添加字段的时候。
  • ✓当你需要存储自定义页面设置,而不改动内置属性的时候。

技能链接

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/website-builder/page-settings/SKILL.md

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

使用方法

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

可直接粘贴的消息

请用这个技能帮我:https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/website-builder/page-settings/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请在 Website Builder 页面设置中添加一个分析标签页,让编辑者可以输入跟踪 ID。”

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

工作原理

技能演示如何为新标签页创建设置分组类,或为现有分组创建修改器,将其注册为功能,并把数据存放在页面的 extensions 区域下。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Page Settings Extensions

TL;DR

Page settings extensions let you add new tabs to the page settings drawer or inject fields into existing tabs. Create a class implementing PageSettingsGroup.Interface for a new tab, or PageSettingsGroupModifier.Interface to extend an existing one. Register both via createFeature() and <RegisterFeature>. Always store custom data in doc.extensions — never write to doc.properties, which is reserved for built-in system properties.

YOU MUST include the full file path with the .tsx extension in every src prop. For example, use src={"/extensions/myPageSettings/index.tsx"}, NOT src={"/extensions/myPageSettings/index"}. Omitting the file extension will cause a build failure.

For field types, renderers, layout, validation, and all other form builder APIs, refer to the webiny-form-model skill.

Important: Where to Store Data

Use doc.extensions for all custom data. The doc.properties object holds built-in system properties (title, path, snippet, image, tags, seo, social). Writing custom fields into doc.properties risks naming collisions with future Webiny updates and can corrupt system behavior. Always namespace your data under doc.extensions.<yourGroupName>.

// CORRECT — custom data in doc.extensions
mapFromForm(formData, doc) {
    doc.extensions.mySettings = doc.extensions.mySettings ?? {};
    doc.extensions.mySettings.myField = formData.myField;
}

// WRONG — never write custom data into doc.properties
mapFromForm(formData, doc) {
    doc.properties.myField = formData.myField; // DON'T DO THIS
}

Adding a New Settings Group

A new settings group appears as its own tab in the page settings drawer. Implement PageSettingsGroup.Interface with these members:

Member Type Description
name string Unique group identifier (used as form field namespace)
label string Tab label shown in the UI
description string (optional) Description shown below the tab label
icon { type: "icon", name: string } (optional) FontAwesome icon for the tab (e.g., "fas/calendar-alt")
buildForm(form) method Define fields and layout
mapToForm(doc) method Read from document to populate the form
mapFromForm(formData, doc) method Write form values back to the document

Complete Example: Publishing Settings Group

// extensions/myPageSettings/PublishingSettingsGroup.ts
import { PageSettingsGroup } from "webiny/admin/website-builder/page/editor";

class PublishingSettingsGroupImpl implements PageSettingsGroup.Interface {
  name = "publishing";
  label = "Publishing";
  description = "Configure publishing schedule and visibility.";
  icon = { type: "icon", name: "fas/calendar-alt" };

  buildForm(form: PageSettingsGroup.FormBuilder): void {
    form.fields(fields => ({
      publishDate: fields.datetime().withTimezone().label("Publish date"),
      unpublishDate: fields.datetime().dateOnly().label("Unpublish date"),
      visibility: fields
        .text()
        .label("Visibility")
        .options([
          { label: "Public", value: "public" },
          { label: "Private", value: "private" },
          { label: "Password Protected", value: "password" }
        ])
        .defaultValue("public"),
      featured: fields.boolean().label("Featured page")
    }));

    form.layout(layout => [
      layout.row("publishDate"),
      layout.row("unpublishDate"),
      layout.row("visibility"),
      layout.row("featured")
    ]);
  }

  mapToForm(doc: PageSettingsGroup.PageDocument): Record<string, any> {
    const publishing = doc.extensions?.publishing;
    return {
      publishDate: publishing?.publishDate ?? null,
      unpublishDate: publishing?.unpublishDate ?? null,
      visib
常见问题

自定义页面数据应存放在哪里?

存放在页面的 extensions 区域下,使用你选择的名称,绝不放在内置属性中。

它会解释每一种表单字段类型吗?

不会。它会参考表单模型技能,了解字段类型、渲染器和校验。

源路径必须包含什么?

必须包含带 .tsx 扩展名的完整文件路径,否则构建会失败。

详情

作者的原始描述

Extending the Website Builder page settings with custom settings groups and modifiers. Use this skill when the developer wants to add a new tab/group to the page settings drawer (e.g., Publishing, Analytics, Access Control), or modify an existing settings group (e.g., add fields to General or SEO). Covers PageSettingsGroup, PageSettingsGroupModifier, and the doc.extensions data model. For field types, renderers, and layout details, see the webiny-form-model skill.

repo: webiny/webiny-js

热度

GitHub 星标
8.1k
排名
#12579
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能