-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: New content type template does not preserve frontmatter formatting/comments #384
Comments
I also just noticed that I have two keys that are called Also, even in the content type I define the default values for the keys with the reference variable, it treats them like strings: {
"title": "Description",
"name": "description",
"type": "string",
"default": "&summary"
},
{
"title": "Summary",
"name": "summary",
"type": "string",
"default": "*summary"
}, becomes description: "&summary"
summary: "*summary" when I want description: &summary
summary: *summary And the datetime fields are made with UTC time, not local time. |
Comments are by default removed by the YAML parser. We already had this question or suggestion a while ago, but unfortunately, there is no easy fix for this apart from rewriting parts of the YAML parser.
The YAML parser converts strings to valid YAML if it contains special characters. From the YAML docs: Strings containing any of the following characters must be quoted. :, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, @, ` Besides the two double quotes added, it is still a valid string that your SSG can use.
Could you share your Content Type configuration for this? That way, we can test it out. |
{
"$schema": "https://frontmatter.codes/frontmatter.schema.json",
"frontMatter.taxonomy.contentTypes": [
{
"name": "blog",
"pageBundle": true,
"template": "[[workspace]]/archetypes/blog/index.md",
"previewPath": null,
"fields": [
{
"title": "Post Title",
"name": "title",
"type": "string",
"single": true,
"default": "{{title}}"
},
{
"title": "Slug",
"name": "slug",
"type": "slug",
"editable": true,
"default": "{{slug}}"
},
{
"title": "Is In Draft?",
"name": "draft",
"type": "draft",
"default": true
},
{
"title": "Created On",
"name": "date",
"type": "datetime",
"isPublishDate": true,
"default": "{{now}}"
},
{
"title": "Last Modified On",
"name": "lastmod",
"type": "datetime",
"isModifiedDate": true,
"default": "{{now}}"
},
{
"title": "SEO Description",
"name": "description",
"type": "string",
"default": "&summary"
},
{
"title": "Link Preview Summary",
"name": "summary",
"type": "string",
"default": "*summary"
},
{
"title": "Target Keywords",
"name": "keywords",
"type": "list"
},
{
"title": "Content Type",
"name": "type",
"type": "string",
"default": "blog",
"hidden": true
},
{
"title": "Weight",
"name": "weight",
"type": "number",
"default": 10
},
{
"title": "Sub-Title",
"name": "subtitle",
"type": "string",
"single": false,
"wysiwyg": true,
"default": ""
},
{
"title": "Is A Featured Post?",
"name": "featuredPost",
"type": "boolean",
"default": false
},
{
"title": "Header Image",
"name": "headerImage",
"type": "fields",
"fields": [
{
"title": "Image",
"name": "src",
"type": "image",
"default": "images/headerdefault.png",
"isPreviewImage": true
},
{
"title": "Image Title",
"name": "title",
"type": "string",
"single": true,
"default": ""
},
{
"title": "Image Alt-Text",
"name": "alt",
"type": "string",
"single": true,
"default": ""
}
]
},
{
"title": "Categories",
"name": "categories",
"type": "categories"
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
}
]
}
],
"frontMatter.framework.id": "hugo",
"frontMatter.content.publicFolder": "assets",
"frontMatter.content.pageFolders": [
{
"title": "Pages",
"path": "[[workspace]]/content",
"excludeSubdir": true
},
{
"title": "Blog",
"path": "[[workspace]]/content/blog"
},
{
"title": "About Page",
"path": "[[workspace]]/content/about"
}
],
"frontMatter.dashboard.content.cardTags": "tags"
} If I change the default value for the headerImage child title field, to something like Regarding the |
The title field is indeed a bug that will get fixed. Unfortunately, the summary variables you add cannot be fixed, as it would invalidate the YAML parser. |
Ok, Thank you. I understand about the YAML parser. I'll have to decide how I want to work with it or not. Thank you for the fix and the clarity. |
Describe the bug
When creating a new content based on a content type with a template as from Issue #351 any frontmatter formatting in the template file is wiped out. Comments are removed, whitespace is removed. Keys which exist in the template but not in the content type are preserved and any non-frontmatter content (below the frontmatter) is preserved.
To Reproduce
Steps to reproduce the behavior:
/archetypes/blog/index.md/
Expected behavior
Formatting to remain, only the keys defined in the content type would have their values specifically changed.
Desktop (please complete the following information):
Additional context
Also, in Hugo at least, one can define an archetype for a page bundle, with folders and extra files and all. They will all get created when the new content of that archetype is created. It would be nice to have the same behavior with content types linked to templates.
The text was updated successfully, but these errors were encountered: