├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
└── examples
├── custom_mapper
├── README.md
└── example
│ ├── .gitignore
│ ├── Gemfile
│ ├── Rakefile
│ ├── _config.yml
│ ├── _includes
│ ├── footer.html
│ ├── head.html
│ ├── header.html
│ ├── icon-github.html
│ ├── icon-github.svg
│ ├── icon-twitter.html
│ └── icon-twitter.svg
│ ├── _layouts
│ └── default.html
│ ├── _plugins
│ ├── mappers.rb
│ └── my_reverse_mapper.rb
│ ├── _sass
│ ├── _base.scss
│ ├── _layout.scss
│ └── _syntax-highlighting.scss
│ ├── about.md
│ ├── css
│ └── main.scss
│ ├── feed.xml
│ └── index.html
├── multiple_spaces
├── README.md
└── example
│ ├── .gitignore
│ ├── Gemfile
│ ├── _config.yml
│ ├── _includes
│ ├── footer.html
│ ├── head.html
│ ├── header.html
│ ├── icon-github.html
│ ├── icon-github.svg
│ ├── icon-twitter.html
│ └── icon-twitter.svg
│ ├── _layouts
│ └── default.html
│ ├── _sass
│ ├── _base.scss
│ ├── _layout.scss
│ └── _syntax-highlighting.scss
│ ├── about.md
│ ├── bootstrap_templates
│ └── catalogue.json
│ ├── css
│ └── main.scss
│ ├── feed.xml
│ └── index.html
└── single_space
├── README.md
└── example
├── .gitignore
├── Gemfile
├── _config.yml
├── _includes
├── footer.html
├── head.html
├── header.html
├── icon-github.html
├── icon-github.svg
├── icon-twitter.html
└── icon-twitter.svg
├── _layouts
└── default.html
├── _sass
├── _base.scss
├── _layout.scss
└── _syntax-highlighting.scss
├── about.md
├── css
└── main.scss
├── feed.xml
└── index.html
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | **/Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 | In the spirit of [free software][free-sw], **everyone** is encouraged to help
3 | improve this project.
4 |
5 | [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
6 |
7 | Here are some ways *you* can contribute:
8 |
9 | * by using alpha, beta, and prerelease versions
10 | * by reporting bugs
11 | * by suggesting new features
12 | * by writing or editing documentation
13 | * by writing specifications
14 | * by writing code ( **no patch is too small** : fix typos, add comments, clean up inconsistent whitespace )
15 | * by refactoring code
16 | * by closing [issues][]
17 | * by reviewing patches
18 |
19 | [issues]: https://github.com/contentful/contentful_jekyll_examples/issues
20 |
21 | ## Submitting an Issue
22 | We use the [GitHub issue tracker][issues] to track bugs and features. Before
23 | submitting a bug report or feature request, check to make sure it hasn't
24 | already been submitted. When submitting a bug report, please include a [Gist][]
25 | that includes a stack trace and any details that may be necessary to reproduce
26 | the bug, including your gem version, Ruby version, and operating system.
27 | Ideally, a bug report should include a pull request with failing specs.
28 |
29 | [gist]: https://gist.github.com/
30 |
31 | ## Submitting a Pull Request
32 | 1. [Fork the repository.][fork]
33 | 2. [Create a topic branch.][branch]
34 | 3. Add specs for your unimplemented feature or bug fix.
35 | 4. Run `bundle exec rake test`. If your specs pass, return to step 3.
36 | 5. Implement your feature or bug fix.
37 | 6. Run `bundle exec rake test`. If your specs fail, return to step 5.
38 | 7. Add, commit, and push your changes.
39 | 8. [Submit a pull request.][pr]
40 |
41 | [fork]: http://help.github.com/fork-a-repo/
42 | [branch]: http://learn.github.com/p/branching.html
43 | [pr]: http://help.github.com/send-pull-requests/
44 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Contentful
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Contentful Jekyll Examples
2 |
3 | A useful collection of examples using the [jekyll-contentful-data-import](https://github.com/contentful/jekyll-contentful-data-import) gem
4 |
5 | ## Contentful
6 | [Contentful](https://www.contentful.com) provides a content infrastructure for digital teams to power content in websites, apps, and devices. Unlike a CMS, Contentful was built to integrate with the modern software stack. It offers a central hub for structured content, powerful management and delivery APIs, and a customizable web app that enable developers and content creators to ship digital products faster.
7 |
8 | ## What will you find here?
9 |
10 | This example repository will include examples for:
11 |
12 | * [Single Space](./examples/single_space) - Interesting Development Links Compilation
13 | * [Multiple Spaces](./examples/multiple_spaces) - Multiple Spaces Example
14 | * [Custom Mapper](./examples/custom_mapper) - Using a Custom Mapper
15 |
16 | Each example will contain a `README.md` file explaining in detail each of the Setups.
17 |
18 | They will all be using example spaces for which Read-Only keys will be provided so that you can
19 | try them out on your own
20 |
21 | ## Contributing
22 |
23 | Feel free to add your own examples by submitting a Pull Request. For more information,
24 | please check [CONTRIBUTING.md](./CONTRIBUTING.md)
25 |
--------------------------------------------------------------------------------
/examples/custom_mapper/README.md:
--------------------------------------------------------------------------------
1 | # Custom Mapper Example
2 |
3 | ## How to Run
4 |
5 | * Paste the following command inside your terminal:
6 |
7 | ```bash
8 | echo "Checkout Repository" && git clone git@github.com:contentful/contentful_jekyll_examples.git && \
9 | echo "Go to This Example's Folder" && cd contentful_jekyll_examples/examples/custom_mapper/example && \
10 | echo "Install Dependencies" && bundle install && \
11 | echo "Fetch Contentful Data" && bundle exec rake contentful && \
12 | echo "Start Jekyll Server" && bundle exec jekyll server
13 | ```
14 |
15 | Then open your browser and go to: [localhost:4000](http://localhost:4000)
16 |
17 | ## Configuration
18 |
19 | For reference of basic configuration, you can look into [single_content_type example](../single_content_type/README.md)
20 |
21 | In this case we're using a extra configuration option not described in the previous example:
22 |
23 | ```yml
24 | content_types:
25 | link: MyReverseMapper
26 | ```
27 |
28 | This option customizes the Mapper used for fetching the entry data. In this case, mapping all `link` type entries using the [`MyReverseMapper` mapper](./example/_plugins/my_reverse_mapper.rb).
29 | This mapper duplicates the data storing it in a field with it's name reversed:
30 |
31 | ```ruby
32 | class MyReverseMapper < Jekyll::Contentful::Mappers::Base
33 | def map
34 | result = super
35 | result.keys.each do |name|
36 | result[name.reverse] = result[name]
37 | end
38 |
39 | result
40 | end
41 | end
42 | ```
43 |
44 | ## Caveats
45 |
46 | Jekyll itself only allows to import code as plugins only for it's recognized plugin entry points.
47 | Therefore we are using a custom [Rakefile](./example/Rakefile) to import the mapper and required files:
48 |
49 | ```ruby
50 | require 'jekyll'
51 | require 'jekyll-contentful-data-import'
52 | require './_plugins/mappers'
53 |
54 | desc "Import Contentful Data with Custom Mappers"
55 | task :contentful do
56 | Jekyll::Commands::Contentful.process([], {}, Jekyll.configuration['contentful'])
57 | end
58 | ```
59 |
60 |
--------------------------------------------------------------------------------
/examples/custom_mapper/example/.gitignore:
--------------------------------------------------------------------------------
1 | _site
2 | _data
3 | .sass-cache
4 | .jekyll-metadata
5 |
--------------------------------------------------------------------------------
/examples/custom_mapper/example/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'jekyll', '~> 3.6', '>= 3.6.3'
4 |
5 | gem 'contentful_bootstrap'
6 | gem 'rake'
7 |
8 | group :jekyll_plugins do
9 | gem 'jekyll-contentful-data-import'
10 | end
11 |
12 |
--------------------------------------------------------------------------------
/examples/custom_mapper/example/Rakefile:
--------------------------------------------------------------------------------
1 | require 'jekyll'
2 | require 'jekyll-contentful-data-import'
3 | require './_plugins/mappers'
4 |
5 | desc "Import Contentful Data with Custom Mappers"
6 | task :contentful do
7 | Jekyll::Commands::Contentful.process([], {}, Jekyll.configuration['contentful'])
8 | end
9 |
--------------------------------------------------------------------------------
/examples/custom_mapper/example/_config.yml:
--------------------------------------------------------------------------------
1 | # Welcome to Jekyll!
2 | #
3 | # This config file is meant for settings that affect your whole blog, values
4 | # which you are expected to set up once and rarely need to edit after that.
5 | # For technical reasons, this file is *NOT* reloaded automatically when you use
6 | # 'jekyll serve'. If you change this file, please restart the server process.
7 |
8 | # Site settings
9 | title: Contentful Jekyll Custom Mapper Example
10 | email: david.litvak@contentful.com
11 | description: > # this means to ignore newlines until "baseurl:"
12 | Custom Mapper Example using Jekyll and Contentful
13 | baseurl: "" # the subpath of your site, e.g. /blog
14 | url: "http://yourdomain.com" # the base hostname & protocol for your site
15 | twitter_username: contentfulapp
16 | github_username: dlitvakb
17 | safe: false
18 |
19 | # Build settings
20 | markdown: kramdown
21 |
22 | contentful:
23 | spaces:
24 | - links:
25 | space: 3fwy09k2gc9g
26 | access_token: 25f513e34e33916336bba1d740d135035d4e1d63b87fc446da374fec3aaccaca
27 | content_types:
28 | link: MyReverseMapper
29 |
--------------------------------------------------------------------------------
/examples/custom_mapper/example/_includes/footer.html:
--------------------------------------------------------------------------------
1 |
38 |
--------------------------------------------------------------------------------
/examples/custom_mapper/example/_includes/head.html:
--------------------------------------------------------------------------------
1 |
21 |
--------------------------------------------------------------------------------
/examples/multiple_spaces/README.md:
--------------------------------------------------------------------------------
1 | # Multiple Spaces Example
2 |
3 | ## How to Run
4 |
5 | * Paste the following command inside your terminal:
6 |
7 | ```bash
8 | echo "Checkout Repository" && git clone git@github.com:contentful/contentful_jekyll_examples.git && \
9 | echo "Go to This Example's Folder" && cd contentful_jekyll_examples/examples/multiple_spaces/example && \
10 | echo "Install Dependencies" && bundle install && \
11 | echo "Create Catalogue Space" && contentful_bootstrap create_space my_catalogue --json-template bootstrap_templates/catalogue.json
12 | ```
13 |
14 | * Open `~/.contentfulrc` and copy the following information into your `_config.yml` file:
15 |
16 | ```ini
17 | ; on ~/.contentfulrc
18 |
19 | [my_catalogue]
20 | CONTENTFUL_DELIVERY_ACCESS_TOKEN =
21 | SPACE_ID =
22 | ```
23 |
24 |
25 | ```yml
26 | # on _config.yml
27 |
28 | - catalogue:
29 | space:
30 | access_token:
31 | cda_query:
32 | include: 2
33 | ```
34 |
35 | * Paste the following command inside your terminal:
36 |
37 | ```bash
38 | echo "Fetch Contentful Data" && bundle exec jekyll contentful && \
39 | echo "Start Jekyll Server" && bundle exec jekyll server
40 | ```
41 |
42 | Then open your browser and go to: [localhost:4000](http://localhost:4000)
43 |
44 | ## Configuration
45 |
46 | For reference of basic configuration, you can look into [single_content_type example](../single_content_type/README.md)
47 |
48 | In this case we're using a extra configuration option not described in the previous example:
49 |
50 | ```yml
51 | cda_query:
52 | include: 2
53 | ```
54 |
55 | This option customizes the query made to the Contentful API, see [contentful.rb](https://github.com/contentful/contentful.rb) for more info (look for filter options there). Note that by default only 100 entries will be fetched, this can be configured to up to 1000 entries using the `limit` option.
56 |
57 | In this example we'll be using [Contentful Bootstrap](https://github.com/contentful/contentful-bootstrap.rb) for setting up our own Space with multiple Content Types, and fetching
58 | the configuration from `~/.contentfulrc`
59 |
60 | The template used is located [here](./example/bootstrap_templates/catalogue.json)
61 |
62 | In this example we have two `contentful` extension activations.
63 |
--------------------------------------------------------------------------------
/examples/multiple_spaces/example/.gitignore:
--------------------------------------------------------------------------------
1 | _site
2 | _data
3 | .sass-cache
4 | .jekyll-metadata
5 |
--------------------------------------------------------------------------------
/examples/multiple_spaces/example/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'jekyll', '~> 3.6', '>= 3.6.3'
4 |
5 | gem 'contentful_bootstrap'
6 |
7 | group :jekyll_plugins do
8 | gem 'jekyll-contentful-data-import', "~> 1.0"
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/examples/multiple_spaces/example/_config.yml:
--------------------------------------------------------------------------------
1 | # Welcome to Jekyll!
2 | #
3 | # This config file is meant for settings that affect your whole blog, values
4 | # which you are expected to set up once and rarely need to edit after that.
5 | # For technical reasons, this file is *NOT* reloaded automatically when you use
6 | # 'jekyll serve'. If you change this file, please restart the server process.
7 |
8 | # Site settings
9 | title: Contentful Jekyll Multiple Space Example
10 | email: david.litvak@contentful.com
11 | description: > # this means to ignore newlines until "baseurl:"
12 | Multiple Space Example using Jekyll and Contentful
13 | baseurl: "" # the subpath of your site, e.g. /blog
14 | url: "http://yourdomain.com" # the base hostname & protocol for your site
15 | twitter_username: contentfulapp
16 | github_username: dlitvakb
17 |
18 | # Build settings
19 | markdown: kramdown
20 |
21 | contentful:
22 | spaces:
23 | - links:
24 | space: 3fwy09k2gc9g
25 | access_token: 25f513e34e33916336bba1d740d135035d4e1d63b87fc446da374fec3aaccaca
26 | - catalogue:
27 | space:
28 | access_token:
29 | cda_query:
30 | include: 2
31 |
--------------------------------------------------------------------------------
/examples/multiple_spaces/example/_includes/footer.html:
--------------------------------------------------------------------------------
1 |
38 |
--------------------------------------------------------------------------------
/examples/multiple_spaces/example/_includes/head.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/multiple_spaces/example/_includes/header.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
88 | {% for category in site.data.contentful.spaces.catalogue.category %}
89 |
90 |
91 |
92 |
93 |
94 |
{{ category.title }}
95 |
{{ category.categoryDescription }}
96 |
97 |
98 |
99 | {% endfor %}
100 |
101 |
--------------------------------------------------------------------------------
/examples/single_space/README.md:
--------------------------------------------------------------------------------
1 | # Single Content Type Example
2 |
3 | ## How to Run
4 |
5 | Paste the following command inside your terminal:
6 |
7 | ```bash
8 | echo "Checkout Repository" && git clone git@github.com:contentful/contentful_jekyll_examples.git && \
9 | echo "Go to This Example's Folder" && cd contentful_jekyll_examples/examples/single_space/example && \
10 | echo "Install Dependencies" && bundle install && \
11 | echo "Fetch Contentful Data" && bundle exec jekyll contentful && \
12 | echo "Start Jekyll Server" && bundle exec jekyll server
13 | ```
14 |
15 | Then open your browser and go to: [localhost:4000](http://localhost:4000)
16 |
17 | ## Configuration
18 |
19 | ```yml
20 | contentful:
21 | spaces:
22 | - links:
23 | space: 3fwy09k2gc9g
24 | access_token: 25f513e34e33916336bba1d740d135035d4e1d63b87fc446da374fec3aaccaca
25 | ```
26 |
27 | In [`_config.yml`](./example/_config.yml) you will find the above cited configuration block. Let's go through it line by line:
28 |
29 | * `contentful:` - Enables Contentful Extension
30 | * ` spaces:` - Tells the Extension to consider the following elements as a Space
31 | * ` - links:` - Creates a `links` Space reference, so that it can be used via that name on the views
32 | * ` space: 3fwy09k2gc9g` - Sets the Space ID
33 | * ` access_token: 25f5...` - Sets the Space Access Token
34 |
35 | ## Views
36 |
37 | ```django
38 |
39 | {% for link in site.data.contentful.spaces.links.link %}
40 |
45 | ```
46 |
47 | In [example/index.html](./example/index.html) you will find the above cited template code. Let's analyze the important bits:
48 |
49 | * `site.data.contentful.spaces` - Will contain a method for each Space you have defined, in this case `links`
50 | * Each Space will be a collection of entries fetched for it, each entry will have an ID and the Data
51 |
--------------------------------------------------------------------------------
/examples/single_space/example/.gitignore:
--------------------------------------------------------------------------------
1 | _site
2 | _data
3 | .sass-cache
4 | .jekyll-metadata
5 |
--------------------------------------------------------------------------------
/examples/single_space/example/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'jekyll', '~> 3.6', '>= 3.6.3'
4 |
5 | gem 'contentful_bootstrap'
6 |
7 | group :jekyll_plugins do
8 | gem 'jekyll-contentful-data-import'
9 | end
10 |
11 |
--------------------------------------------------------------------------------
/examples/single_space/example/_config.yml:
--------------------------------------------------------------------------------
1 | # Welcome to Jekyll!
2 | #
3 | # This config file is meant for settings that affect your whole blog, values
4 | # which you are expected to set up once and rarely need to edit after that.
5 | # For technical reasons, this file is *NOT* reloaded automatically when you use
6 | # 'jekyll serve'. If you change this file, please restart the server process.
7 |
8 | # Site settings
9 | title: Contentful Jekyll Single Space Example
10 | email: david.litvak@contentful.com
11 | description: > # this means to ignore newlines until "baseurl:"
12 | Single Space Example using Jekyll and Contentful
13 | baseurl: "" # the subpath of your site, e.g. /blog
14 | url: "http://yourdomain.com" # the base hostname & protocol for your site
15 | twitter_username: contentfulapp
16 | github_username: dlitvakb
17 |
18 | # Build settings
19 | markdown: kramdown
20 |
21 | contentful:
22 | spaces:
23 | - links:
24 | space: 3fwy09k2gc9g
25 | access_token: 25f513e34e33916336bba1d740d135035d4e1d63b87fc446da374fec3aaccaca
26 |
--------------------------------------------------------------------------------
/examples/single_space/example/_includes/footer.html:
--------------------------------------------------------------------------------
1 |
38 |
--------------------------------------------------------------------------------
/examples/single_space/example/_includes/head.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/examples/single_space/example/_includes/header.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |