Skip to content
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

Add optional frontmatter snippet to new notes. #217

Open
thoughtstile opened this issue Mar 25, 2021 · 4 comments
Open

Add optional frontmatter snippet to new notes. #217

thoughtstile opened this issue Mar 25, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@thoughtstile
Copy link

thoughtstile commented Mar 25, 2021

Is your feature request related to a problem? Please describe.
Currently, when clicking on the calendar icon in VSCode, a new markdown file is autogenerated and added to a configurable directory.

The filename is the current date, and the same date is used to populate the first header in the generated file:

2021-03-25.md

# March 25, 2021

I really like how one click gets you to immediately writing a new note for the specific date.

Describe the solution you'd like

I would like it if it was possible to change the generated content in the markdown file to include some basic frontmatter metadata so that it would look something like this:

2021-03-25.md

---
title: March 25, 2021
---

Describe alternatives you've considered
I can just write in the required frontmatter text every time, but it kind of goes against the spirit of clicking on the button and immediately getting to writing.

Additional context
I've been using this app to integrate with the blogging side of docusaurus.
It'd be great to generate entirely new blog posts just from the click of a single button.

@thoughtstile thoughtstile added the enhancement New feature or request label Mar 25, 2021
@lostintangent
Copy link
Owner

Hey! I love this suggestion 😄

Would it be sufficient to simply say that you want a front-matter title as well when generating new daily pages? Or would you want to be able to specify the entire front-matter block? I just ask because I could probably add a setting to allow generating a front-matter section for new page, that simply auto-generated the title based on the date. But if you'd want to also add other content to the template, than we'd probably need another, more generic solution.

@thoughtstile
Copy link
Author

thoughtstile commented Mar 26, 2021

I would personally be more than happy with the first suggestion of generating a front-matter section with a title based on the date via a toggleable setting. This would make it practically frictionless to add new posts for my particular use case.

It would also be good to have a more generic solution, but this may be a bit more complex.

For instance, Docusaurus's example post has 9 separate fields:

---
title: Welcome Docusaurus v2
author: Joel Marcey
author_title: Co-creator of Docusaurus 1
author_url: https://github.com/JoelMarcey
author_image_url: https://graph.facebook.com/611217057/picture/?height=200&width=200
tags: [hello, docusaurus-v2]
description: This is my first post on Docusaurus 2.
image: https://i.imgur.com/mErPwqL.png
hide_table_of_contents: false
---

Granted, it would be convenient to have certain static fields like author, author_url, author_image_url, and hide_table_of_contents automatically filled out for you when making a new post.

The generic solution would probably be more valuable to users that are making posts for a website with multiple writers or if there were repeating metadata when making new posts.

But again, it would be great to have the non-generic solution as well.

@lostintangent
Copy link
Owner

lostintangent commented Mar 27, 2021

I wonder if it would make sense to allow adding a DAILY_TEMPLATE.md file to the repo, and specify whatever content you want in there. Then, whenever you create a new daily page, it would auto-populate the file with the contents from that template file.

In order to parameterize it, the template could support mustache placeholders (e.g. {{foo}}) that would be rendered properly whenever a page was created from it. To start, we could support a {{title}} placeholder, but we could add more over time. The nice thing about this solution, is that it would allow you to define the front-matter you want, but would also be quite a bit more flexible (and also interoperable with other note-taking solutions). It would also be similar to how GitHub enables issue/PR templates. Thoughts?

Example DAILY_TEMPLATE.md

---
title: {{title}}
author: Joel Marcey
author_title: Co-creator of Docusaurus 1
author_url: https://github.com/JoelMarcey
author_image_url: https://graph.facebook.com/611217057/picture/?height=200&width=200
tags: [hello, docusaurus-v2]
description: This is my first post on Docusaurus 2.
image: https://i.imgur.com/mErPwqL.png
hide_table_of_contents: false
---

@thoughtstile
Copy link
Author

That sounds great, pretty much exactly what I would would want as a user, especially if the feature gains the ability to also add more mustache placeholders over time.

I feel like the solution is also flexible enough to cover a large amount of use cases, minimizing a lot of redundant busywork with the click of a button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants