middleman-dato 0.5.23 → 0.5.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +25 -7
- data/lib/middleman_dato/meta_tags/title.rb +11 -5
- data/lib/middleman_dato/version.rb +1 -1
- data/middleman-dato.gemspec +2 -0
- data/spec/spec_helper.rb +7 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ea2407f7c1f9ac3fcaca5adcb47bc2f6ac3785f
|
4
|
+
data.tar.gz: 98d081e1bb716dad649277d023d8acb389b1e1ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca3280632ab6d349820407a098d57a53369a7e142dedeabc6009109104c55582da26f9c15fd9104711c1f8e61f1c71d80678baaed1fcd3700d47d13e8ffe7885
|
7
|
+
data.tar.gz: 58f973e3e4490aa575518e4b86f006bf940a9daf3397d701f00292531774d1596ecfa95c9e96e1396dff73b3d79d634f12367e22e55c594a85bf2a92b4d7deb2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# DatoCMS extension for DatoCMS
|
2
2
|
|
3
|
-
[](https://travis-ci.org/datocms/middleman-dato)
|
3
|
+
[](https://coveralls.io/github/datocms/middleman-dato?branch=master) [](https://travis-ci.org/datocms/middleman-dato) [](https://badge.fury.io/rb/middleman-dato)
|
4
4
|
|
5
5
|
Middleman Dato is a Middleman extension to use the Middleman static site generator together with the API-driven DatoCMS, a fully customizable administrative backend for your static websites.
|
6
6
|
|
@@ -34,11 +34,29 @@ activate :dato,
|
|
34
34
|
|
35
35
|
## Middleman helpers
|
36
36
|
|
37
|
-
|
37
|
+
Using this extension you can access to any item stored in your site by item type.
|
38
|
+
Let's start with a basic example: in your Middleman `source/index.html.erb` file
|
39
|
+
add the following lines:
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
```erb
|
42
|
+
<% dato.item_types.each do |item_type| %>
|
43
|
+
<h1>Items of type "<%= item_type.name %>"</h1>
|
44
|
+
<% dato.items_of_type(item_type).each do |item| %>
|
45
|
+
<pre><%= item.to_hash %></pre>
|
46
|
+
<% end %>
|
47
|
+
<% end %>
|
48
|
+
```
|
49
|
+
|
50
|
+
Run the server with `bundle exec middleman` and you'll see the content of every
|
51
|
+
item you created on your DatoCMS site. Awesome!
|
52
|
+
|
53
|
+
### Querying items
|
54
|
+
|
55
|
+
Beside dumping every content available, this extension makes it easy also to
|
56
|
+
return items belonging to a specific Item Type.
|
57
|
+
|
58
|
+
If your site has an Item Type with `article` as API identifier, you can get
|
59
|
+
the complete array of items with `dato.articles` — yep, **the API identifier pluralized**.
|
42
60
|
|
43
61
|
If a Item Type is marked as Singleton (ie. `about_page`) you don't need to pluralize and
|
44
62
|
a call to `dato.about_page` directly returns the Item (or `nil`, if still hasn't been created
|
@@ -49,7 +67,7 @@ You can query any Item field value with a method called like the field API ident
|
|
49
67
|
If a Item Type has a String field with Title appeareance, than the item responds to `.slug`,
|
50
68
|
returning a slugified version of the title itself (or the item identifier, if the title is empty).
|
51
69
|
|
52
|
-
You can use
|
70
|
+
You can use these methods in the Middleman `config.rb` file, as well as within your views:
|
53
71
|
|
54
72
|
```ruby
|
55
73
|
<% dato.articles.each do |article| %>
|
@@ -15,11 +15,17 @@ module MiddlemanDato
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def title
|
18
|
-
@title ||=
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
@title ||= begin
|
19
|
+
title_field = item.fields.find do |field|
|
20
|
+
field.field_type == 'string' &&
|
21
|
+
field.appeareance[:type] == 'title'
|
22
|
+
end
|
23
|
+
|
24
|
+
seo_field_with_fallback(
|
25
|
+
:title,
|
26
|
+
item && title_field && item.send(title_field.api_key)
|
27
|
+
)
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def title_with_suffix
|
data/middleman-dato.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
|
|
20
20
|
end
|
21
21
|
s.require_paths = ['lib']
|
22
22
|
|
23
|
+
s.add_development_dependency('coveralls')
|
24
|
+
|
23
25
|
s.add_runtime_dependency('middleman-core', ['>= 3.3.12'])
|
24
26
|
s.add_runtime_dependency('dato', ['>= 0.1.22'])
|
25
27
|
s.add_runtime_dependency('semantic')
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
6
|
+
SimpleCov::Formatter::HTMLFormatter,
|
7
|
+
Coveralls::SimpleCov::Formatter
|
8
|
+
])
|
9
|
+
|
3
10
|
SimpleCov.start do
|
4
11
|
add_filter '/spec/'
|
5
12
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-dato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: coveralls
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: middleman-core
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|