views:

27

answers:

1

My blog, powerred by Jekyll, serves out a Atom feed.

---
layout: nill
rooturi: http://stefan.artspace44.com
---

<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"&gt;

...

{% for post in site.posts %}
  <entry>
    <title>{{ post.title }}</title>
    <link href="{{ page.rooturi }}{{ post.url }}" />
    <updated>{{post.date | date_to_xmlschema }}</updated>
    <id>{{ page.rooturi }}{{ post.id }}</id>
    <content type="html">{{ post.content | xml_escape }}</content>
  </entry>
 {% endfor %}
</feed>

I need to change the content of each post, so that

<img href="/images/01.jpg" />
<a href="/2010/post/">Post</a>

becomes:

<img href="http://stefan.artspace44.com/images/01.jpg" />
<a href="http://stefan.artspace44.com/2010/post/"&gt;Post&lt;/a&gt;

I was thinking of doing something along the lines of

<content type='html'>
  {{ post.content | make_hrefs_base page.rooturi }}
</content>

Where would I code this in jekyll or liquid, and how could I solve the problem of changing only the href values that point to "/" and not "http://otherdomain.com/"?

Thank you

+1  A: 

Where would I code this in jekyll or liquid?

In the recently-released Jekyll 0.6.0, you can create your own plugins, including Liquid tag plugins. You can check out the Jekyll plugin documentation for more info, but that would be your best bet.

How could I solve the problem of changing only the href values that point to "/" and not "http://otherdomain.com/"?

Seems pretty easy. In your custom Liquid tag, check to see if the first character is a '/'; if it is, then prepend your new domain. You could probably use a Ruby HTML parser to find all instances of <a>, and then change the href attributes as appropriate.

mipadi