bridgetown-sitemap 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -5
- data/CHANGELOG.md +8 -0
- data/README.md +16 -0
- data/lib/bridgetown/resource/base.rb +8 -1
- data/lib/bridgetown-sitemap/version.rb +1 -1
- data/lib/sitemap.erb +18 -0
- data/test/fixtures/src/some-subfolder/test_priority_and_changefreq.html +5 -0
- data/test/helper.rb +3 -3
- data/test/test_sitemap.rb +12 -8
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4988c349a0919aefa587882e538bf0623a5c9a994f38aa937edcf6898f644e1d
|
4
|
+
data.tar.gz: d94f6c3d21bc8800f71c038d8615fb6902e61de07b64f8c61c99729a275da104
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1752c19b00fb0de0b7f194da1ecbe20f279f6890a51f7ff5f826f4a0d5d3da9c1bbaca4331291d517552fa25ca54ae4a297421819a1fcca40e694ad172ce7e7c
|
7
|
+
data.tar.gz: de70253082a7be05ff85785b1c9ef806ed5c3e62b2fe4e32d616acb0c99dff1e83c50dd4c6b23fd216b50540511d09f2c8cedbdfad49c8d83e9590efa31136df
|
data/.rubocop.yml
CHANGED
@@ -4,22 +4,32 @@ inherit_gem:
|
|
4
4
|
rubocop-bridgetown: .rubocop.yml
|
5
5
|
|
6
6
|
AllCops:
|
7
|
-
TargetRubyVersion: 2.
|
8
|
-
Include:
|
9
|
-
- lib/**/*.rb
|
7
|
+
TargetRubyVersion: 2.7
|
10
8
|
|
11
9
|
Exclude:
|
12
10
|
- .gitignore
|
13
|
-
- .rspec
|
14
11
|
- .rubocop.yml
|
12
|
+
- "*.gemspec"
|
15
13
|
|
16
14
|
- Gemfile.lock
|
17
15
|
- CHANGELOG.md
|
18
16
|
- LICENSE.txt
|
19
17
|
- README.md
|
18
|
+
- Rakefile
|
19
|
+
- bridgetown.automation.rb
|
20
20
|
|
21
21
|
- script/**/*
|
22
|
+
- test/fixtures/**/*
|
22
23
|
- vendor/**/*
|
23
24
|
|
24
25
|
Layout/LineLength:
|
25
|
-
Max:
|
26
|
+
Max: 140
|
27
|
+
|
28
|
+
Metrics/BlockLength:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Bundler/OrderedGems:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/IfUnlessModifier:
|
35
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,22 @@ The `<lastmod>` tag in the `sitemap.xml` will reflect by priority:
|
|
30
30
|
2. The modified date of the file as reported by `git log`.
|
31
31
|
|
32
32
|
|
33
|
+
## `<priority>` and `<changefreq>` tag
|
34
|
+
You can optionally specify a _priority_ and _change frequency_ for each page in your site by adding the following to the Front Matter of each page:
|
35
|
+
|
36
|
+
```yml
|
37
|
+
sitemap_priority: 0.7
|
38
|
+
sitemap_change_frequency: weekly
|
39
|
+
```
|
40
|
+
|
41
|
+
This will add the following to the `<url>` tag in the `sitemap.xml`:
|
42
|
+
|
43
|
+
```xml
|
44
|
+
<priority>0.7</priority>
|
45
|
+
<changefreq>weekly</changefreq>
|
46
|
+
```
|
47
|
+
|
48
|
+
|
33
49
|
## Exclusions
|
34
50
|
|
35
51
|
If you would like to exclude specific pages from the sitemap set the
|
@@ -12,13 +12,20 @@ module Bridgetown
|
|
12
12
|
def latest_git_commit_date
|
13
13
|
return nil unless git_repo?
|
14
14
|
|
15
|
-
date =
|
15
|
+
date = sitemap_cache.getset(id) do
|
16
|
+
`git log -1 --pretty="format:%cI" "#{path}"`
|
17
|
+
end
|
18
|
+
|
16
19
|
Time.parse(date) if date.present?
|
17
20
|
end
|
18
21
|
|
19
22
|
def git_repo?
|
20
23
|
system "git status", out: File::NULL, err: File::NULL
|
21
24
|
end
|
25
|
+
|
26
|
+
def sitemap_cache
|
27
|
+
@sitemap_cache = Bridgetown::Cache.new("sitemap")
|
28
|
+
end
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
data/lib/sitemap.erb
CHANGED
@@ -13,6 +13,12 @@
|
|
13
13
|
<url>
|
14
14
|
<loc><%= xml_escape resource.absolute_url %></loc>
|
15
15
|
<lastmod><%= resource.sitemap_last_modified_at.localtime.xmlschema %></lastmod>
|
16
|
+
<% if resource.data.sitemap_priority %>
|
17
|
+
<priority><%= resource.data.sitemap_priority %></priority>
|
18
|
+
<% end %>
|
19
|
+
<% if resource.data.sitemap_change_frequency %>
|
20
|
+
<changefreq><%= resource.data.sitemap_change_frequency %></changefreq>
|
21
|
+
<% end %>
|
16
22
|
</url>
|
17
23
|
<% end %>
|
18
24
|
<% end %>
|
@@ -23,6 +29,12 @@
|
|
23
29
|
<url>
|
24
30
|
<loc><%= xml_escape absolute_url(generated_page.url) %></loc>
|
25
31
|
<lastmod><%= (generated_page.data.last_modified_at || site.time).localtime.xmlschema %></lastmod>
|
32
|
+
<% if generated_page.data.sitemap_priority %>
|
33
|
+
<priority><%= generated_page.data.sitemap_priority %></priority>
|
34
|
+
<% end %>
|
35
|
+
<% if generated_page.data.sitemap_change_frequency %>
|
36
|
+
<changefreq><%= generated_page.data.sitemap_change_frequency %></changefreq>
|
37
|
+
<% end %>
|
26
38
|
</url>
|
27
39
|
<% end %>
|
28
40
|
|
@@ -31,6 +43,12 @@
|
|
31
43
|
<url>
|
32
44
|
<loc><%= xml_escape absolute_url(file.relative_path) %></loc>
|
33
45
|
<lastmod><%= file.modified_time.localtime.xmlschema %></lastmod>
|
46
|
+
<% if file.data.sitemap_priority %>
|
47
|
+
<priority><%= file.data.sitemap_priority %></priority>
|
48
|
+
<% end %>
|
49
|
+
<% if file.data.sitemap_change_frequency %>
|
50
|
+
<changefreq><%= file.data.sitemap_change_frequency %></changefreq>
|
51
|
+
<% end %>
|
34
52
|
</url>
|
35
53
|
<% end %>
|
36
54
|
</urlset>
|
data/test/helper.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "minitest/autorun"
|
4
4
|
require "minitest/reporters"
|
5
|
-
require
|
5
|
+
require "minitest/hooks/default"
|
6
6
|
require "bridgetown"
|
7
7
|
|
8
8
|
Bridgetown.begin!
|
@@ -37,6 +37,6 @@ class BridgetownSitemap::Test < Minitest::Test
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def make_context(registers = {})
|
40
|
-
Liquid::Context.new({}, {}, { :
|
40
|
+
Liquid::Context.new({}, {}, { site: site }.merge(registers))
|
41
41
|
end
|
42
|
-
end
|
42
|
+
end
|
data/test/test_sitemap.rb
CHANGED
@@ -6,12 +6,12 @@ class TestSitemap < BridgetownSitemap::Test
|
|
6
6
|
def prepare_site
|
7
7
|
Bridgetown.reset_configuration!
|
8
8
|
@config = Bridgetown.configuration(
|
9
|
-
"full_rebuild"
|
10
|
-
"root_dir"
|
11
|
-
"source"
|
12
|
-
"destination"
|
13
|
-
"url"
|
14
|
-
"quiet"
|
9
|
+
"full_rebuild" => true,
|
10
|
+
"root_dir" => root_dir,
|
11
|
+
"source" => source_dir,
|
12
|
+
"destination" => dest_dir,
|
13
|
+
"url" => "https://example.com",
|
14
|
+
"quiet" => true
|
15
15
|
)
|
16
16
|
|
17
17
|
@config.run_initializers! context: :static
|
@@ -116,7 +116,7 @@ class TestSitemap < BridgetownSitemap::Test
|
|
116
116
|
end
|
117
117
|
|
118
118
|
it "includes the correct number of items for the sitemap" do
|
119
|
-
assert_equal
|
119
|
+
assert_equal 19, @sitemap.scan(%r!(?=<url>)!).count
|
120
120
|
end
|
121
121
|
|
122
122
|
it "includes generated pages in the sitemap" do
|
@@ -126,6 +126,11 @@ class TestSitemap < BridgetownSitemap::Test
|
|
126
126
|
it "renders liquid in the robots.txt" do
|
127
127
|
assert_match "Sitemap: https://example.com/sitemap.xml", @robots
|
128
128
|
end
|
129
|
+
|
130
|
+
it "renders the priority and changefreq properties if needed" do
|
131
|
+
assert_match %r!<priority>0.8</priority>!, @sitemap
|
132
|
+
assert_match %r!<changefreq>monthly</changefreq>!, @sitemap
|
133
|
+
end
|
129
134
|
end
|
130
135
|
|
131
136
|
describe "rendering the site with a base URL" do
|
@@ -215,4 +220,3 @@ class TestSitemap < BridgetownSitemap::Test
|
|
215
220
|
end
|
216
221
|
end
|
217
222
|
end
|
218
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridgetown-sitemap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ayush Newatia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bridgetown
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- test/fixtures/src/some-subfolder/htm.htm
|
124
124
|
- test/fixtures/src/some-subfolder/index.html
|
125
125
|
- test/fixtures/src/some-subfolder/test_index.html
|
126
|
+
- test/fixtures/src/some-subfolder/test_priority_and_changefreq.html
|
126
127
|
- test/fixtures/src/some-subfolder/this-is-a-subfile.html
|
127
128
|
- test/fixtures/src/some-subfolder/this-is-a-subpage.html
|
128
129
|
- test/fixtures/src/some-subfolder/xhtml.xhtml
|
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
149
|
- !ruby/object:Gem::Version
|
149
150
|
version: '0'
|
150
151
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
152
|
+
rubygems_version: 3.4.10
|
152
153
|
signing_key:
|
153
154
|
specification_version: 4
|
154
155
|
summary: Automatically generate a sitemap.xml for your Bridgetown site.
|
@@ -179,6 +180,7 @@ test_files:
|
|
179
180
|
- test/fixtures/src/some-subfolder/htm.htm
|
180
181
|
- test/fixtures/src/some-subfolder/index.html
|
181
182
|
- test/fixtures/src/some-subfolder/test_index.html
|
183
|
+
- test/fixtures/src/some-subfolder/test_priority_and_changefreq.html
|
182
184
|
- test/fixtures/src/some-subfolder/this-is-a-subfile.html
|
183
185
|
- test/fixtures/src/some-subfolder/this-is-a-subpage.html
|
184
186
|
- test/fixtures/src/some-subfolder/xhtml.xhtml
|