Replies: 5 comments 1 reply
-
FWIW I’m down to take a stab at implementation if this seems like a reasonable idea. |
Beta Was this translation helpful? Give feedback.
-
I like this idea 😄 One technical issue I think you might hit is that I don't see how you could generate the actual file from the Zod schema. But I'm sure that's something that we could figure out. |
Beta Was this translation helpful? Give feedback.
-
I also like this idea! This command would save a lot of time! |
Beta Was this translation helpful? Give feedback.
-
I like this idea! It saves my time to create md file manually. |
Beta Was this translation helpful? Give feedback.
-
Would love this idea! You could do something like… Hugo SSG does this with the |
Beta Was this translation helpful? Give feedback.
-
Body
Summary
A CLI command (like
astro create
) that could create a new file in a Content Collection.Background & Motivation
Astro stands out to me for the smoothness of its development experience that thoughtfully irons out little frictions.
npx astro add [integration]
is a perfect example of this: it doesn’t just make it easy to tack on an integration, it shows me exactly what it’s doing. Saves me time and teaches me, which is a lovely thing.Content Collections are great too, which got me thinking they could help not just with validating Markdown that’s been created but helping create it in the first place!
Each time I create a new post within a Content Collection, I go through a few steps I wouldn’t have to with a CMS:
.md
file..md
file into this new one. (Because my memory is awful.)This is not the end of the world, of course, but it’s a little set of mechanical barriers that keep me from jumping into writing and focusing on ideas. This effect is magnified for any other author or teammate that may not be as familiar with the site’s structure and content.
Since Content Collections know what shape a post should have, why not add a command that smooths out this process? It could take a collection name and title, and create a slug-friendly
.md
file in the right folder, pre-populated with relevant frontmatter and that human-friendly title.Goal
Take advantage of Content Collections and make it easier to start writing new content.
Example
Let’s say we have this schema for a blog post collection:
I’m probably cheating thinking
new Date()
would be sufficient, but pretend with me for a moment.Minimal Example w/Single Argument
The only required argument should be a reference to the content collection if the project has more than one.
This would create a new “Untitled” post for the blog collection, pre-populating frontmatter based on the content schema:
Example with Post Title
This would do the same thing, but starting with a post title. (Populating the first field in the content schema.)
Example with Post Title + Markdoc
And since Astro supports more than Markdown for Content Collections, there might as well be an option to specify the file format:
Beta Was this translation helpful? Give feedback.
All reactions