lostintangent / gistpad

VS Code extension for managing and sharing code snippets, notes and interactive samples using GitHub Gists
https://aka.ms/gistpad
MIT License
944 stars 61 forks source link

Add optional frontmatter snippet to new notes. #217

Open thoughtstile opened 3 years ago

thoughtstile commented 3 years ago

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.

lostintangent commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.