Instantly share code, notes, and snippets.

@jooray jooray/export.xml
Created Jan 21, 2019

Embed
What would you like to do?
Export jekyll as RSS, remove newlines in the full text to allow importing in wordpress. Put into pages/export.xml and regenerate your jekyll site
---
layout: null
---
{%- capture newline %}
{% endcapture -%}
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ site.title | xml_escape }}</title>
<description>{{ site.description | xml_escape }}</description>
<link>{{ site.url }}{{ site.baseurl }}/</link>
<atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
<pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
<lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
<generator>Jekyll v{{ jekyll.version }}</generator>
{% for post in site.posts limit:100 %}
<item>
<title>{{ post.title | xml_escape }}</title>
<excerpt>
{% if post.video %}
&lt;iframe width=&quot;1280&quot; height=&quot;720&quot; src=&quot;{% if post.video contains 'youtu' %}https://www.youtube.com/embed/{{ post.video | remove: "https://www.youtube.com/watch?v=" | remove: "https://youtu.be/" | xml_escape }}{% elsif post.video contains 'vimeo.com' %}https://player.vimeo.com/video/{{ post.video | remove: "https://vimeo.com/" | xml_escape }}{% else %}{{ post.video | xml_escape }}{% endif %}{{ post.embed | xml_escape }}&quot; frameborder=&quot;0&quot; allowfullscreen>&lt;/iframe&gt;
{% endif %}
{{ post.excerpt | xml_escape }}</excerpt>
<description>
{% if post.video %}
&lt;iframe width=&quot;1280&quot; height=&quot;720&quot; src=&quot;{% if post.video contains 'youtu' %}https://www.youtube.com/embed/{{ post.video | remove: "https://www.youtube.com/watch?v=" | remove: "https://youtu.be/" | xml_escape }}{% elsif post.video contains 'vimeo.com' %}https://player.vimeo.com/video/{{ post.video | remove: "https://vimeo.com/" | xml_escape }}{% else %}{{ post.video | xml_escape }}{% endif %}{{ post.embed | xml_escape }}&quot; frameborder=&quot;0&quot; allowfullscreen>&lt;/iframe&gt;
{% endif %}
{% if post.podcast_link %}
&lt;p&gt; &lt;audio controls&gt; &lt;source src=&quot;{{ post.podcast_link }}&quot; type=&quot;audio/mpeg&quot;/&gt; &lt;/audio&gt;&lt;br/&gt; &lt;a href=&quot;{{ post.podcast_link }}&quot; download&gt;Download audio&lt;/a&gt; &lt;/p&gt;
{% endif %}
{% if post.video or post.embed %}
{% elsif post.image %}
&lt;figure&gt; &lt;a href=&quot;{{ post.url | absolute_url | xml_escape }}&quot; title=&quot;{{ post.title | escape_once | xml_escape }}&quot;&gt;&lt;img src=&quot;{{ "/images/" | absolute_url }}{{ post.image | xml_escape }}&quot; alt=&quot;{{ post.title | escape_once | xml_escape }}&quot;&gt;&lt;/a&gt; {% if post.caption_url and post.caption %} &lt;figcaption&gt; &lt;a href=&quot;{{ post.caption_url | xml_escape }}&quot;&gt;{{ post.caption | xml_escape }}&lt;/a&gt; &lt;/figcaption&gt; {% elsif post.caption %} &lt;figcaption&gt; {{ post.caption |xml_escape }} &lt;/figcaption&gt; {% endif %} &lt;/figure&gt;
{% endif %}
{{ post.content | replace: newline, ' ' | xml_escape }}</description>
<pubDate>{{ post.date | date_to_rfc822 | replace: '00:00:00', '08:00:00' }}</pubDate>
<link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
<guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
{% for cat in post.categories %}
<category>{{ cat | xml_escape }}</category>
{% endfor %}
</item>
{% endfor %}
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment