middleman-title 0.0.2 → 0.0.3
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/.travis.yml +6 -4
- data/CHANGELOG.md +4 -0
- data/README.md +46 -26
- data/Rakefile +5 -0
- data/lib/middleman-title/version.rb +1 -1
- data/middleman-title.gemspec +1 -1
- data/spec/extension_spec.rb +8 -8
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 905b57b97b08acd97e7305dca9bb78ce393d3cfb
|
4
|
+
data.tar.gz: 7792436582d0ecabeb0e0e340de188e28804db5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ba9d6c37b5d0e2fcd187861b799cf244fa42858ec00a9b1a9a13f4797a92a709ea245da95ddd7db6d3472437cc87eebf8cbb36e84003b5629d318e65a7bdb19
|
7
|
+
data.tar.gz: d2058bf70334d73aa65fda7fa3721b31feb1a7a450ad3bec4a604215c02fb8472bcf67a905345f6141eef053c00d93192930cc4c3bdc99dfa0f1f3d1295b5312
|
data/.travis.yml
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
1
3
|
rvm:
|
2
|
-
-
|
3
|
-
- 2.
|
4
|
+
- 2.3.0
|
5
|
+
- 2.2.0
|
4
6
|
- 2.1.0
|
5
|
-
|
7
|
+
- 2.0.0
|
6
8
|
addons:
|
7
9
|
code_climate:
|
8
|
-
repo_token: 96d351848c244b986b3888fd13d12b6e916dcfbc83474c8a7a2c03d1c7827ecf
|
10
|
+
repo_token: 96d351848c244b986b3888fd13d12b6e916dcfbc83474c8a7a2c03d1c7827ecf
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,11 +7,15 @@ This Middleman extension allows you to easily set page titles for your website.
|
|
7
7
|
## Setup
|
8
8
|
Add the following line to `Gemfile`, then run `bundle install`:
|
9
9
|
|
10
|
-
|
10
|
+
```Ruby
|
11
|
+
gem 'middleman-title'
|
12
|
+
```
|
11
13
|
|
12
14
|
After installation, activate the extension in `config.rb`:
|
13
15
|
|
14
|
-
|
16
|
+
```Ruby
|
17
|
+
activate :title, site: 'Your Website Name', separator: ' — '
|
18
|
+
```
|
15
19
|
|
16
20
|
*The separator is optional and will default to a dash.*
|
17
21
|
|
@@ -20,58 +24,74 @@ After installation, activate the extension in `config.rb`:
|
|
20
24
|
|
21
25
|
In your layout file, you can use the `page_title` helper to output the current page title:
|
22
26
|
|
23
|
-
|
27
|
+
```HTML+ERB
|
28
|
+
<title><%= page_title %></title>
|
29
|
+
```
|
24
30
|
|
25
31
|
Then, add a page `title` to the Frontmatter any page:
|
26
32
|
|
27
|
-
|
28
|
-
|
29
|
-
|
33
|
+
```YAML
|
34
|
+
---
|
35
|
+
title: The title of this page goes here
|
36
|
+
---
|
37
|
+
```
|
30
38
|
|
31
39
|
This would output:
|
32
40
|
|
33
|
-
|
34
|
-
|
41
|
+
```Text
|
42
|
+
The title of this page goes here — Your Website Name
|
43
|
+
```
|
35
44
|
|
36
45
|
## Outputting Website Name First
|
37
46
|
|
38
47
|
Sometimes it is desirable to put the website name first, such as on the home page. This can be done by setting `title_reverse` to `true` in the frontmatter of the page.
|
39
48
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
```YAML
|
50
|
+
---
|
51
|
+
title: The title of this page goes here
|
52
|
+
title_reverse: true
|
53
|
+
---
|
54
|
+
```
|
44
55
|
|
45
56
|
This would output:
|
46
57
|
|
47
|
-
|
58
|
+
```Text
|
59
|
+
Your Website Name — The title of this page goes here
|
60
|
+
```
|
48
61
|
|
49
62
|
You can also put the website name first on every page by setting it when you activate the extension:
|
50
63
|
|
51
|
-
|
64
|
+
```Ruby
|
65
|
+
activate :title, site: 'Your Website Name', reverse: true
|
66
|
+
```
|
52
67
|
|
53
68
|
Then on any page where you want the website name to come last, you can set `title_reverse` to false in the Frontmatter:
|
54
69
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
70
|
+
```YAML
|
71
|
+
---
|
72
|
+
title: The title of this page goes here
|
73
|
+
title_reverse: false
|
74
|
+
---
|
75
|
+
```
|
59
76
|
|
60
77
|
|
61
78
|
## Multi-level Page Titles
|
62
79
|
|
63
80
|
When your website has heirachy, it is sometimes desirable to have multiple parts to the title. This can be done by passing an array in the Frontmatter:
|
64
81
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
82
|
+
```YAML
|
83
|
+
---
|
84
|
+
title:
|
85
|
+
- John Doe
|
86
|
+
- Staff
|
87
|
+
---
|
88
|
+
```
|
70
89
|
|
71
90
|
This would output:
|
72
91
|
|
73
|
-
|
74
|
-
|
92
|
+
```Text
|
93
|
+
John Doe — Staff — Your Website Name
|
94
|
+
```
|
75
95
|
|
76
96
|
## Contributing
|
77
97
|
|
@@ -79,4 +99,4 @@ This would output:
|
|
79
99
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
100
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
101
|
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
-
5. Create a new Pull Request
|
102
|
+
5. Create a new Pull Request
|
data/Rakefile
CHANGED
data/middleman-title.gemspec
CHANGED
data/spec/extension_spec.rb
CHANGED
@@ -5,9 +5,9 @@ describe Middleman::Title::Helpers do
|
|
5
5
|
|
6
6
|
describe '#page_title' do
|
7
7
|
before(:each) do
|
8
|
-
h.stub_chain(:
|
9
|
-
h.stub_chain(:
|
10
|
-
h.stub_chain(:
|
8
|
+
h.stub_chain(:title_options, :site).and_return(false)
|
9
|
+
h.stub_chain(:title_options, :separator).and_return(' — ')
|
10
|
+
h.stub_chain(:title_options, :reverse).and_return(false)
|
11
11
|
|
12
12
|
h.stub_chain(:current_page, :data, :title).and_return(nil)
|
13
13
|
h.stub_chain(:current_page, :data, :title_site).and_return(nil)
|
@@ -15,7 +15,7 @@ describe Middleman::Title::Helpers do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'website name is set' do
|
18
|
-
before(:each) { h.stub_chain(:
|
18
|
+
before(:each) { h.stub_chain(:title_options, :site).and_return('Website Name') }
|
19
19
|
|
20
20
|
context 'page name is set' do
|
21
21
|
before(:each) { h.stub_chain(:current_page, :data, :title).and_return('How to Say Hello to the World') }
|
@@ -35,20 +35,20 @@ describe Middleman::Title::Helpers do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'puts website name first when activate reverse is true' do
|
38
|
-
h.stub_chain(:
|
38
|
+
h.stub_chain(:title_options, :reverse).and_return(true)
|
39
39
|
expect(h.page_title).to eq 'Website Name — How to Say Hello to the World'
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'puts website name last when activate reverse is true but frontmatter is false' do
|
43
|
-
h.stub_chain(:
|
43
|
+
h.stub_chain(:title_options, :reverse).and_return(true)
|
44
44
|
h.stub_chain(:current_page, :data, :title_reverse).and_return(false)
|
45
45
|
expect(h.page_title).to eq 'How to Say Hello to the World — Website Name'
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'separator is set' do
|
49
49
|
it 'to a vertical bar' do
|
50
|
-
h.stub_chain(:
|
51
|
-
h.stub_chain(:
|
50
|
+
h.stub_chain(:title_options, :site).and_return('Website Name')
|
51
|
+
h.stub_chain(:title_options, :separator).and_return(' | ')
|
52
52
|
expect(h.page_title).to eq 'How to Say Hello to the World | Website Name'
|
53
53
|
end
|
54
54
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-title
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Cypret
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
description: A Middleman extension for setting the page title
|
@@ -67,10 +67,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
69
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
70
|
+
rubygems_version: 2.5.1
|
71
71
|
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: A Middleman extension for setting the page title
|
74
74
|
test_files:
|
75
75
|
- spec/extension_spec.rb
|
76
76
|
- spec/spec_helper.rb
|
77
|
+
has_rdoc:
|