logseq / logseq

A privacy-first, open-source platform for knowledge management and collaboration. Download link: http://github.com/logseq/logseq/releases. roadmap: http://trello.com/b/8txSM12G/roadmap
https://logseq.com
GNU Affero General Public License v3.0
30.26k stars 1.77k forks source link

Template generated frontmatter is placed as block instead proper page's fronmatter if `template-include-parent: false` is used #4055

Open maciejmatczak opened 2 years ago

maciejmatczak commented 2 years ago

Describe the bug

I am using template to fill new empty page, template-include-parent: false guarantees me that everything is placed on a root level on a page. I do want to fill the new page's frontmatter as well, so I do have one as a children for the template.

After using the template it is placed as any other block, though. Looks like it's not possible to use template to generate new page's frontmatter if template-include-parent: false is used.

To Reproduce

Create such template:

- Template
    - template:: testtemplate
      template-including-parent:: false
        - prop1:: hello
          prop2:: world
        - # Notes

Then, create new page and use /Template, pick testtemplate, you get:

- prop1:: hello
  prop2:: world
- # Notes

Expected behavior

While not explicit and obvious, I believe an additional action "check if first block is not frontmatter" should be performed (I believe such step happens if we type in frontmatter manually):

prop1:: hello
prop2:: world
- # Notes

I can workaround it moderately easy with going back to the formatter, pretend I edit it, ESC.

Desktop (please complete the following information):

cannibalox commented 2 years ago

try to create your template like this instead (inside any page, like [[templates]] for instance):

- tags:: test
  keyword:: test
  template:: frontmatter

then invoke it in the first block of a new page

or this if you need the # note section

- template
  template:: frontmatter2
  template-including-parent:: false
    - tags:: test
      keyword:: test
    - # note

the resulting page should work (the query on page-tags shows it picked up the properties as page-properties image

update: actually this is not working , see later comments

maciejmatczak commented 2 years ago

@cannibalox, did you try to replicate my issue?

I added your proposed template, it does differ a bit, but it's structure doesn't have an influence over my issue. Pasted on the bottom of my templates container: image

And used it, same problem persists:

image image

Are you sure you didn't actually "enter through" (move cursor to the incorrect frontmatter, hit enter while on the last property, proceed to hitting enter)? This should actually make Logseq understood you edited frontmatter, which fires some additional markdown cleanup, frontmatter no longer is under a bullet point:

logseq-frontmatter-issue

cannibalox commented 2 years ago

actually you're right, I should have double checked it sry for the trouble. updating the previous comment

mattiasdh commented 2 weeks ago

I confirm this is still unsolved as of Logseq 0.10.9. It would be great to see YAML Frontmatter in templates supported, for 'backwards' compatibility with other markdown tools like Zettlr etc.