mosra / m.css

A no-nonsense, no-JavaScript CSS framework, site and documentation theme for content-oriented websites
https://mcss.mosra.cz
Other
406 stars 92 forks source link

m.htmlsanity link expansion works only when the same link referenced in content #130

Closed bedlamzd closed 4 years ago

bedlamzd commented 4 years ago

Hello! Have been trying out your plugin htmlsanity for expanding links in meta fields to link cover image. Expansion works only when this same image is referenced within content. Otherwise there is a warning "Unable to find file" and it pastes just "{static}path/to/file" instead of a proper path.

mosra commented 4 years ago

Hi!

(and sorry for a late reply, was busy elsewhere). Hum, this shouldn't be. I'm having the exact same use case (for example directly on the index page of https://mcss.mosra.cz -- https://github.com/mosra/m.css/blob/master/doc/index.rst#mcss ) and everything works as it should.

I dug a bit and found this, is this where you're trying to use this feature? I forgot most of Pelican internals since last time, but I think to make this work you need to explicitly pass the path to images via STATIC_PATHS in pelicanconf.py (here's what I do for the mcss website). Not sure why it works when you reference the image in content tho -- probably some additional automagic I am not aware of.

bedlamzd commented 4 years ago

Hi!

Yes, you found right project. I kind of paused it since then and I am completely new to pelican. So I may use it wrong and it is why it isn't working.

Anyway thanks for help. When I start working on this project again I will try your solution and write back here if it worked for me.

bedlamzd commented 4 years ago

I returned to the project and specified static directory and it didn't work I tried to debug and trace what is going on and found out that in content._context[key] keys (i.e. paths to images) contain 'static' like in 'static/img/cover.png'. But parsed path does not contain 'static'. I think I use something in a wrong way, because it is strange that in your case it does work. static folder supposed to be in content directory? should pelican copy static folder to output or only files inside it?

bedlamzd commented 4 years ago

I finally figured it out. Didn't know that {static} does not imply any path and I should specify full path relative to content directory, not to static directory