jekyll-make-sitemap 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16db4afb3d3c11c391bb3b66415273fc85911357a5a9fd9032f740533925c3b2
4
- data.tar.gz: 448cffe8ddb49bf4945a08192214eacb11bde3892670d8a4a0cc1d61658b2ee3
3
+ metadata.gz: bd4a41d21f409fc188d785d843aea6e5914bbe33e36746e0559dfdf53694054f
4
+ data.tar.gz: 2577576bcb190c6bafdf42d5b627d5a706acc1ac0c953cafe1c1eae82b1d28b3
5
5
  SHA512:
6
- metadata.gz: f4458b5ea17b2942cc5381c94789a97167457c17b577b7d00e67e7ec4b9a40f1aea0f3247e7c742bf514a4a9cacdf61e4ac3673df52d54a43254b58604a0c818
7
- data.tar.gz: 024267fbca6c40efc38cf0da7fc691cc0650f432e662d8dff0657fb8baf13b22730f4230d0d3a4c47499de5a551db965bf0d876758344dbcf3845d1986b2b615
6
+ metadata.gz: 8e40c0ec789663d2c5f02b5d0591b788c0bd90d10bcedf43126c5716d7e74501c08d99764f1f247d5e11ced80864792730e38d4d702548eb7ba13f345b8356fd
7
+ data.tar.gz: debe344540615d72d81f168cde9baa31ce634970f493d69b3b6be7e8ce8b5a340657875396bcb5109476729f0984f5fdf3815fb6522faff149da92c44a7c3a74
data/CHANGELOG.md CHANGED
@@ -4,11 +4,27 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
- ## [1.2.0] - 2020-07-19
7
+ ## [1.3.0] - 2026-08-21
8
+
9
+ Fixed
10
+ - Endless rebuild loop under `jekyll serve`. The sitemap was written to, and then
11
+ deleted from, the source directory on every build. The watcher saw that churn as
12
+ a source change and rebuilt, which churned the file again. The sitemap is now
13
+ built in memory as a generated page and written only to the destination, so the
14
+ source directory is never touched.
15
+
16
+ Changed
17
+ - When the current environment is not listed in `environments`, no `sitemap.txt` is
18
+ written at all. Previously an empty `sitemap.txt` was emitted into the destination.
19
+
20
+ ## [1.2.1] - 2020-07-19
8
21
 
9
22
  Added
10
23
  - Ability to include posts by category in configuration
11
24
 
25
+ Fixed
26
+ - Bug where default env config is lost if there are config settings but none for envs
27
+
12
28
  ## [1.1.1] - 2020-07-12
13
29
 
14
30
  Added
data/Gemfile.lock CHANGED
@@ -6,8 +6,8 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- addressable (2.7.0)
10
- public_suffix (>= 2.0.2, < 5.0)
9
+ addressable (2.8.4)
10
+ public_suffix (>= 2.0.2, < 6.0)
11
11
  colorator (1.1.0)
12
12
  concurrent-ruby (1.1.6)
13
13
  em-websocket (0.5.1)
@@ -38,7 +38,7 @@ GEM
38
38
  sassc (> 2.0.1, < 3.0)
39
39
  jekyll-watch (2.2.1)
40
40
  listen (~> 3.0)
41
- kramdown (2.3.0)
41
+ kramdown (2.3.1)
42
42
  rexml
43
43
  kramdown-parser-gfm (1.1.0)
44
44
  kramdown (~> 2.0)
@@ -49,12 +49,12 @@ GEM
49
49
  mercenary (0.3.6)
50
50
  pathutil (0.16.2)
51
51
  forwardable-extended (~> 2.6)
52
- public_suffix (4.0.5)
52
+ public_suffix (4.0.7)
53
53
  rake (12.3.3)
54
54
  rb-fsevent (0.10.4)
55
55
  rb-inotify (0.10.1)
56
56
  ffi (~> 1.0)
57
- rexml (3.2.4)
57
+ rexml (3.2.5)
58
58
  rouge (3.20.0)
59
59
  safe_yaml (1.0.5)
60
60
  sassc (2.4.0)
@@ -1,7 +1,7 @@
1
1
  module Jekyll
2
2
  module Make
3
3
  class Sitemap
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -4,54 +4,68 @@ module Jekyll
4
4
  module Make
5
5
  class Sitemap
6
6
  class Error < StandardError; end
7
+
8
+ FILENAME = "sitemap.txt".freeze
9
+
7
10
  class << self
8
- def generate(site, payload, file)
11
+ def config_for(site)
9
12
  default_config = { 'pages' => true, 'posts' => true, 'environments' => ['production'] }
10
- config = site.config.has_key?("jekyll-make-sitemap") ? site.config["jekyll-make-sitemap"] : default_config
11
- if config['environments'].include?(payload.jekyll.environment)
12
- baseurl = site.config["url"]
13
- collections = config.has_key?("collections") ? config["collections"] : []
14
- unless config.has_key?("pages") && config["pages"] == false
15
- payload.site.pages.each do |page| process(file, page, baseurl) end
16
- end
17
- unless config.has_key?("posts") && config["posts"] == false
18
- payload.site.posts.each do |post|
19
- if !config["posts"].eql?(true)
20
- config["posts"].each do |cat|
21
- if post.data.has_key?("categories") && post.data["categories"].include?(cat)
22
- process(file, post, baseurl)
23
- end
13
+ site.config.has_key?("jekyll-make-sitemap") ? default_config.merge(site.config["jekyll-make-sitemap"]) : default_config
14
+ end
15
+
16
+ def generate(site, config)
17
+ lines = []
18
+ baseurl = site.config["url"]
19
+ collections = config.has_key?("collections") ? config["collections"] : []
20
+ unless config.has_key?("pages") && config["pages"] == false
21
+ site.pages.each do |page| process(lines, page, baseurl) end
22
+ end
23
+ unless config.has_key?("posts") && config["posts"] == false
24
+ # Match the ordering of `site.posts` as exposed to Liquid, which
25
+ # `Jekyll::Drops::SiteDrop` sorts newest-first.
26
+ site.posts.docs.sort { |a, b| b <=> a }.each do |post|
27
+ if !config["posts"].eql?(true)
28
+ config["posts"].each do |cat|
29
+ if post.data.has_key?("categories") && post.data["categories"].include?(cat)
30
+ process(lines, post, baseurl)
24
31
  end
25
- else
26
- process(file, post, baseurl)
27
32
  end
33
+ else
34
+ process(lines, post, baseurl)
28
35
  end
29
36
  end
30
- collections.each do |col|
31
- site.collections[col].docs.each do |post| process(file, post, baseurl) end
32
- end
33
37
  end
38
+ collections.each do |col|
39
+ site.collections[col].docs.each do |post| process(lines, post, baseurl) end
40
+ end
41
+ lines
34
42
  end
35
- def process(file, doc, baseurl)
43
+
44
+ def process(lines, doc, baseurl)
36
45
  if !((doc.data.has_key?("tags") && doc.data["tags"].include?("sitemap-exclude")) || !doc.path.end_with?(".md"))
37
- file.write "#{baseurl}#{doc.url}\n"
46
+ lines << "#{baseurl}#{doc.url}\n"
38
47
  end
39
48
  end
40
49
  end
41
50
  end
42
- end
43
- end
44
51
 
45
- Jekyll::Hooks.register :site, :after_reset do |site|
46
- File.new("sitemap.txt", "w") if !File.exist?("sitemap.txt")
47
- end
52
+ # Builds the sitemap as an in-memory page so that it is written by Jekyll's
53
+ # normal output pipeline. Nothing is ever written to the source directory,
54
+ # which would otherwise churn the watcher during `jekyll serve` and trigger
55
+ # an endless rebuild loop.
56
+ class SitemapGenerator < Jekyll::Generator
57
+ safe true
58
+ priority :lowest
48
59
 
49
- Jekyll::Hooks.register :site, :post_render do |site, payload|
50
- file = File.open("sitemap.txt", "w+")
51
- Jekyll::Make::Sitemap.generate(site, payload, file)
52
- file.close
53
- end
60
+ def generate(site)
61
+ config = Sitemap.config_for(site)
62
+ return unless config["environments"].include?(Jekyll.env)
54
63
 
55
- Jekyll::Hooks.register :site, :post_write do |site|
56
- File.delete("sitemap.txt")
57
- end
64
+ page = Jekyll::PageWithoutAFile.new(site, site.source, "", Sitemap::FILENAME)
65
+ page.content = Sitemap.generate(site, config).join
66
+ page.data["layout"] = nil
67
+ site.pages << page
68
+ end
69
+ end
70
+ end
71
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-make-sitemap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Hofer
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2020-07-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: A Jekyll hook plugin for generating a sitemap.txt file during the Jekyll
14
13
  build process.
@@ -37,7 +36,6 @@ licenses:
37
36
  metadata:
38
37
  homepage_uri: https://github.com/hofers/jekyll-make-sitemap
39
38
  source_code_uri: https://github.com/hofers/jekyll-make-sitemap
40
- post_install_message:
41
39
  rdoc_options: []
42
40
  require_paths:
43
41
  - lib
@@ -52,8 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
50
  - !ruby/object:Gem::Version
53
51
  version: '0'
54
52
  requirements: []
55
- rubygems_version: 3.1.4
56
- signing_key:
53
+ rubygems_version: 3.6.9
57
54
  specification_version: 4
58
55
  summary: A Jekyll hook plugin for generating a sitemap.txt file during the Jekyll
59
56
  build process.