Open O-Willis opened 9 months ago
Hello @O-Willis, thanks a lot for the feedback, this seems like a really great feature.
I can think of two options right now:
I'm feeling more inclined for the second option, since it would simplify replacing variables and templates for individual files by using the files' metadata.
For more advanced use cases, I thought about implementing advanced templates similarly to a web component or react element, something like:
<Template file="path_to_file.html">
children that will be rendered inside the template document tree (at a specified outlet)
<\Template>
If your ok with it, I could make a pull request on this feature. I've been playing around with obsidian for a little while now and would be happy to help with development on this plugin.
I was also wondering, how would you handle locating the html files?
As I understand it, the obsidian api doesn't normally detect html files. I think this.registerExtensions(['html', 'htm'], "markdown");
allows the obsidian api to do this though.
Sort of as a follow up but I was thinking about two important things to go with template/html support:
From what I've seen in the plugin's current state, everything that a note needs (i.e. assets, images, etc.) are only retrieved when the note is loaded in the web page. Then when the user leaves the page to go to another, the resources are removed, and new ones (if they exist) are retrieved and rendered. This can get tricky if Javascript code is going to be executed, which pose similar questions to the html file handling (where should it be stored, would it also be a var or would it be stored in the .md frontmatter) On top of that, if live editing on notes (and also multi-user collaboration...👀) is in consideration as a future feature, this might need some additional handling.
The more I look into this plugin and think about the possibilities, the more its kinda hyping me up! In my mind, this plugin could fix the issues many people have with Obsidian that note taking apps like Notion handle through being web-hosted, such as synchronous multi-user editing, use on an OS that Obsidian wouldn't typically support, etc. There's actually a mega-thread on this topic: forum link here
I think this is an amazing plugin but I was thinking, it would be amazing if you could implement a way to insert html templates into the custom index.html section. In the
Replaceable Variables
section, you could have atype
section in between thename
andvalue
sections to specify the action needed to either stringify or read the given file/value. I'm not very familiar with how Electron works in this regard but I think by allowing this feature, you would enable two super important things: