"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchema = getSchema;
/**
* Returns the complete CMS schema reference for custom collections
*/
async function getSchema() {
return `# CMS Schema Reference
## Collections Overview
All CMS content is managed through **custom collections**. Collections are content types you define (e.g., Blog Posts, Team Members, Services, Products) with custom fields.
**To see the exact collections and fields for a specific project, use the \`get_tenant_schema\` tool.**
---
## Collection Templates
When creating a new collection, you can start from a **template** that pre-configures common field sets:
- **Blog Posts** - Articles with images, summary, body, author reference
- **Authors** - Content creators with bio, photo, social links
- **Team Members** - Staff profiles with role, photo, bio
- **Downloads** - Downloadable files with description and category
- **FAQs** - Question and answer pairs
- **Products** - Items with price, description, images
Templates are just starting points - you can customize fields after creation.
---
## Token Syntax
### Basic Tokens
\`\`\`html
{{fieldSlug}} <!-- For text, number, boolean, image, url, date, select -->
{{{fieldSlug}}} <!-- For richText fields (MUST use triple braces) -->
\`\`\`
### Built-in Tokens (Available on ALL items)
- \`{{name}}\` - Item name/title (REQUIRED - every item has a name)
- \`{{slug}}\` - Item URL slug (if collection has detail pages)
- \`{{url}}\` - Full item URL (e.g., /services/my-service)
### Date Tokens (Automatically tracked)
- \`{{createdAt}}\` - When the item was first created
- \`{{publishedAt}}\` - When the item was published (empty for drafts)
- \`{{updatedAt}}\` - When the item was last updated
---
## Loop Syntax
### Basic Loop
\`\`\`html
{{#each collectionSlug}}
<article>
<h2>{{name}}</h2>
</article>
{{/each}}
\`\`\`
### Loop Modifiers
- \`limit=N\` - Limit to N items
- \`featured=true\` - Only featured items (if collection has a boolean "featured" field)
- \`sort="fieldName"\` - Sort by field
- \`order="asc|desc"\` - Sort direction
\`\`\`html
{{#each posts limit=6 sort="publishedAt" order="desc"}}
<article>{{name}}</article>
{{/each}}
\`\`\`
### Loop Variables
Inside \`{{#each}}\` blocks:
- \`{{@first}}\` - true for first item
- \`{{@last}}\` - true for last item
- \`{{@index}}\` - zero-based index
\`\`\`html
{{#each services limit=3}}
<div class="{{#if @first}}featured{{/if}}">
{{name}}
</div>
{{/each}}
\`\`\`
---
## Conditionals
### Check if field has value
\`\`\`html
{{#if image}}
<img src="{{image}}" alt="{{name}}">
{{else}}
<div class="placeholder"></div>
{{/if}}
{{#unless featured}}
<span>Regular item</span>
{{/unless}}
\`\`\`
### Collection Empty Checks
\`\`\`html
{{#each posts}}
<article>{{name}}</article>
{{/each}}
{{#unless posts}}
<p>No posts yet. Check back soon!</p>
{{/unless}}
\`\`\`
---
## Equality Comparisons
Compare field values using the \`(eq field1 field2)\` helper:
\`\`\`html
<!-- Show content when fields ARE equal -->
{{#if (eq category.slug ../slug)}}
<span>Current category</span>
{{/if}}
<!-- Show content when fields are NOT equal (exclude current) -->
{{#unless (eq slug ../slug)}}
<a href="{{url}}">{{name}}</a>
{{/unless}}
\`\`\`
### Related Items Pattern (Exclude Current)
\`\`\`html
<h3>Other Posts</h3>
{{#each posts limit=3}}
{{#unless (eq slug ../slug)}}
<article>
<a href="{{url}}">{{name}}</a>
</article>
{{/unless}}
{{/each}}
\`\`\`
---
## Parent Context References
Inside loops, access the parent scope using \`../\`:
\`\`\`html
<!-- On author detail page, show only posts by THIS author -->
{{#each posts}}
{{#if (eq author.name ../name)}}
<h3>{{name}}</h3>
{{/if}}
{{/each}}
\`\`\`
- \`../name\` - Parent item's name field
- \`../slug\` - Parent item's slug
- \`../fieldName\` - Any field from the parent scope
---
## Relation Fields
Link items from one collection to another. Access related item data using dot notation:
\`\`\`html
{{#each projects}}
<article>
<h2>{{name}}</h2>
{{#if category}}
<span class="tag">{{category.name}}</span>
<a href="{{category.url}}">View all {{category.name}}</a>
{{/if}}
</article>
{{/each}}
\`\`\`
**Available tokens for related items:**
- \`{{relationField.name}}\` - Related item's name
- \`{{relationField.slug}}\` - Related item's slug
- \`{{relationField.url}}\` - Related item's full URL
- \`{{relationField.anyField}}\` - Any field from the related collection
---
## Rich Text (Triple Braces)
For HTML content that should NOT be escaped:
\`\`\`html
{{{description}}} ✓ Correct - renders HTML
{{description}} ✗ Wrong - escapes HTML as text
\`\`\`
---
## Important Rules
1. **Triple braces for richText fields** - \`{{{body}}}\`, \`{{{bio}}}\`
2. **Double braces for everything else** - \`{{name}}\`, \`{{image}}\`
3. **Always wrap optional fields in {{#if}}** - Check before rendering
4. **Use {{url}} for links** - Generates correct path based on manifest
5. **Match field slugs exactly** - Case-sensitive
---
## Image Handling
### Static UI Images (logos, icons)
\`\`\`html
<img src="/public/images/logo.png" alt="Logo">
\`\`\`
### CMS Content Images
\`\`\`html
{{#if heroImage}}
<img src="{{heroImage}}" alt="{{name}}">
{{/if}}
\`\`\`
---
## CMS Template Configuration
Configure templates in manifest.json:
\`\`\`json
{
"cmsTemplates": {
"postsIndex": "pages/blog.html",
"postsIndexPath": "/blog",
"postsDetail": "templates/blog-post.html",
"postsDetailPath": "/blog",
"servicesIndex": "pages/services.html",
"servicesIndexPath": "/services",
"servicesDetail": "templates/service-detail.html",
"servicesDetailPath": "/services"
}
}
\`\`\`
### Template Keys Pattern
- **{collectionSlug}Index** - Template file for listing page
- **{collectionSlug}IndexPath** - URL path for listing page
- **{collectionSlug}Detail** - Template file for detail page
- **{collectionSlug}DetailPath** - URL base for detail pages
---
## Form Handling
Forms are automatically captured and stored in the CMS.
\`\`\`html
<form data-form-name="contact">
<input type="text" name="firstName" required>
<input type="email" name="email" required>
<textarea name="message"></textarea>
<button type="submit">Send</button>
</form>
\`\`\`
### Form Handler Script
\`\`\`javascript
document.querySelectorAll('form[data-form-name]').forEach(form => {
form.addEventListener('submit', async (e) => {
e.preventDefault();
const formName = form.dataset.formName || 'general';
const formData = new FormData(form);
const data = Object.fromEntries(formData);
const response = await fetch('/_forms/' + formName, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
if (response.ok) {
form.reset();
alert(form.dataset.successMessage || 'Thank you!');
}
});
});
\`\`\`
**CRITICAL:** Endpoint is \`/_forms/{formName}\` - NOT \`/api/forms/submit\`
---
## SEO Template Tokens
For CMS detail pages, use tokens in SEO templates:
- \`{{name}}\` - Item name for title
- \`{{description}}\` or summary field - For meta description
- \`{{image}}\` field - For OG image
SEO templates are configured in the Fast Mode Editor.
---
## Next Steps
**To see exact collections and fields for a specific project, use:**
\`\`\`
get_tenant_schema(projectId: "your-project-name-or-id")
\`\`\`
This will show you:
- All collections with their slugs
- All fields with their tokens, types, and descriptions
- Relation field targets
`;
}