tomfran / typo

A simple Hugo theme
https://tomfran.github.io/
MIT License
247 stars 76 forks source link

[CLOSED] Support relative paths in markdown images #42

Closed runofthemillgeek closed 2 weeks ago

runofthemillgeek commented 2 weeks ago

Adds code from Hugo's built-in render-image hook and modifies it slightly to support relative image paths in markdown files.

Previously, we'd have to spell the absolute path from root of the hugo site or make directories for each individual post which is what Hugo recommend. But this was very inefficient. This change allows us to use editors like Obsidian, VSCode and have them render the images correctly. It also supports Hugo's page bundles for rendering images as a result. Based on the order, I believe page bundles are given priority so that works out.

i.e, if you have the following tree:

content
└── posts
   ├── _index.md
   ├── hello.md
   ├── images
   │  └── test.png
   └── test.png

You can now include images in hello.md in the following ways:

![](test.png)
![](images/test.png)
![](./test.png)
![](./images/test.png)
runofthemillgeek commented 2 weeks ago

@tomfran was this accidentally closed when you force-pushed? 🤔

tomfran commented 2 weeks ago

Probably, sorry for that. Can you re-fork and re-open this PR please? At least the repo size is now down to 2MB 😅

runofthemillgeek commented 2 weeks ago

Huge reduction! :) I'll cherry-pick the commit and force-push, should be enough.

runofthemillgeek commented 2 weeks ago

Hmm okay, maybe need to open another.