KosmosisDire / obsidian-webpage-export

Export html from single files, canvas pages, or whole vaults. Direct access to the exported HTML files allows you to publish your digital garden anywhere. Focuses on flexibility, features, and style parity.
https://docs.obsidianweb.net/
MIT License
693 stars 58 forks source link

Embed javascript in export #453

Open GerkinDev opened 3 weeks ago

GerkinDev commented 3 weeks ago

Is your feature request related to a problem? Please describe. I cannot make my editor plugins relying on javascript work.

Describe the solution you'd like I would like to be able to list some JS files to import in exported pages.

Describe alternatives you've considered The plugin could automatically embed other plugin's js file with a certain name, like export.js. Thus, .obsidian/plugins/my-plugin/export.js would be copied in output dir as assets/plugins/my-plugin.js (and eventually assets/plugins/my-plugin.css)

This way, plugin authors can separate the processing part from registerMarkdownCodeBlockProcessor or registerMarkdownProcessor from the actual dom interactivity.

Additional context Add any other context or screenshots about the feature request here.

KosmosisDire commented 3 weeks ago

I'm confused about what you're trying to do. The plugin cannot include js from other plugins because plugins rely on obsidian's API. Can you describe in more detail what you want?

GerkinDev commented 3 weeks ago

Simply having some assets (JS in that case) copied to outputs and referenced in pages

KosmosisDire commented 3 weeks ago

Have you tried using the custom head content?

GerkinDev commented 3 weeks ago

No, I did not see this option, I could get around with it indeed. But it would still be pretty useful if it was doable automatically for other plugins.

I'm writing one, to embed 3D models, and if you were able to auto embed some JS/CSS files, I would gladly use it so that I can push that plugin and say it is exportable to HTML via your plugin

KosmosisDire commented 3 weeks ago

I want to, in the future add a sort of plugin feature where plugins can supply their own content to the exports. Or where user created features can be easily downloaded. In the future this will work for your needs, but that is a little ways away still.

GerkinDev commented 3 weeks ago

That would be absolutely awesome, and indeed may match my need. But maybe this wide idea can be broken down to simpler, easier to implement features ?

Anyway, I'll try to use custom headers like you suggested, and see if it works. If it doesn't, I'll fork your plugin to add a minimal example of something I need that works for me, open a PR and let you free to take it, reject it or alter it the way you like. This is the Open Source way :)

KosmosisDire commented 3 weeks ago

Sure, there are a lot of features that could be added in small parts though. So I prefer to focus on one feature at a time and implement it fully. Feel free to make a PR, if you do make sure to work in the beta branch and not the master branch.