bridgetown-sitemap 1.2.0 → 2.0.0
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/.github/workflows/tests.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +18 -23
- data/bridgetown-sitemap.gemspec +1 -1
- data/lib/bridgetown-sitemap/builder.rb +0 -8
- data/lib/bridgetown-sitemap/version.rb +1 -1
- data/lib/bridgetown-sitemap.rb +3 -1
- data/lib/sitemap.erb +6 -6
- data/test/fixtures/config/initializers.rb +12 -0
- data/test/helper.rb +9 -46
- data/test/test_sitemap.rb +145 -145
- metadata +6 -6
- data/test/fixtures/bridgetown.config.yml +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b46fc691359d55c28bae04bec5dc2712f995bfeda3b7f9a59d854e9594c61b5d
|
|
4
|
+
data.tar.gz: b5479047c0ccac7ec071a9aaf3428f9d615935548c8dd9d4d9b28f79769bf33a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73dd830ca3fc53df0a3850bb2a1fb6b230f2ebe62202281f019ae4d48b3bb414c5f9531a0bafda378b6cd22a94de62ae0f711be0206768ad3f8c2306c4dd2f34
|
|
7
|
+
data.tar.gz: b37f746153cf2c39ce6fe774194fc7e09ac5be31615c555c7f26e438bb32343b1783f517dfa07fdb94acebae756ea48690714411e9f44e61db6efbf117943c19
|
data/.github/workflows/tests.yml
CHANGED
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
strategy:
|
|
15
15
|
matrix:
|
|
16
16
|
ruby_version: [2.7.7, 3.0.5, 3.1.3, 3.2.0]
|
|
17
|
-
bridgetown_version: [1.
|
|
17
|
+
bridgetown_version: [1.2.0]
|
|
18
18
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
|
19
19
|
# Has to be top level to cache properly
|
|
20
20
|
env:
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -10,26 +10,19 @@ Bridgetown plugin to silently generate a sitemaps.org compliant sitemap for your
|
|
|
10
10
|
1. Install the plugin with the following command:
|
|
11
11
|
|
|
12
12
|
```shell
|
|
13
|
-
bundle add bridgetown-sitemap
|
|
13
|
+
bundle add bridgetown-sitemap
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
2. Add the following to your site's `
|
|
16
|
+
2. Add the following to your site's `config/initializers.rb`:
|
|
17
17
|
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<br>
|
|
23
|
-
|
|
24
|
-
**This plugin only supports Bridgetown sites that use the [resource content engine](https://www.bridgetownrb.com/docs/resources).**
|
|
25
|
-
|
|
26
|
-
This can be configured by adding the following line to your site's `bridgetown.config.yml`:
|
|
18
|
+
```ruby
|
|
19
|
+
Bridgetown.configure do |config|
|
|
20
|
+
config.url = "https://example.com" # the base hostname & protocol for your site
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
init :"bridgetown-sitemap"
|
|
23
|
+
end
|
|
30
24
|
```
|
|
31
25
|
|
|
32
|
-
|
|
33
26
|
## `<lastmod>` tag
|
|
34
27
|
The `<lastmod>` tag in the `sitemap.xml` will reflect by priority:
|
|
35
28
|
|
|
@@ -46,15 +39,17 @@ sitemap flag to `false` in the front matter for the page.
|
|
|
46
39
|
sitemap: false
|
|
47
40
|
```
|
|
48
41
|
|
|
49
|
-
To exclude multiple files, add a glob config to your `
|
|
42
|
+
To exclude multiple files, add a glob config to your `config/initializers.rb` file.
|
|
50
43
|
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
```ruby
|
|
45
|
+
Bridgetown.configure do |config|
|
|
46
|
+
# ...
|
|
47
|
+
|
|
48
|
+
config.defaults << {
|
|
49
|
+
"scope" => { "path" => "assets/**/*.pdf" },
|
|
50
|
+
"values" => { "sitemap" => false }
|
|
51
|
+
}
|
|
52
|
+
end
|
|
58
53
|
```
|
|
59
54
|
|
|
60
55
|
## Testing
|
|
@@ -75,4 +70,4 @@ defaults:
|
|
|
75
70
|
|
|
76
71
|
Bridgetown Sitemap is released under the [MIT License](https://opensource.org/licenses/MIT).
|
|
77
72
|
|
|
78
|
-
Copyright ©
|
|
73
|
+
Copyright © 2023 [Ayush Newatia](https://twitter.com/ayushn21)
|
data/bridgetown-sitemap.gemspec
CHANGED
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
|
|
19
19
|
spec.required_ruby_version = ">= 2.7.0"
|
|
20
20
|
|
|
21
|
-
spec.add_dependency "bridgetown", ">= 1.0", "< 2.0"
|
|
21
|
+
spec.add_dependency "bridgetown", ">= 1.2.0", "< 2.0"
|
|
22
22
|
|
|
23
23
|
spec.add_development_dependency "bundler"
|
|
24
24
|
spec.add_development_dependency "rake"
|
|
@@ -3,17 +3,9 @@
|
|
|
3
3
|
require "fileutils"
|
|
4
4
|
|
|
5
5
|
module BridgetownSitemap
|
|
6
|
-
class UnsupportedContentEngine < StandardError; end
|
|
7
|
-
|
|
8
6
|
class Builder < Bridgetown::Builder
|
|
9
7
|
def build
|
|
10
8
|
hook :site, :pre_render, priority: :low do |site|
|
|
11
|
-
unless site.uses_resource?
|
|
12
|
-
Bridgetown.logger.error "\n\nbridgetown-sitemap only supports the resource content engine"
|
|
13
|
-
Bridgetown.logger.info "Add `content_engine: 'resource'` to your bridgetown.config.yml\n\n"
|
|
14
|
-
raise UnsupportedContentEngine
|
|
15
|
-
end
|
|
16
|
-
|
|
17
9
|
@site = site
|
|
18
10
|
|
|
19
11
|
@site.generated_pages << sitemap unless file_exists?("sitemap.xml")
|
data/lib/bridgetown-sitemap.rb
CHANGED
data/lib/sitemap.erb
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
<% end %>
|
|
19
19
|
|
|
20
20
|
<% site.generated_pages.each do |generated_page| %>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
<% next if ["sitemap.erb", "robots.liquid"].include? generated_page.name %>
|
|
22
|
+
<% next if generated_page.data.sitemap == false %>
|
|
23
|
+
<url>
|
|
24
|
+
<loc><%= xml_escape absolute_url(generated_page.url) %></loc>
|
|
25
|
+
<lastmod><%= (generated_page.data.last_modified_at || site.time).localtime.xmlschema %></lastmod>
|
|
26
|
+
</url>
|
|
27
27
|
<% end %>
|
|
28
28
|
|
|
29
29
|
<% page.data.static_files.each do |file| %>
|
data/test/helper.rb
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
require "minitest/autorun"
|
|
4
4
|
require "minitest/reporters"
|
|
5
|
-
require
|
|
6
|
-
require "
|
|
7
|
-
|
|
5
|
+
require 'minitest/hooks/default'
|
|
6
|
+
require "bridgetown"
|
|
7
|
+
|
|
8
|
+
Bridgetown.begin!
|
|
9
|
+
|
|
10
|
+
require File.expand_path("../lib/bridgetown-sitemap", __dir__)
|
|
8
11
|
|
|
9
12
|
# Report with color.
|
|
10
13
|
Minitest::Reporters.use! [
|
|
@@ -14,15 +17,13 @@ Minitest::Reporters.use! [
|
|
|
14
17
|
]
|
|
15
18
|
|
|
16
19
|
class BridgetownSitemap::Test < Minitest::Test
|
|
20
|
+
extend Minitest::Spec::DSL
|
|
21
|
+
include Minitest::Hooks
|
|
22
|
+
|
|
17
23
|
ROOT_DIR = File.expand_path("fixtures", __dir__)
|
|
18
24
|
SOURCE_DIR = File.join(ROOT_DIR, "src")
|
|
19
25
|
DEST_DIR = File.expand_path("dest", __dir__)
|
|
20
26
|
|
|
21
|
-
def build_site
|
|
22
|
-
@site = Bridgetown::Site.new(config)
|
|
23
|
-
process_site
|
|
24
|
-
end
|
|
25
|
-
|
|
26
27
|
def root_dir(*files)
|
|
27
28
|
File.join(ROOT_DIR, *files)
|
|
28
29
|
end
|
|
@@ -38,42 +39,4 @@ class BridgetownSitemap::Test < Minitest::Test
|
|
|
38
39
|
def make_context(registers = {})
|
|
39
40
|
Liquid::Context.new({}, {}, { :site => site }.merge(registers))
|
|
40
41
|
end
|
|
41
|
-
|
|
42
|
-
def config_overrides
|
|
43
|
-
{}
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def metadata_overrides
|
|
47
|
-
{}
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def process_site
|
|
53
|
-
@metadata = {
|
|
54
|
-
"name" => "My Awesome Site",
|
|
55
|
-
"author" => {
|
|
56
|
-
"name" => "Ada Lovejoy",
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
metadata = @metadata.merge(metadata_overrides).to_yaml.sub("---\n", "")
|
|
61
|
-
File.write(source_dir("_data/site_metadata.yml"), metadata)
|
|
62
|
-
@site.process
|
|
63
|
-
FileUtils.rm(source_dir("_data/site_metadata.yml"))
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def config
|
|
67
|
-
@config ||= Bridgetown.configuration(Bridgetown::Utils.deep_merge_hashes({
|
|
68
|
-
"full_rebuild" => true,
|
|
69
|
-
"root_dir" => root_dir,
|
|
70
|
-
"source" => source_dir,
|
|
71
|
-
"destination" => dest_dir,
|
|
72
|
-
"content_engine" => "resource",
|
|
73
|
-
"url" => "https://example.com",
|
|
74
|
-
"quiet" => true
|
|
75
|
-
},
|
|
76
|
-
config_overrides
|
|
77
|
-
))
|
|
78
|
-
end
|
|
79
42
|
end
|
data/test/test_sitemap.rb
CHANGED
|
@@ -3,216 +3,216 @@
|
|
|
3
3
|
require "helper"
|
|
4
4
|
|
|
5
5
|
class TestSitemap < BridgetownSitemap::Test
|
|
6
|
+
def prepare_site
|
|
7
|
+
Bridgetown.reset_configuration!
|
|
8
|
+
@config = Bridgetown.configuration(
|
|
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
|
+
)
|
|
16
|
+
|
|
17
|
+
@config.run_initializers! context: :static
|
|
18
|
+
@site = Bridgetown::Site.new(@config)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def process_site
|
|
22
|
+
@site.process
|
|
23
|
+
end
|
|
6
24
|
|
|
7
|
-
|
|
8
|
-
|
|
25
|
+
describe "rendering the site with defaults" do
|
|
26
|
+
before(:all) do
|
|
27
|
+
prepare_site
|
|
28
|
+
process_site
|
|
9
29
|
|
|
10
|
-
|
|
30
|
+
@sitemap = File.read(dest_dir("sitemap.xml"))
|
|
31
|
+
@robots = File.read(dest_dir("robots.txt"))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "creates the sitemap without a layout" do
|
|
11
35
|
assert File.exist?(dest_dir("sitemap.xml"))
|
|
36
|
+
refute_match %r!THIS IS MY LAYOUT!, @sitemap
|
|
12
37
|
end
|
|
13
38
|
|
|
14
|
-
|
|
39
|
+
it "creates robots.txt without a layout" do
|
|
15
40
|
assert File.exist?(dest_dir("robots.txt"))
|
|
41
|
+
refute_match %r!\ATHIS IS MY LAYOUT!, @robots
|
|
16
42
|
end
|
|
17
43
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
refute_match %r!THIS IS MY LAYOUT!, @sitemap
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
should "put all the pages in the sitemap" do
|
|
26
|
-
assert_match %r!<loc>https://example\.com/</loc>!, @sitemap
|
|
27
|
-
assert_match %r!<loc>https://example\.com/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
should "not put files with output: false into the sitemap" do
|
|
31
|
-
refute_match %r!/other_things/test2\.html</loc>!, @sitemap
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
should "performs URI encoding of site paths" do
|
|
35
|
-
assert_match %r!<loc>https://example\.com/this%20url%20has%20an%20%C3%BCmlaut</loc>!, @sitemap
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
should "put all the posts in the sitemap" do
|
|
39
|
-
assert_match %r!<loc>https://example.com/2021/05/06/may-the-sixth/</loc>!, @sitemap
|
|
40
|
-
assert_match %r!<loc>https://example.com/2021/03/04/march-the-fourth/</loc>!, @sitemap
|
|
41
|
-
assert_match %r!<loc>https://example.com/2021/03/02/march-the-second/</loc>!, @sitemap
|
|
42
|
-
assert_match %r!<loc>https://example.com/2019/07/14/last-modified-at/</loc>!, @sitemap
|
|
43
|
-
end
|
|
44
|
+
it "puts all the pages in the sitemap" do
|
|
45
|
+
assert_match %r!<loc>https://example\.com/</loc>!, @sitemap
|
|
46
|
+
assert_match %r!<loc>https://example\.com/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
|
|
47
|
+
end
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
assert_match %r!<lastmod>2021-03-02T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
|
|
49
|
+
it "does not put files with output: false into the sitemap" do
|
|
50
|
+
refute_match %r!/other_things/test2\.html</loc>!, @sitemap
|
|
51
|
+
end
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
end
|
|
54
|
-
end
|
|
53
|
+
it "performs URI encoding of site paths" do
|
|
54
|
+
assert_match %r!<loc>https://example\.com/this%20url%20has%20an%20%C3%BCmlaut</loc>!, @sitemap
|
|
55
|
+
end
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
it "puts all the posts in the sitemap" do
|
|
58
|
+
assert_match %r!<loc>https://example.com/2021/05/06/may-the-sixth/</loc>!, @sitemap
|
|
59
|
+
assert_match %r!<loc>https://example.com/2021/03/04/march-the-fourth/</loc>!, @sitemap
|
|
60
|
+
assert_match %r!<loc>https://example.com/2021/03/02/march-the-second/</loc>!, @sitemap
|
|
61
|
+
assert_match %r!<loc>https://example.com/2019/07/14/last-modified-at/</loc>!, @sitemap
|
|
62
|
+
end
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
it "generates the correct date for each of the posts" do
|
|
65
|
+
assert_match %r!<lastmod>2021-05-06T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
|
|
66
|
+
assert_match %r!<lastmod>2021-03-04T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
|
|
67
|
+
assert_match %r!<lastmod>2021-03-02T00:00:00(-|\+)\d+:\d+</lastmod>!, @sitemap
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
assert_match %r!<
|
|
69
|
+
# This doesn't work on CI because it runs a git command which isn't allowed I guess
|
|
70
|
+
unless ENV["GITHUB_ACTIONS"]
|
|
71
|
+
assert_match %r!<lastmod>2019-07-14T18:22:00\+00:00</lastmod>!, @sitemap
|
|
68
72
|
end
|
|
73
|
+
end
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
it "puts all the static HTML files in the sitemap.xml file" do
|
|
76
|
+
assert_match %r!<loc>https://example\.com/some-subfolder/this-is-a-subfile\.html</loc>!, @sitemap
|
|
77
|
+
end
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
it "does not include assets or any static files that aren't .html" do
|
|
80
|
+
refute_match %r!/assets/sample_image\.jpg</loc>!, @sitemap
|
|
81
|
+
refute_match %r!/feeds/atom\.xml</loc>!, @sitemap
|
|
82
|
+
end
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
it "includes assets or any static files with .xhtml and .htm extensions" do
|
|
85
|
+
assert_match %r!<loc>https://example\.com/some-subfolder/xhtml\.xhtml</loc>!, @sitemap
|
|
86
|
+
assert_match %r!<loc>https://example\.com/some-subfolder/htm\.htm</loc>!, @sitemap
|
|
87
|
+
end
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
it "includes assets or any static files with .pdf extension" do
|
|
90
|
+
assert_match %r!<loc>https://example\.com/assets/sample_pdf\.pdf</loc>!, @sitemap
|
|
91
|
+
end
|
|
85
92
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
it "does not include any files named 404.html" do
|
|
94
|
+
refute_match %r!404.html!, @sitemap
|
|
95
|
+
end
|
|
89
96
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
end
|
|
97
|
+
it "does not include any static files that have set 'sitemap: false'" do
|
|
98
|
+
refute_match %r!/excluded_files/excluded\.pdf!, @sitemap
|
|
99
|
+
end
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
it "does not include any static html files that have set 'sitemap: false'" do
|
|
102
|
+
refute_match %r!/excluded_files/html_file\.html!, @sitemap
|
|
103
|
+
end
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
it "does not include posts that have set 'sitemap: false'" do
|
|
106
|
+
refute_match %r!exclude-this-post!, @sitemap
|
|
107
|
+
end
|
|
102
108
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
it "does not include pages that have set 'sitemap: false'" do
|
|
110
|
+
refute_match %r!exclude-this-page!, @sitemap
|
|
111
|
+
refute_match %r!about!, @sitemap
|
|
106
112
|
end
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
it "correctly formats timestamps of static files" do
|
|
115
|
+
assert_match %r!/this-is-a-subfile\.html</loc>\s+<lastmod>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(-|\+)\d{2}:\d{2}</lastmod>!, @sitemap
|
|
116
|
+
end
|
|
110
117
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
it "includes the correct number of items for the sitemap" do
|
|
119
|
+
assert_equal 18, @sitemap.scan(%r!(?=<url>)!).count
|
|
120
|
+
end
|
|
114
121
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
end
|
|
122
|
+
it "includes generated pages in the sitemap" do
|
|
123
|
+
assert_match %r!<loc>https://example.com/generated_page/</loc>!, @sitemap
|
|
118
124
|
end
|
|
119
|
-
end
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
config.base_path = "/baseurl"
|
|
124
|
-
build_site
|
|
126
|
+
it "renders liquid in the robots.txt" do
|
|
127
|
+
assert_match "Sitemap: https://example.com/sitemap.xml", @robots
|
|
125
128
|
end
|
|
129
|
+
end
|
|
126
130
|
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
describe "rendering the site with a base URL" do
|
|
132
|
+
before(:all) do
|
|
133
|
+
prepare_site
|
|
134
|
+
@config.base_path = "/baseurl"
|
|
135
|
+
process_site
|
|
129
136
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
137
|
+
@sitemap = File.read(dest_dir("sitemap.xml"))
|
|
138
|
+
@robots = File.read(dest_dir("robots.txt"))
|
|
139
|
+
end
|
|
133
140
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
end
|
|
141
|
+
it "adds the baseurl to the static files in the sitemap" do
|
|
142
|
+
assert_match %r!<loc>https://example\.com/baseurl/some-subfolder/this-is-a-subfile\.html</loc>!, @sitemap
|
|
143
|
+
end
|
|
138
144
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
assert_match %r!<loc>https://example.com/baseurl/2021/03/02/march-the-second/</loc>!, @sitemap
|
|
143
|
-
assert_match %r!<loc>https://example.com/baseurl/2019/07/14/last-modified-at/</loc>!, @sitemap
|
|
144
|
-
end
|
|
145
|
+
it "adds the baseurl to the pages in the sitemap" do
|
|
146
|
+
assert_match %r!<loc>https://example\.com/baseurl/</loc>!, @sitemap
|
|
147
|
+
assert_match %r!<loc>https://example\.com/baseurl/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
|
|
145
148
|
end
|
|
146
149
|
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
it "adds the baseurl to the posts in the sitemap" do
|
|
151
|
+
assert_match %r!<loc>https://example.com/baseurl/2021/05/06/may-the-sixth/</loc>!, @sitemap
|
|
152
|
+
assert_match %r!<loc>https://example.com/baseurl/2021/03/04/march-the-fourth/</loc>!, @sitemap
|
|
153
|
+
assert_match %r!<loc>https://example.com/baseurl/2021/03/02/march-the-second/</loc>!, @sitemap
|
|
154
|
+
assert_match %r!<loc>https://example.com/baseurl/2019/07/14/last-modified-at/</loc>!, @sitemap
|
|
155
|
+
end
|
|
149
156
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
end
|
|
157
|
+
it "adds the baseurl in the robots.txt" do
|
|
158
|
+
assert_match "Sitemap: https://example.com/baseurl/sitemap.xml", @robots
|
|
153
159
|
end
|
|
154
160
|
end
|
|
155
161
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
describe "rendering the site with a url that needs URI encoding" do
|
|
163
|
+
before(:all) do
|
|
164
|
+
prepare_site
|
|
165
|
+
@config.url = "http://ümlaut.example.org"
|
|
166
|
+
process_site
|
|
161
167
|
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
@sitemap = File.read(dest_dir("sitemap.xml"))
|
|
169
|
+
end
|
|
164
170
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
end
|
|
171
|
+
it "performs URI encoding of site url" do
|
|
172
|
+
assert_match %r!<loc>http://xn--mlaut-jva.example.org/</loc>!, @sitemap
|
|
173
|
+
assert_match %r!<loc>http://xn--mlaut-jva.example.org/some-subfolder/this-is-a-subpage/</loc>!, @sitemap
|
|
174
|
+
assert_match %r!<loc>http://xn--mlaut-jva.example.org/2021/03/04/march-the-fourth/</loc>!, @sitemap
|
|
175
|
+
assert_match %r!<loc>http://xn--mlaut-jva.example.org/2020/04/03/%E9%94%99%E8%AF%AF</loc>!, @sitemap
|
|
176
|
+
assert_match %r!<loc>http://xn--mlaut-jva.example.org/2020/04/02/%E9%94%99%E8%AF%AF</loc>!, @sitemap
|
|
177
|
+
assert_match %r!<loc>http://xn--mlaut-jva.example.org/2019/04/01/%E9%94%99%E8%AF%AF/</loc>!, @sitemap
|
|
173
178
|
end
|
|
174
179
|
end
|
|
175
180
|
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
describe "rendering the site with a user defined robots.txt" do
|
|
182
|
+
before(:all) do
|
|
183
|
+
prepare_site
|
|
178
184
|
File.write(source_dir("robots.txt"), "ROBOT")
|
|
179
|
-
|
|
185
|
+
process_site
|
|
186
|
+
|
|
180
187
|
@robots = File.read(dest_dir("robots.txt"))
|
|
181
188
|
end
|
|
182
189
|
|
|
183
|
-
|
|
190
|
+
after(:all) do
|
|
184
191
|
File.delete(source_dir("robots.txt"))
|
|
185
192
|
end
|
|
186
193
|
|
|
187
|
-
|
|
194
|
+
it "does not overwrite the robots.txt" do
|
|
188
195
|
assert_match %r!ROBOT!, @robots
|
|
189
196
|
refute_match %r!Sitemap!, @robots
|
|
190
197
|
end
|
|
191
198
|
end
|
|
192
199
|
|
|
193
|
-
|
|
194
|
-
|
|
200
|
+
describe "rendering the site with an uncommitted file" do
|
|
201
|
+
before(:all) do
|
|
202
|
+
prepare_site
|
|
195
203
|
File.write(source_dir("new.html"), "---\n---")
|
|
196
|
-
|
|
204
|
+
process_site
|
|
205
|
+
|
|
197
206
|
@sitemap = File.read(dest_dir("sitemap.xml"))
|
|
198
207
|
end
|
|
199
208
|
|
|
200
|
-
|
|
209
|
+
after(:all) do
|
|
201
210
|
File.delete(source_dir("new.html"))
|
|
202
211
|
end
|
|
203
212
|
|
|
204
|
-
|
|
213
|
+
it "includes the uncommitted file in the sitemap" do
|
|
205
214
|
assert_match %r!<loc>https://example.com/new/</loc>!, @sitemap
|
|
206
215
|
end
|
|
207
216
|
end
|
|
208
|
-
|
|
209
|
-
context "rendering the site without the resource content engine" do
|
|
210
|
-
setup { config.delete "content_engine" }
|
|
211
|
-
|
|
212
|
-
should "throw an error" do
|
|
213
|
-
capture_io do
|
|
214
|
-
assert_raises(BridgetownSitemap::UnsupportedContentEngine) { build_site }
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
end
|
|
218
217
|
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:
|
|
4
|
+
version: 2.0.0
|
|
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-01-
|
|
11
|
+
date: 2023-01-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bridgetown
|
|
@@ -16,7 +16,7 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.2.0
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
22
|
version: '2.0'
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
29
|
+
version: 1.2.0
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '2.0'
|
|
@@ -97,7 +97,7 @@ files:
|
|
|
97
97
|
- script/fmt
|
|
98
98
|
- script/release
|
|
99
99
|
- script/test
|
|
100
|
-
- test/fixtures/
|
|
100
|
+
- test/fixtures/config/initializers.rb
|
|
101
101
|
- test/fixtures/plugins/builders/generated_pages.rb
|
|
102
102
|
- test/fixtures/plugins/site_builder.rb
|
|
103
103
|
- test/fixtures/src/_data/.keep
|
|
@@ -153,7 +153,7 @@ signing_key:
|
|
|
153
153
|
specification_version: 4
|
|
154
154
|
summary: Automatically generate a sitemap.xml for your Bridgetown site.
|
|
155
155
|
test_files:
|
|
156
|
-
- test/fixtures/
|
|
156
|
+
- test/fixtures/config/initializers.rb
|
|
157
157
|
- test/fixtures/plugins/builders/generated_pages.rb
|
|
158
158
|
- test/fixtures/plugins/site_builder.rb
|
|
159
159
|
- test/fixtures/src/_data/.keep
|