GithubHelp home page GithubHelp logo

Comments (9)

lacarmen avatar lacarmen commented on June 3, 2024

I'm not entirely sure what you mean here. Can you provide a better example of the problem?

from cryogen.

jayp avatar jayp commented on June 3, 2024

I believe @kremers is saying that a relative resource like img/pic01.png works from /blog/index.html but not from /blog/pages/about.html or /blog/posts/2014-12-03-hello-world.html.

Rewriting URL for resources may be needed.

from cryogen.

kremers avatar kremers commented on June 3, 2024

Exactly.

from cryogen.

dl1ely avatar dl1ely commented on June 3, 2024

I recommend using absolute URLs like /img/pic01.png. Cryogen works with a single common img resource directory in mind (or many of them, if you configure :resources like that in config.edn). But still, all resources are copied to public/resources/ and not its sub dirs, so having relative URLs in posts does not seem to sensible here.

from cryogen.

kremers avatar kremers commented on June 3, 2024

@dl1ely doesn't work since things like /blog/img are configured and some configurations rely on reverse proxies / specific url's.

Absolute URLs (on server side) are a bad pattern anyway (think about image resources are migrated to a CDN).

Other systems like jekyll offer a {{ site.url }} placeholder that defaults to the current site url without resources such as "assets" or "img".

http://jekyllrb.com/docs/posts/#including-images-and-resources

If such a site url is put absolutely in every page, a change to templates/config.edn >> :blog-prefix will have no effect on the image. Resulting in 404 for all images.

So there are various options how to fix this. For example:

  1. Offer a site.url placeholder
  2. Dynamic image resource path rewriting
  3. An own image syntax (comes down to option 2).

from cryogen.

dl1ely avatar dl1ely commented on June 3, 2024

@kremers URL for images are given in the Markdown files. Cryogen renders them and does not touch the contents itself. Upfront, i think that is a good thing in terms of simplicity. That is why i personally dislike your options 2 and 3, to be honest.

But it should be easy to do option 1, i think. Selmer tags should survive md-to-html-string conversation fine, and could be substituted in Selmers render-file function. We just have to supply a placeholder there, constructed from the :site-url and :blog-prefix keys of config.edn

from cryogen.

yogthos avatar yogthos commented on June 3, 2024

+1 for option 1 here as well

from cryogen.

lacarmen avatar lacarmen commented on June 3, 2024

I've added this function to the compiler. It should inject the blog prefix in front of links to local resources.

For example, if you want to add img/pic01.png to a post and your blog prefix is /blog, the markdown should be ![pic01](/img/pic01.png). (Note the leading slash, this is required.) When the post gets compiled, the respective html will be <img src="/blog/img/cryogen.png">

Ps. I've migrated the compiler into a library here

from cryogen.

kremers avatar kremers commented on June 3, 2024

Thank you very much for adding this functionality! 👍

from cryogen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.