obsidian-export icon indicating copy to clipboard operation
obsidian-export copied to clipboard

Can I replace spaces with dashes for URL generation?

Open assopri opened this issue 3 years ago • 4 comments

Using your solution to generate website with Obsidian Zola. Can I somehow override the default URL generation mechanics of obsidian-export (to change spaces to dashes)?

assopri avatar Apr 08 '22 17:04 assopri

This would be useful for many use cases, not only Zola!

benbohmer avatar May 01 '22 11:05 benbohmer

It's currently pretty hard-coded: https://github.com/zoni/obsidian-export/blob/6af4c9140cb08898b782b694e6ecb3e23ad88a92/src/lib.rs#L674-L688 I'm not against making this more configurable/overrideable, but it would be nice to know what you're trying to achieve and why you would want a different behavior.

The intent of obsidian-export is to give you a normalized CommonMark input to feed to later processors (such as static site generators like Zola). It's obsidian-export's job to make sure that input has valid links/paths on the local filesystem that those tools can resolve correctly (which it currently does).

It's not intended to construct final URLs directly, as that's really the job of Hugo, Zola, etc. to do (because it's also their concern to change .md to .html, or to link to a directory instead of a file in case of "pretty URLs")

zoni avatar Nov 05 '22 14:11 zoni

Related issue: https://github.com/zoni/obsidian-export/issues/73

zoni avatar Nov 05 '22 14:11 zoni

I also had an issue where I wanted to leave the spaces encoded as literal spaces, for a responsive image partial for a hugo site, which uses the image in markdown as

{{< imgh src="filename with spaces.png" alt="alt-text" >}}

(since the image filename itself is not renamed to be percent encoded by obsidian-export the partial does not find the asset)

Of course the partial could be changed to first percent encode the resource, but I'm just getting started with hugo...

Partial I'm using: https://mijndertstuij.nl/posts/hugo-responsive-images/

smaroukis avatar Oct 17 '23 09:10 smaroukis