How can put a banner by a template? #1340
Replies: 1 comment
-
Hello, const file = tp.file.find_tfile(tp.file.title);
await app.fileManager.processFrontMatter(file, (frontmatter) => {}) // this will remove the quotes of a correctly formatted banner key in the frontmatter Either open en issue on the obsidian banner plugin to correctly handle not escaped url or with obsidian to change the behavior of In the mean time if you install obsidian-linter you can add a rule in the force Yaml Section > "Force Yaml Escape on key" and add "banner" and update your template as follow : const file = tp.file.find_tfile(tp.file.title);
await app.fileManager.processFrontMatter(file, (frontmatter) => {
frontmatter["banner"] = "https://source.unsplash.com/800x0/?scenery;"
})
await app.plugins.plugins["obsidian-linter"].runLinterFile(file) The linter is there to "clean" your markdown files, it can do a lot of great thing, one of them is to clean the Yaml section. Here we force the key "banner" to be escaped, meaning adding the quotes around the url. By default the linter might also clean other stuff you don't want so you should try first on test files and adjust the settings of the linter. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am putting a banner by using a template like this:
with this snippet, a
banner: https://source.unsplash.com/800x0/?scenery;
could be put in yaml. however, this banner does not show up in live-preview or source mode, only it works in reading mode.after playing a while, I found that if a
"
could be put before and afterhttps://source.unsplash.com/800x0/?scenery;
, it will be shown up both in reading mode and editing mode.Question now is, how to put the
"
before and afterhttps://source.unsplash.com/800x0/?scenery;
?I tried ``https://source.unsplash.com/800x0/?scenery;`` and ""
https://source.unsplash.com/800x0/?scenery;
"" infrontmatter["banner"] = "https://source.unsplash.com/800x0/?scenery;"
, both them leads to template error.Is that anyway to add
"
it the template?Thanks for your helps in advance.
Beta Was this translation helpful? Give feedback.
All reactions