Communitygithub.com

miketropi/nextora-site-composition

组合 Nextora 或 Nextora 子块主题的表层 — HTML 模板和模板部件、PHP 块模式及其分类、页面模板与模板层级、首页与文章索引、从薄模板引用的文件系统模式、核心查询/归档/搜索循环与显式查询上下文、页眉页脚归属以及文件系统与站点编辑器自定义。适用于涉及着陆页布局、页面模板、归档或搜索组合、可复用模式或区块、页眉/页脚部件、查询循环,或模板文件编辑后前端无变化的场景。

nextora-site-composition 是什么?

该技能专注于 Nextora 生态系统中块主题的组合层,负责管理 `templates/`、`parts/`、`patterns/` 目录以及 `theme.json` 中的声明。它提供了一套有序的工作流程,指导开发者解决主题中的模板层级、部件所有权、模式创建与引用、查询循环构建以及 `customTemplates` 和 `templateParts` 声明准确性等核心任务。技能强调复用现有模式或块以减少冗余,并避免不必要的自定义或 mock 数据。它特别关注文件系统与站点编辑器之间的冲突,确保模板编辑在前端生效,同时保护真实站点数据。支持平台包括 Nextora 父主题及其子块主题,主要面向采用块编辑器和完整站点编辑(FSE)的 WordPress 环境。该技能需要加载 `references/templates-and-patterns.md`、`source-map.md` 和 `quality-gates.md` 等参考文档以获取详细规则和缺陷信息。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/miketropi/nextora-skills/tree/main/skills/nextora-site-composition

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Nextora 站点组合

负责 Nextora 驱动的块主题的组合层:templates/、parts/、patterns/ 以及描述它们的 theme.json 声明。块内部细节见 ../nextora-gutenberg-blocks/SKILL.md;外观和预设数据见 ../nextora-design-system/SKILL.md;子主题引导和资源见 ../nextora-child-themes/SKILL.md。

要加载的参考文档

  • references/templates-and-patterns.md — 包含真实文件名的模板层级、部件所有权和覆盖规则、模式头部和分类约定、隐藏模式加薄模板配方、查询组合和清理辅助函数、文件系统与数据库自定义、已观察到的缺陷以及下游 WordPress 验收步骤。在步骤 3 之前加载。
  • source-map.md — 其中每个锚点的来源。
  • quality-gates.md — 决定组合是否完成的门禁。

本地文件优先级高于这些参考文档中引用的任何值。

有序工作流

1. 解析主题根目录并读取本地表层

父主题是模板目录,当前活动主题是样式表目录:

get_template_directory();      // 父主题根目录
get_stylesheet_directory();    // 当前活动主题根目录(存在子主题时为子主题)

按此顺序读取:theme.json (customTemplates, templateParts)、templates/、parts/、patterns/、目标的 blocks/*/block.json 名称,以及 inc/ 中的查询或模板辅助函数。子主题对模板或部件的副本会覆盖父主题中同名的文件,因此已存在的内容决定了大部分答案。

2. 在组合任何内容前查找已存在的内容

复用优于创新,按此顺序:

  1. 已存在的模式,恰好就是该区块。
  2. 已存在的块(父主题的 nextora/* 或子主题自己的),恰好渲染该区块。
  3. 由已存在块组成的新子主题模式。
  4. 一个组装这些模式的薄模板。
  5. 一个子主题部件覆盖 — 仅用于子主题真正拥有的表层。
  6. 一个新块 — 仅当所需行为或编辑结构无法由任何现有块表达时。

永远不要将模拟文章作为生产内容发布,也不要克隆父主题的联系表单后端:父主题已经提供了 nextora/contact-form 块,示例的联系页面将其组合在子主题的包装组内。

3. 将组合放在正确的模板中

应用 references/templates-and-patterns.md 中的层级:

  • front-page.html 存在时控制首页;home.html 是文章索引,不是首页的同义词;index.html 是回退。
  • 归档、单页、搜索和特定页面模板优先于索引回退。
  • theme.json customTemplates 中声明的名称必须在声明它的主题中有一个匹配的 templates/<name>.html。

读取主题自己的 templates/ 列表,而不是猜测文件名:父主题提供 front-page、home、index、archive、single、search、page、page-full-width、about-us、contact-us、frequently-asked-questions、theme-terms-conditions、theme-privacy-policy、404;示例子主题提供其自己的一组不同名称。

4. 决定部件所有权,然后引用部件

一个 wp:template-part 引用首先解析 样式表 目录,因此子主题的 parts/header.html 会在所有使用的地方替换父主题的页眉。

  • 如果子主题没有理由拥有页眉/页脚,则保留父主题的页眉/页脚:不要添加复制的部件。
  • 如果子主题拥有一个部件,给它一个子主题拥有的主体,并在引用中说明;不要留下指向父主题副本的 theme 属性。
  • 示例子主题的 parts/header.html 和 parts/footer.html 各是一个块引用(nextsaas/site-header、nextsaas/site-footer);父主题的页眉部件组合了 nextora/scrolling-promotion 和 nextora/header。
  • 源代码中的引用语法在子主题中是 {"slug":"header","tagName":"div"},在父主题中是 {"slug":"header","tagName":"header","area":"header"}。匹配目标自己的约定;永远不要硬编码文件系统路径。

5. 将模式编写为带有真实头部的 PHP 文件

模式位于 patterns/*.php。它们的注册来自文件头部,而不是来自 register_block_pattern() 调用 — 两个源主题都没有调用它;两者都仅在 PHP 中注册 分类。必需的头部字段和别名规则在 references/templates-and-patterns.md 中:

  • Title、Slug: <child-slug>/<pattern-slug>(唯一)、Categories 和说明何时使用它的 Description。
  • 模式主体是编辑器插入的序列化块标记,从头部注释的 */ 之后开始。
  • 它必须可解析,仅使用已注册的块,并且在插入后保持可编辑。

6. 为全页组合赋予唯一权限

对于新的全页组合,将区块列表放在一个隐藏的文件系统模式中 — 头部的 Inserter: no — 并从薄模板中引用它:

<!-- wp:template-part {"slug":"header","tagName":"div"} /-->

<!-- wp:pattern {"slug":"nextfolio/page-landing"} /-->

<!-- wp:template-part {"slug":"footer","tagName":"div"} /-->

不要也把区块列表重复到模板中。示例当前在两个地方(patterns/page-home.php 和 templates/front-page.html)保存了相同的列表,而父主题的模板内联了带有 metadata.patternName 的模式标记;这种重复正是此规则为新工作所取代的。当仅编辑现有块时,保留现有的重复 — 仅在区块内容实际改变时才更新其他副本。

7. 使用核心块和显式上下文组合查询

  • 归档、文章索引、搜索和文章详情委托给带有 "inherit":true 的 wp:query,因此主查询提供上下文;示例的 index.html、home.html、archive.html 和 search.html 都这样做。
  • 从 core/post-template 加上 core/post-* 块构建循环,添加 wp:query-pagination,并始终提供 wp:query-no-results。
  • 使用 wp:query-title、core/post-title、core/post-content、core/comments + core/comment-template + wp:comments-pagination + wp:post-comments-form 作为单篇文章表层,而不是经典循环。
  • 启动其 自己 循环的块传递经过清理的属性:复用子主题的 inc/blocks/query.php 辅助函数(如果存在),否则将页面大小限制在允许值范围内,并针对允许值验证文章类型、分类法和术语。预编译 SQL 不能替代该验证。

8. 保持 theme.json 声明准确

仅为主题拥有的表层声明 customTemplates 和 templateParts 条目,且仅用于不是核心模板的名称。关于示例中观察到的重复声明以及新工作的规则,请参阅 references/templates-and-patterns.md。

9. 考虑站点编辑器

文件系统模板和部件可能被站点编辑器中保存的数据库自定义所掩盖。如果文件编辑未改变前端,则在 touch 文件前查找保存的模板或样式。切勿静默覆盖真实站点的自定义;仅查看或重置可丢弃环境。

10. 在运行的站点上验证

在前端解析每个模板和部件,确认模式插入并保持可编辑,确认所需的 WordPress 最低版本和当前支持的版本,并运行 references/templates-and-patterns.md 中的浏览器步骤。将任何未实际测试的内容标记为未验证。

完成检查

  • 每个使用的模板和部件都解析到预期的主题;没有错误的 theme 属性将父主题部件固定到子主题模板。
  • 没有不必要的新块,没有经典的 PHP 页面模板,没有 mock 生产内容。
  • 新的全页组合:隐藏模式中的唯一权限,从薄模板引用;没有重复的区块列表。
  • 模式可解析,使用已注册的块,保持唯一的别名,其分类是主题在 PHP 中注册的类别。
  • 查询循环使用显式上下文、经过清理的属性和无结果状态。
  • theme.json 仅声明拥有的、非核心的模板名称。
  • 应用了 quality-gates.md,包括其组合验收部分。

边界

仅限 Markdown 指令:没有运行时脚本、生成器、复制的主题树或安装程序,也不编辑父主题或示例子主题。父主题的模式库和示例的组合是供读取的证据,而不是要复制的文件。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

miketropi/nextora-child-themes

Create, bootstrap or audit a child theme of the Nextora parent block theme — the style.css header with Template nextora, the functions.php load order, the single version constant kept in sync with the header, the front-end and editor-canvas asset pipeline with its parent handle dependencies, the child block registrar and inserter category, PHP/i18n conventions, and the optional feature-file layout. Use when a request names a Nextora child, a new child theme name or slug, a child theme header or version bump, child CSS/JS enqueueing, editor canvas styles, a child block folder or block category, porting Nextsaas conventions into a new child, or asks why child code cannot call the parent at file scope. Pair with nextora-design-system for any child that must follow palette or visitor font/colour switching.

miketropi/nextora-ecosystem

Entry point for work on the Nextora block-theme ecosystem — child themes, Gutenberg blocks, design presets and the visitor colour/font switcher, and template/part/pattern composition. Use when a request mentions Nextora or a Nextora child theme, when the task spans more than one of those areas, or when you need the source map and production quality gates for this ecosystem before writing code. Also use to decide which specialist skill a multi-part request needs.

nextora-design-system

Own colours, typography, spacing tokens, style variations and the optional visitor colour/font switcher for the Nextora parent theme and its child themes. Use when a request mentions a palette, colour role, preset slug, font family or font preset, theme.json settings, Tailwind @theme aliases, CSS custom properties, a style variation, "follow the palette", "must switch with the visitor's choice", scoped block colours, or appearance for a new child theme.

nextora-gutenberg-blocks

Build or change Gutenberg blocks in the Nextora parent theme or a Nextora child theme — block.json registration, typed attributes, native visual editing with RichText and media, InspectorControls settings panels, repeatable list editors with modal item editing, render.php output, view scripts, block style variations, and the esbuild block pipeline. Use when a request mentions a block, block.json, edit.tsx, index.tsx, render.php, ServerSideRender, InnerBlocks, a repeater or list editor, a modal item form, an inspector panel, a block category, or "add/restyle a section block" for Nextora.

相关技能