Open gorootde opened 1 year ago
I was just thinking that a couple of days ago.
In my case, clicking on a [[2023-04-12]]
placeholder will not create the daily note, but simply use the generic template.
First of all, there is a pretty simple solution to your problem: if you hover on a placeholder you will see a "Create note from template" in the hover, which will allow you to select the template to apply.
At the same time I was thinking of a way to make this simpler and more automated.
My current thinking is adding a property to templates called from_placeholder
(or something like that), which would include a regex that will be matched against the placeholder text. E.g.
---
foam_template:
filepath: "📆 daily-notes/$FOAM_DATE_YEAR-$FOAM_DATE_MONTH-$FOAM_DATE_DATE.md"
from_placeholder: ^(19|20)\d\d-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$
name: "Daily note"
---
# ${FOAM_DATE_YEAR}-${FOAM_DATE_MONTH}-${FOAM_DATE_DATE}
Still thinking about the details on how to go about it, happy to get feedback on it.
This is exactly what I was describing. I'd love to see it implemented like that!
Upon index creation we may just index the from_placeholder
fields as well, and use the first matching entry of that list to choose the template to apply.
Is your feature request related to a problem? Please describe.
It is annoying to be forced to create pages for placeholders manually, because
Ctrl+click
does not apply the matching template.My current workflow looks way to often like this :
[[users/example]]
Cmd+click
on the link/
instead of/users
User
Describe the solution you'd like
As a user I'd expect placeholders to apply the matching template automatically upon
Ctrl+click
.[[users/example]]
Ctrl+click
on the linkfilepath: users/$FOAM_SLUG
is automatically chosen and I am prompted for the$FOAM_TITLE
To do so, foam would require a way to configure a "template schema" that is used for looking up the correct template in step 3.). The schema ideally would be a regex / glob pattern either configured as setting or within the frontmatter of templates.
Describe alternatives you've considered
Eventhough #850 would reduce the pain, it would certainly not help with creating the files in the correct path.
Screenshots or Videos
No response