bridgetown-sitemap 2.0.1 → 2.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac539efc37311d68fe991191d98d0f88c47318128e2bf529a177af6814066a14
4
- data.tar.gz: 4fed4074d7a52b2fa807b35bf9e14d29649c09d0b6e8629dad7a7a56ce21423e
3
+ metadata.gz: 4988c349a0919aefa587882e538bf0623a5c9a994f38aa937edcf6898f644e1d
4
+ data.tar.gz: d94f6c3d21bc8800f71c038d8615fb6902e61de07b64f8c61c99729a275da104
5
5
  SHA512:
6
- metadata.gz: 289155d9d0827a4c257c127227666f1d489b931521876d42b031000583a524b10d87e62e46991b6cc420d6958bbd94d1a1a9a49e125691cdd101c7e89056b52d
7
- data.tar.gz: ab85ae03365fa0f65e4c1a12e32bff50c21e2254e5fa067594a58ee064021c15a03b495d8f21db009cd173670b420aad1d8cffe97e88130833dff766eccc4197
6
+ metadata.gz: 1752c19b00fb0de0b7f194da1ecbe20f279f6890a51f7ff5f826f4a0d5d3da9c1bbaca4331291d517552fa25ca54ae4a297421819a1fcca40e694ad172ce7e7c
7
+ data.tar.gz: de70253082a7be05ff85785b1c9ef806ed5c3e62b2fe4e32d616acb0c99dff1e83c50dd4c6b23fd216b50540511d09f2c8cedbdfad49c8d83e9590efa31136df
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # main
2
2
 
3
+ # 2.0.2 / 27-06-2023
4
+
5
+ * Add support for priority and changefreq tags.
6
+
3
7
  # 2.0.1 / 04-04-2023
4
8
 
5
9
  * Cache `git log` value for last modified date.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BridgetownSitemap
4
- VERSION = "2.0.1"
4
+ VERSION = "2.0.2"
5
5
  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>
@@ -0,0 +1,5 @@
1
+ ---
2
+ sitemap_priority: 0.8
3
+ sitemap_change_frequency: monthly
4
+ ---
5
+ This is a page with custom sitemap priority and change frequency.
data/test/test_sitemap.rb CHANGED
@@ -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 18, @sitemap.scan(%r!(?=<url>)!).count
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
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.1
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-04-04 00:00:00.000000000 Z
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.2.32
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