UNPKG

@paroicms/site-generator-plugin

Version:

ParoiCMS Site Generator Plugin

140 lines (104 loc) 4.26 kB
You are tasked with modifying a JSON object based on a given TypeScript type definition and an update message. Follow these steps carefully: # 1. Review the TypeScript type definition of the JSON structure <site_schema_ts_defs> {{siteSchemaTsDefs}} </site_schema_ts_defs> # 2. Fields In a list of fields, an item can be either a predefined field name (a string) or a custom field type, which is an object of type `JtFieldType`. Here are the predefined fields provided by ParoiCMS: <predefined_fields_json> {{predefinedFields}} </predefined_fields_json> Here is an example of an object for describing a custom **HTML** field type: <field_type_example> { "name": "myCustomField", "localized": true, "storedAs": "text", "dataType": "json", "renderAs": "html", "useAsExcerpt": 1, "plugin": "@paroicms/tiptap-editor-plugin" } </field_type_example> Then, in the locales, the translations of custom field types must be in a sub-key `fields` of the node type: <l10n_example> { "nodeTypes": { ... "myNodeTypeName": { ... "fields": { "myCustomField": { "label": "My custom field", "description": "This is a description that will be displayed in a tooltip of the admin-ui" } } } } } </l10n_example> Here is how to write field locales for a custom site field: <l10n_example> { "nodeTypes": { ... "_site": { "fields": { "myCustomSiteField": { "label": "My custom site field", "description": "…" } } } } } </l10n_example> Important: - Never add locales for a predefined field. - Never add an unknown predefined field. - The type name of the "site" node type is omitted from the JSON but its value is always `_site`. # 3. Labeling fields (using a taxonomy) A labeling field lets the user assign taxonomy terms to a document (or part). <field_type_example> { "name": "tags", "localized": false, "storedAs": "labeling", "taxonomy": "tags", "multiple": true }, </field_type_example> Most of the time, the field name will be the same as the taxonomy type name. # 4. Part Field (embedding a part inline) A part field embeds a single part directly within a document or part's field list. The referenced part type must exist in the schema's nodeTypes as a `kind: "part"` node type. <field_type_example> { "name": "seo", "storedAs": "partField", "partType": "myPartTypeName" } </field_type_example> When using a partField, the referenced part type (e.g., "myPartTypeName") must be defined as a `kind: "part"` node type in the schema. The part will be embedded inline in the document editor, not in the parts tab. Use partField when a group of fields should logically belong together as a reusable unit (e.g., SEO metadata, social sharing settings, address blocks). # 5. Examine the current JSON data, which conforms to the `JtSiteSchema` type <site_schema_json> {{siteSchemaJson}} </site_schema_json> Also, the attached locales: <l10n_json> {{l10nJson}} </l10n_json> # 6. Now, here is what to do <user_request> {{taskDetailsMd}} </user_request> # 7. Guidelines - Don't assume how the CMS works. If you are not sure how to do something, don't do it. - You are allowed to be proactive, but only when the user asks you to do something. - Remember to adhere strictly to the TypeScript typing when making changes. If the update message requests changes that would violate the typing, then prioritize maintaining the correct structure over making those specific changes. - Field choice for listing pages: For new routing documents that have `regularChildren` (like blog index, products index, etc.), prefer `introduction[@paroicms/tiptap-editor-plugin]` instead of `htmlContent[@paroicms/tiptap-editor-plugin]`. These pages display a list of child items, so they only need a short introduction, not full HTML content. # 8. Output If there is a change in the site schema, then provide the updated site schema in JSON within <updated_site_schema_json> tags. Otherwise, let this tag empty. If there is a change in the locales, then provide the updated attached locales within <updated_l10n_json>. Otherwise, let this tag empty. Do not write any explanation or commentary outside these tags.