clayh53 / tufte-jekyll

Minimal Jekyll blog styled to resemble the look and layout of Edward Tufte's books
MIT License
620 stars 206 forks source link

eliminate need to hard-code urls to image tags #15

Closed ghost closed 8 years ago

ghost commented 8 years ago

Is your baseurl issue related to this? https://github.com/jekyll/jekyll/issues/332#issuecomment-18952908 Are you sure it's your code that is causing the problem?

EDIT: I realize now that Jekyll variables are not available inside a Markdown post document, so site.baseurl needs to be added automatically within @clayh53's custom plugins.

ghost commented 8 years ago

I've made a gist which prepends site.baseurl in front of the image url.

Take a look and let me know how bad my Ruby skills are :smile:

I borrowed from this plugin: https://github.com/jhauraw/jekyll-url-helper-filter-plugin

clayh53 commented 8 years ago

Thanks! I'll take a look at it, and add it to the theme if I don't run into any snags. It should make writing posts a little more intuitive

ghost commented 8 years ago

closing because after experimenting with the code I wrote, I found it wouldn't solve the problem. Your baseurl issue is related to something else. Good luck!

clayh53 commented 8 years ago

Thanks. The ‘baseurl’ thing is mostly related to getting the sample site to display on the gh_pages branch. Most users will want to edit _config.yml and set the baseurl to blank or ‘/‘

On Nov 17, 2015, at 10:00 AM, Nick notifications@github.com wrote:

closing because after experimenting with the code I wrote, I found it wouldn't solve the problem. Your baseurl issue is related to something else. Good luck!

— Reply to this email directly or view it on GitHub.

ghost commented 8 years ago

welp after fiddling with some code, I was able to actually get this to work with a baseurl of / and a liquid tags with relative urls for example:

{% fullwidth 'assets/img/123.png' 'A caption for the image' %}

So no more need for hard coded urls.

I'll fix up a pull request for you to look at.

ghost commented 8 years ago

OK I've added the pull request which fixes this issue.

clayh53 commented 8 years ago

The one thing I want to check is whether links to external urls still work. I have gotten tied up on some other things, and haven't had time to do any checking. Thanks for you work on this. Its great to have all these contributions!

On Nov 20, 2015, at 12:22 AM, Nick notifications@github.com wrote:

OK I've added the pull request which fixes this issue.

— Reply to this email directly or view it on GitHub.

ghost commented 8 years ago

The one thing I want to check is whether links to external urls still work.

Good point, I had forgotten that. I'll check and update my PR with necessary changes.

ghost commented 8 years ago

d65d85a adds checks for external image urls and omits baseurl if image url contains http/https

ghost commented 8 years ago

Ok! I tested and it's working well for me so far. I updated the Readme to include some examples of external image urls.