bridgetown-sitemap 1.1.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +3 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile +1 -1
- data/README.md +18 -23
- data/bridgetown-sitemap.gemspec +3 -3
- 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/fixtures/plugins/builders/{generated_pages_builder.rb → generated_pages.rb} +1 -1
- data/test/helper.rb +9 -46
- data/test/test_sitemap.rb +145 -146
- metadata +18 -18
- 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
@@ -13,12 +13,14 @@ jobs:
|
|
13
13
|
runs-on: ubuntu-latest
|
14
14
|
strategy:
|
15
15
|
matrix:
|
16
|
-
ruby_version: [2.
|
16
|
+
ruby_version: [2.7.7, 3.0.5, 3.1.3, 3.2.0]
|
17
|
+
bridgetown_version: [1.2.0]
|
17
18
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
18
19
|
# Has to be top level to cache properly
|
19
20
|
env:
|
20
21
|
BUNDLE_JOBS: 3
|
21
22
|
BUNDLE_PATH: "vendor/bundle"
|
23
|
+
BRIDGETOWN_VERSION: ${{ matrix.bridgetown_version }}
|
22
24
|
steps:
|
23
25
|
- uses: actions/checkout@master
|
24
26
|
- name: Setup Ruby
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# main
|
2
2
|
|
3
|
+
# 2.0.0 / 25-01-2023
|
4
|
+
|
5
|
+
* Restrict support to Bridgetown v1.2 and newer.
|
6
|
+
* Initialize plugin using the new Ruby DSL in Bridgetown v1.2.
|
7
|
+
|
8
|
+
# 1.2.0 / 23-01-2023
|
9
|
+
|
10
|
+
* Require Bridgetown 1.0 or newer.
|
11
|
+
* Require Ruby 2.7 or newer.
|
12
|
+
|
3
13
|
# 1.1.2 / 18-02-2022
|
4
14
|
|
5
15
|
* Handle cases where the site is not in a git repo
|
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
@@ -16,11 +16,11 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.required_ruby_version = ">= 2.
|
19
|
+
spec.required_ruby_version = ">= 2.7.0"
|
20
20
|
|
21
|
-
spec.add_dependency "bridgetown", ">= 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"
|
25
|
-
spec.add_development_dependency "rubocop-bridgetown"
|
25
|
+
spec.add_development_dependency "rubocop-bridgetown"
|
26
26
|
end
|
@@ -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,217 +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
|
-
assert_match %r!<lastmod>2022-02-18T00: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
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
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
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
60
63
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
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
|
69
72
|
end
|
73
|
+
end
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
74
78
|
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
78
83
|
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
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
|
86
92
|
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
it "does not include any files named 404.html" do
|
94
|
+
refute_match %r!404.html!, @sitemap
|
95
|
+
end
|
90
96
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
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
|
95
100
|
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
99
104
|
|
100
|
-
|
101
|
-
|
102
|
-
|
105
|
+
it "does not include posts that have set 'sitemap: false'" do
|
106
|
+
refute_match %r!exclude-this-post!, @sitemap
|
107
|
+
end
|
103
108
|
|
104
|
-
|
105
|
-
|
106
|
-
|
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
|
107
112
|
end
|
108
113
|
|
109
|
-
|
110
|
-
|
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
|
111
117
|
|
112
|
-
|
113
|
-
|
114
|
-
|
118
|
+
it "includes the correct number of items for the sitemap" do
|
119
|
+
assert_equal 18, @sitemap.scan(%r!(?=<url>)!).count
|
120
|
+
end
|
115
121
|
|
116
|
-
|
117
|
-
|
118
|
-
end
|
122
|
+
it "includes generated pages in the sitemap" do
|
123
|
+
assert_match %r!<loc>https://example.com/generated_page/</loc>!, @sitemap
|
119
124
|
end
|
120
|
-
end
|
121
125
|
|
122
|
-
|
123
|
-
|
124
|
-
config.baseurl = "/baseurl"
|
125
|
-
build_site
|
126
|
+
it "renders liquid in the robots.txt" do
|
127
|
+
assert_match "Sitemap: https://example.com/sitemap.xml", @robots
|
126
128
|
end
|
129
|
+
end
|
127
130
|
|
128
|
-
|
129
|
-
|
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
|
130
136
|
|
131
|
-
|
132
|
-
|
133
|
-
|
137
|
+
@sitemap = File.read(dest_dir("sitemap.xml"))
|
138
|
+
@robots = File.read(dest_dir("robots.txt"))
|
139
|
+
end
|
134
140
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
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
|
139
144
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
assert_match %r!<loc>https://example.com/baseurl/2021/03/02/march-the-second/</loc>!, @sitemap
|
144
|
-
assert_match %r!<loc>https://example.com/baseurl/2019/07/14/last-modified-at/</loc>!, @sitemap
|
145
|
-
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
|
146
148
|
end
|
147
149
|
|
148
|
-
|
149
|
-
|
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
|
150
156
|
|
151
|
-
|
152
|
-
|
153
|
-
end
|
157
|
+
it "adds the baseurl in the robots.txt" do
|
158
|
+
assert_match "Sitemap: https://example.com/baseurl/sitemap.xml", @robots
|
154
159
|
end
|
155
160
|
end
|
156
161
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
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
|
162
167
|
|
163
|
-
|
164
|
-
|
168
|
+
@sitemap = File.read(dest_dir("sitemap.xml"))
|
169
|
+
end
|
165
170
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
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
|
174
178
|
end
|
175
179
|
end
|
176
180
|
|
177
|
-
|
178
|
-
|
181
|
+
describe "rendering the site with a user defined robots.txt" do
|
182
|
+
before(:all) do
|
183
|
+
prepare_site
|
179
184
|
File.write(source_dir("robots.txt"), "ROBOT")
|
180
|
-
|
185
|
+
process_site
|
186
|
+
|
181
187
|
@robots = File.read(dest_dir("robots.txt"))
|
182
188
|
end
|
183
189
|
|
184
|
-
|
190
|
+
after(:all) do
|
185
191
|
File.delete(source_dir("robots.txt"))
|
186
192
|
end
|
187
193
|
|
188
|
-
|
194
|
+
it "does not overwrite the robots.txt" do
|
189
195
|
assert_match %r!ROBOT!, @robots
|
190
196
|
refute_match %r!Sitemap!, @robots
|
191
197
|
end
|
192
198
|
end
|
193
199
|
|
194
|
-
|
195
|
-
|
200
|
+
describe "rendering the site with an uncommitted file" do
|
201
|
+
before(:all) do
|
202
|
+
prepare_site
|
196
203
|
File.write(source_dir("new.html"), "---\n---")
|
197
|
-
|
204
|
+
process_site
|
205
|
+
|
198
206
|
@sitemap = File.read(dest_dir("sitemap.xml"))
|
199
207
|
end
|
200
208
|
|
201
|
-
|
209
|
+
after(:all) do
|
202
210
|
File.delete(source_dir("new.html"))
|
203
211
|
end
|
204
212
|
|
205
|
-
|
213
|
+
it "includes the uncommitted file in the sitemap" do
|
206
214
|
assert_match %r!<loc>https://example.com/new/</loc>!, @sitemap
|
207
215
|
end
|
208
216
|
end
|
209
|
-
|
210
|
-
context "rendering the site without the resource content engine" do
|
211
|
-
setup { config.delete "content_engine" }
|
212
|
-
|
213
|
-
should "throw an error" do
|
214
|
-
capture_io do
|
215
|
-
assert_raises(BridgetownSitemap::UnsupportedContentEngine) { build_site }
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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'
|
@@ -62,17 +62,17 @@ dependencies:
|
|
62
62
|
name: rubocop-bridgetown
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0
|
67
|
+
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0
|
75
|
-
description:
|
74
|
+
version: '0'
|
75
|
+
description:
|
76
76
|
email: ayush@hey.com
|
77
77
|
executables: []
|
78
78
|
extensions: []
|
@@ -97,8 +97,8 @@ files:
|
|
97
97
|
- script/fmt
|
98
98
|
- script/release
|
99
99
|
- script/test
|
100
|
-
- test/fixtures/
|
101
|
-
- test/fixtures/plugins/builders/
|
100
|
+
- test/fixtures/config/initializers.rb
|
101
|
+
- test/fixtures/plugins/builders/generated_pages.rb
|
102
102
|
- test/fixtures/plugins/site_builder.rb
|
103
103
|
- test/fixtures/src/_data/.keep
|
104
104
|
- test/fixtures/src/_layouts/default.html
|
@@ -133,7 +133,7 @@ homepage: https://github.com/ayushn21/bridgetown-sitemap
|
|
133
133
|
licenses:
|
134
134
|
- MIT
|
135
135
|
metadata: {}
|
136
|
-
post_install_message:
|
136
|
+
post_install_message:
|
137
137
|
rdoc_options: []
|
138
138
|
require_paths:
|
139
139
|
- lib
|
@@ -141,20 +141,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
141
|
requirements:
|
142
142
|
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 2.
|
144
|
+
version: 2.7.0
|
145
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
147
|
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
152
|
-
signing_key:
|
151
|
+
rubygems_version: 3.2.32
|
152
|
+
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/
|
157
|
-
- test/fixtures/plugins/builders/
|
156
|
+
- test/fixtures/config/initializers.rb
|
157
|
+
- test/fixtures/plugins/builders/generated_pages.rb
|
158
158
|
- test/fixtures/plugins/site_builder.rb
|
159
159
|
- test/fixtures/src/_data/.keep
|
160
160
|
- test/fixtures/src/_layouts/default.html
|