Nice, it's detecting content correctly. It doesn't generate appropriate types in some cases though. Below is zod configuration and resulting content types generated:
zod and resulting config type
constblogCollection=defineCollection({// Type-check frontmatter using a schema
schema: z.object({title: z.string(),description: z.string(),heroImage: z.string().optional(),tags: z.array(z.string()).optional(),categories: z.array(z.string()).optional(),draft: z.boolean().optional().default(true),published: z.string().datetime({offset: true}).or(z.date())// Transform string to Date object
.transform((val)=>newDate(val)),modified: z.string().datetime({offset: true}).or(z.date()).optional().transform((val)=>(val?newDate(val):undefined)),})});
Result content types:
"frontMatter.taxonomy.contentTypes":[{"name":"default","pageBundle":false,"previewPath":null,"fields":[{"title":"Title","name":"title","type":"string"},{"title":"Description","name":"description","type":"string"},{"title":"Publishing date","name":"date","type":"datetime","default":"{{now}}","isPublishDate":true},{"title":"Content preview","name":"preview","type":"image"},{"title":"Is in draft","name":"draft","type":"draft"},{"title":"Tags","name":"tags","type":"tags"},{"title":"Categories","name":"categories","type":"categories"}]},{"name":"blog","previewPath":"'blog'","pageBundle":false,"clearEmpty":true,"fields":[{"name":"title","type":"string","single":true,"required":true},{"name":"description","type":"string","single":true,"required":true},{"name":"heroImage","type":"string","single":true,"required":true,"default":true},{"name":"tags","type":"list","required":true,"default":true},{"name":"categories","type":"list","required":true,"default":true},{"name":"draft","type":"boolean","required":true,"default":true}]}]
In words:
possibly needles 'default' content type (created on "initialize project" stage)
the "Create content types" step doesn't get a checkmark even after marking all content collections (1 in my case)
tags, categories, heroImage, title, getting assigned improper types (I understand those types may not be always right, but some obvious heuristics could be put in place, some based on zods validation like .string().datetime(), some based on name)
some fields like published and modified are completely missing
Aside from that I would also think about the UX of the "use template" and "detect content" steps because using "blog template" — which looks like a required step — finalizes the whole configuration and opens the dashboard. I clicked it the first time thinking it would just append some defaults to configs and let me proceed with initialization, but it basically finished everything on it's own. Maybe make it the "step 0" where those buttons are on the very top.
Not sure if above comments belong to this thread or should be moved to separate issues though.
Nice, it's detecting content correctly. It doesn't generate appropriate types in some cases though. Below is zod configuration and resulting content types generated:
<details>
<summary>zod and resulting config type</summary>
```ts
const blogCollection = defineCollection({
// Type-check frontmatter using a schema
schema: z.object({
title: z.string(),
description: z.string(),
heroImage: z.string().optional(),
tags: z.array(z.string()).optional(),
categories: z.array(z.string()).optional(),
draft: z.boolean().optional().default(true),
published: z
.string().datetime({offset: true})
.or(z.date())
// Transform string to Date object
.transform((val) => new Date(val)),
modified: z
.string().datetime({offset: true})
.or(z.date())
.optional()
.transform((val) => (val ? new Date(val) : undefined)),
})
});
```
Result content types:
```json
"frontMatter.taxonomy.contentTypes": [
{
"name": "default",
"pageBundle": false,
"previewPath": null,
"fields": [
{
"title": "Title",
"name": "title",
"type": "string"
},
{
"title": "Description",
"name": "description",
"type": "string"
},
{
"title": "Publishing date",
"name": "date",
"type": "datetime",
"default": "{{now}}",
"isPublishDate": true
},
{
"title": "Content preview",
"name": "preview",
"type": "image"
},
{
"title": "Is in draft",
"name": "draft",
"type": "draft"
},
{
"title": "Tags",
"name": "tags",
"type": "tags"
},
{
"title": "Categories",
"name": "categories",
"type": "categories"
}
]
},
{
"name": "blog",
"previewPath": "'blog'",
"pageBundle": false,
"clearEmpty": true,
"fields": [
{
"name": "title",
"type": "string",
"single": true,
"required": true
},
{
"name": "description",
"type": "string",
"single": true,
"required": true
},
{
"name": "heroImage",
"type": "string",
"single": true,
"required": true,
"default": true
},
{
"name": "tags",
"type": "list",
"required": true,
"default": true
},
{
"name": "categories",
"type": "list",
"required": true,
"default": true
},
{
"name": "draft",
"type": "boolean",
"required": true,
"default": true
}
]
}
]
```
</details>
In words:
- possibly needles 'default' content type (created on "initialize project" stage)
- `optional` from zod not respected, all fields are `required` ([possibly messed up function definition/arguments order after some refactoring?](https://github.com/estruyf/vscode-front-matter/blob/8db76abf5133563fa2a580420ea09dde1903750a/ssg-scripts/astro.collections.mjs#L29C5-L29C5))
- all fields are `default: true`
- the "Create content types" step doesn't get a checkmark even after marking all content collections (1 in my case)
- `tags`, `categories`, `heroImage`, `title`, getting assigned improper types (I understand those types may not be always right, but some obvious heuristics could be put in place, some based on zods validation like `.string().datetime()`, some based on name)
- some fields like `published` and `modified` are completely missing
Aside from that I would also think about the UX of the "use template" and "detect content" steps because using "blog template" — which looks like a required step — finalizes the whole configuration and opens the dashboard. I clicked it the first time thinking it would just append some defaults to configs and let me proceed with initialization, but it basically finished everything on it's own. Maybe make it the "step 0" where those buttons are on the very top.
Not sure if above comments belong to this thread or should be moved to separate issues though.
_Originally posted by @T3sT3ro in https://github.com/estruyf/vscode-front-matter/issues/703#issuecomment-1804827033_
<!-- github-sync-id:1987957715 -->
@ T3sT3ro, I have been verifying against your Astro Collections, and it should now correctly create the content type.
Also added a small enhancement to show when a content type has not yet been created and when it is:
When it is created:
@ T3sT3ro, I have been verifying against your Astro Collections, and it should now correctly create the content type.
Also added a small enhancement to show when a content type has not yet been created and when it is:

When it is created:

<!-- github-comment-id:1806896999 -->
About the templates, they behave like a complete configuration for your site. I agree we can improve the UX on this one, but pushing it to the top would not be optimal as those templates are linked to certain frameworks/SSGs. Adding those to the top would always show them; right now, it is only shown when templates for a framework are available.
About the templates, they behave like a complete configuration for your site. I agree we can improve the UX on this one, but pushing it to the top would not be optimal as those templates are linked to certain frameworks/SSGs. Adding those to the top would always show them; right now, it is only shown when templates for a framework are available.
<!-- github-comment-id:1806897610 -->
"The following astro content collections and (?) can be used to generate a content-type (types?)"
As for the templates, I think it doesn't have to be pushed to the top, but it would be good if either this step didn't close the configuration welcome screen or would clearly indicate that it will finalize configuration if you use the template. As for the frameworks step — does it have to be after the "initialize project" step, can't it be a part of it in a form of "choose a framework template or start with empty/generic template"?
I see a small typo on the screenshot:
> 
"The following astro content collections ___and (?)___ can be used to generate a content-type **(types?)**"
As for the templates, I think it doesn't have to be pushed to the top, but it would be good if either this step didn't close the configuration welcome screen or would clearly indicate that it will finalize configuration if you use the template. As for the frameworks step — does it have to be after the "initialize project" step, can't it be a part of it in a form of "choose a framework template or start with empty/generic template"?
<!-- github-comment-id:1806899515 -->
Is this step supposed to leave the circle un-ticked even after the content types are generated?
What do you mean exactly?
> I see a small typo on the screenshot:
Will fix this.
> Is this step supposed to leave the circle un-ticked even after the content types are generated?
What do you mean exactly?
<!-- github-comment-id:1806903246 -->
Is this step supposed to leave the circle un-ticked even after the content types are generated?
What do you mean exactly?
"Create content types" step has a single dot in circle, as if "not completed" but the "register content folders" has a ticked circle. Neither have any "(optional step)" annotation giving making an impression that the "create content types" step did not complete.
> > Is this step supposed to leave the circle un-ticked even after the content types are generated?
>
> What do you mean exactly?

"Create content types" step has a single dot in circle, as if "not completed" but the "register content folders" has a ticked circle. Neither have any "(optional step)" annotation giving making an impression that the "create content types" step did not complete.
<!-- github-comment-id:1806903908 -->
That could be an enhancement indeed, but it is also intentional, as the Astro Content Type creation is optional in cases where it couldn't retrieve the content collection configuration.
That could be an enhancement indeed, but it is also intentional, as the Astro Content Type creation is optional in cases where it couldn't retrieve the content collection configuration.
<!-- github-comment-id:1806904340 -->
I stumbled upon some ideas for slightly improving generated field types:
draft field could generate with type draft instead of boolean
publish field (anything with /.*publish.*/i could have isPublishDate: true
modified/updated (some adequate regex) would get a isModifiedDate: true
first/only image field, e.g. hero/preview/image would get isPreviewImage: true
Finally, not sure if it would be actually useful or a needless fluff yet, but something like "review your configuration" at the end of initialization process that opens the config file.
I stumbled upon some ideas for slightly improving generated field types:
- `draft` field could generate with type `draft` instead of `boolean`
- `publish` field (anything with `/.*publish.*/i` could have `isPublishDate: true`
- `modified`/`updated` (some adequate regex) would get a `isModifiedDate: true`
- first/only image field, e.g. `hero`/`preview`/`image` would get `isPreviewImage: true`
Finally, not sure if it would be actually useful or a needless fluff yet, but something like "review your configuration" at the end of initialization process that opens the config file.
<!-- github-comment-id:1806906267 -->
I had changed this but used published instead of draft. A fix is coming up.
Good suggestion
Good suggestion
Good suggestion
Finally, not sure if it would be actually useful or a needless fluff yet, but something like "review your configuration" at the end of initialization process that opens the config file.
Will think of how we can show this in the UI, or if you have an idea, feel free to share.
1. I had changed this but used `published` instead of `draft`. A fix is coming up.
2. Good suggestion
3. Good suggestion
4. Good suggestion
> Finally, not sure if it would be actually useful or a needless fluff yet, but something like "review your configuration" at the end of initialization process that opens the config file.
Will think of how we can show this in the UI, or if you have an idea, feel free to share.
<!-- github-comment-id:1806912276 -->
Another change coming up for the template section:
For the content collection section, if there are collections found, it won't be an optional section anymore:
Another change coming up for the template section:

For the content collection section, if there are collections found, it won't be an optional section anymore:

<!-- github-comment-id:1806917992 -->
When you click the final action to show the dashboard, you will now get a notification which allows you to review your configuration.
When you click the final action to show the dashboard, you will now get a notification which allows you to review your configuration.

<!-- github-comment-id:1806921541 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
zod and resulting config type
Result content types:
In words:
optionalfrom zod not respected, all fields arerequired(possibly messed up function definition/arguments order after some refactoring?)default: truetags,categories,heroImage,title, getting assigned improper types (I understand those types may not be always right, but some obvious heuristics could be put in place, some based on zods validation like.string().datetime(), some based on name)publishedandmodifiedare completely missingAside from that I would also think about the UX of the "use template" and "detect content" steps because using "blog template" — which looks like a required step — finalizes the whole configuration and opens the dashboard. I clicked it the first time thinking it would just append some defaults to configs and let me proceed with initialization, but it basically finished everything on it's own. Maybe make it the "step 0" where those buttons are on the very top.
Not sure if above comments belong to this thread or should be moved to separate issues though.
Originally posted by @T3sT3ro in https://github.com/estruyf/vscode-front-matter/issues/703#issuecomment-1804827033
@ T3sT3ro, I have been verifying against your Astro Collections, and it should now correctly create the content type.
Also added a small enhancement to show when a content type has not yet been created and when it is:
When it is created:
About the templates, they behave like a complete configuration for your site. I agree we can improve the UX on this one, but pushing it to the top would not be optimal as those templates are linked to certain frameworks/SSGs. Adding those to the top would always show them; right now, it is only shown when templates for a framework are available.
I see a small typo on the screenshot:
"The following astro content collections and (?) can be used to generate a content-type (types?)"
As for the templates, I think it doesn't have to be pushed to the top, but it would be good if either this step didn't close the configuration welcome screen or would clearly indicate that it will finalize configuration if you use the template. As for the frameworks step — does it have to be after the "initialize project" step, can't it be a part of it in a form of "choose a framework template or start with empty/generic template"?
Is this step supposed to leave the circle un-ticked even after the content types are generated?
Will fix this.
What do you mean exactly?
"Create content types" step has a single dot in circle, as if "not completed" but the "register content folders" has a ticked circle. Neither have any "(optional step)" annotation giving making an impression that the "create content types" step did not complete.
That could be an enhancement indeed, but it is also intentional, as the Astro Content Type creation is optional in cases where it couldn't retrieve the content collection configuration.
I stumbled upon some ideas for slightly improving generated field types:
draftfield could generate with typedraftinstead ofbooleanpublishfield (anything with/.*publish.*/icould haveisPublishDate: truemodified/updated(some adequate regex) would get aisModifiedDate: truehero/preview/imagewould getisPreviewImage: trueFinally, not sure if it would be actually useful or a needless fluff yet, but something like "review your configuration" at the end of initialization process that opens the config file.
publishedinstead ofdraft. A fix is coming up.Will think of how we can show this in the UI, or if you have an idea, feel free to share.
Another change coming up for the template section:
For the content collection section, if there are collections found, it won't be an optional section anymore:
When you click the final action to show the dashboard, you will now get a notification which allows you to review your configuration.