bhugo
bhugo copied to clipboard
Insert images from anywhere
Instead of having to save images in the Hugo images folder, it would be great to save them anywhere to insert into Bear and then have Bhugo copy the image into the Hugo directory.
Probably will require an additional query to determine image location.
Hi Zach! Wanted to thank you for this library - it's made writing my blog way more enjoyable. Seems like you aren't really updating the library anymore, but if you had plans to - this feature would be at the top of my list for sure!
Also happy to try to take a crack at a PR if you had some context or ideas on the best way to do this.
Hey @michaellee1! Thanks, I'm glad you are finding this library useful.
If you want to take a crack at implementing this, I'm happy to help review. It's been awhile since I've looked at this, but I think to implement this, I think we'd need to do a couple of things. The text that Bear saves for an image looks like this:
[image:7BD34BA7-1D41-4634-B42B-0C6D20B88E33-34561-0000B3447A4CA4D0/img.jpg]
Where that ID I believe is some internal Bear ID for the image, and img.jpg
is the name of the image. I think what you would need to do is in the function that parses image lines (parseImages
) you would need to query the Bear DB (it's a SQLite DB, it's what I'm polling for changes to notes) and retrieve the directory of the image. Then you would need to read and copy that file from wherever it's saved to the Hugo image directory with original name of the image. There is already an environment variable for specifying the Hugo image directory in the config.
I think that should be enough to get started, happy to work through it more on a PR if you would like to take a crack at it!