Jekyll XML Source is a plugin that will download XML from external sites and makes the data available when generating a site. It also works for RSS feeds. Once downloaded it is converted to JSON.
From the root of your Jekyll project, if there isn't a plugins directory, create one:
mkdir _plugins
Setup the plugins directory by adding the following to the _config.yml
:
plugins_dir: ./_plugins
Then download load jekyll_xml_source.rb
to the plugin directory:
curl -o ./_plugins/jekyll_xml_source.rb https://raw.githubusercontent.com/mcred/jekyll-xml-source/master/jekyll_xml_source.rb
Add the following dependencies to the Gemfile:
gem "json"
gem "activesupport"
Add the following to _config.yml
:
jekyll_xml:
- data: nasa
source: https://www.nasa.gov/rss/dyn/solar_system.rss
cache: true
Add the following to index.html
or any other frontend file:
{% assign nasa = site.data.nasa.rss.channel.item | sort: 'title' %}
{% for item in nasa %}
{{item.title}} <br />
{% endfor %}
jekyll_xml
is the root collection for the plugin. Each of the following items in the collection have 3 parameters.data
is an arbitrary name that is used to save the results tosite.data
. If you were to usedata: nasa
the resulting fetched data will be available insite.data.nasa
.source
is the URL from which the data should be fetched.cache
is an optional parameter. Iftrue
, it will save the results to_data/*DATA*.json
.
- Fork the project.
- Make your bug fix or new feature.
- Add tests for your code.
- Send a pull request.
Contributions must be signed as User Name <[email protected]>
. Make sure to set up Git with user name and email address. Bug fixes should branch from the current stable branch. New features should be based on the master
branch.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Issues should be reported here.
This is code is licensed under the MIT License. Full license is available here.