Comments (9)
I'm not entirely sure what you mean here. Can you provide a better example of the problem?
from cryogen.
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.
Exactly.
from cryogen.
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.
@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:
- Offer a site.url placeholder
- Dynamic image resource path rewriting
- An own image syntax (comes down to option 2).
from cryogen.
@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.
+1 for option 1 here as well
from cryogen.
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.
Thank you very much for adding this functionality! 👍
from cryogen.
Related Issues (20)
- Serve headless with containerized development environment HOT 4
- Add support for author avatar and bio for multiple authors HOT 1
- How to change the port for `lein serve` HOT 4
- [feature] pagination for posts summary HOT 1
- [feature] unique files names HOT 1
- `clojure -M:build` exite code HOT 1
- Sass-location theme error, with fresh project, using lotus/nucleus HOT 1
- deploy in nginx, but" hljs is not defined" HOT 1
- Doc: "full build" is only mentioned in the end. HOT 3
- MathJax integration HOT 2
- RSS feed: only publishes article's "summary" HOT 2
- deps-new error when creating a new site HOT 2
- Auto-refresh feature doesn't work with Nucleus template. HOT 1
- How to upgrade old blog to newest version of Cryogen HOT 1
- How to set one post to the home page HOT 1
- Router serving static-file only works locally HOT 6
- Lotus Theme error, "resource content/themes/lotus/img not found" HOT 2
- The `/blog/blog/` problem HOT 3
- Cryogen does not list as a clojure project HOT 2
- Feature Request: Marking posts as "unlisted" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cryogen.