jekyll-make-sitemap 1.0.0 → 1.0.1
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/Gemfile.lock +1 -1
- data/README.md +7 -0
- data/jekyll-make-sitemap.gemspec +3 -3
- data/lib/jekyll/make/sitemap.rb +45 -0
- data/lib/jekyll/make/sitemap/version.rb +7 -0
- metadata +3 -3
- data/lib/jekyll/make-sitemap.rb +0 -42
- data/lib/jekyll/make-sitemap/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f040a8c5737b7efc45e9e8ab37a40d1543cc16f10394e6d6cc4c92721fbbf98
|
4
|
+
data.tar.gz: 06d8e64bd564e9673d34143f564ff2735863fc17708e0a444006c4026baf6f03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83962694d35aa068db6b71c13a5e383a0cedafea095f90e73635edb5878fbfc5f1670295c8adee9129eaaf28d884e6cb7385493042b9a9e8a148f995c86f06e4
|
7
|
+
data.tar.gz: b7258225a86e8c0e5a1ca744b8bbc25e920955ff24e4a9ee092f5ed6db280b2c489196583ded522eeb506525374f342b97236b273931e27c6ab2ea0b898a80cd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,10 @@ end
|
|
21
21
|
## Configuration
|
22
22
|
In `_config.yml`
|
23
23
|
``` yaml
|
24
|
+
...
|
25
|
+
plugins:
|
26
|
+
- jekyll-make-sitemap
|
27
|
+
...
|
24
28
|
jekyll-make-sitemap:
|
25
29
|
pages: true # Default: true
|
26
30
|
posts: true # Default: true
|
@@ -28,6 +32,9 @@ jekyll-make-sitemap:
|
|
28
32
|
- collection_1 # include items from collection_1 in sitemap
|
29
33
|
```
|
30
34
|
|
35
|
+
## Exceptions
|
36
|
+
To exclude a page or post, assign it the `sitemap-exclude` tag
|
37
|
+
|
31
38
|
## License
|
32
39
|
|
33
40
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/jekyll-make-sitemap.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require_relative 'lib/jekyll/make
|
1
|
+
require_relative 'lib/jekyll/make/sitemap/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "jekyll-make-sitemap"
|
5
|
-
spec.version = Jekyll::
|
5
|
+
spec.version = Jekyll::Make::Sitemap::VERSION
|
6
6
|
spec.authors = ["Sean Hofer"]
|
7
7
|
spec.email = ["me@seanhofer.com"]
|
8
8
|
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
20
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/})
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) or f.match(/^jekyll-make-sitemap-\d\.\d\.\d\.gem$/) }
|
22
22
|
end
|
23
23
|
spec.bindir = "exe"
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'jekyll'
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Make
|
5
|
+
class Sitemap
|
6
|
+
class Error < StandardError; end
|
7
|
+
class << self
|
8
|
+
def generate(site, payload)
|
9
|
+
if payload.jekyll.environment == "production"
|
10
|
+
default_config = { 'pages' => true, 'posts' => true }
|
11
|
+
file = File.open("sitemap.txt", "w+")
|
12
|
+
config = site.config.has_key?("jekyll-make-sitemap") ? site.config["jekyll-make-sitemap"] : default_config
|
13
|
+
baseurl = site.config["url"]
|
14
|
+
collections = config.has_key?("collections") ? ["collections"] : []
|
15
|
+
|
16
|
+
unless config.has_key?("pages") && config["pages"] == false
|
17
|
+
payload.site.pages.each do |page| process(file, page, baseurl) end
|
18
|
+
end
|
19
|
+
unless config.has_key?("posts") && config["posts"] == false
|
20
|
+
payload.site.posts.each do |post| process(file, post, baseurl) end
|
21
|
+
end
|
22
|
+
collections.each do |col|
|
23
|
+
site.collections[col].docs.each do |post| process(file, post, baseurl) end
|
24
|
+
end
|
25
|
+
|
26
|
+
file.close()
|
27
|
+
end
|
28
|
+
end
|
29
|
+
def process(file, doc, baseurl)
|
30
|
+
if !((doc.data.has_key?("tags") && doc.data["tags"].include?("sitemap-exclude")) || !doc.path.end_with?(".md"))
|
31
|
+
file.write "#{baseurl}#{doc.url}\n"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Jekyll::Hooks.register :site, :after_init do |site|
|
40
|
+
File.new("sitemap.txt", "w")
|
41
|
+
end
|
42
|
+
|
43
|
+
Jekyll::Hooks.register :site, :pre_render do |site, payload|
|
44
|
+
Jekyll::Make::Sitemap.generate(site, payload)
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-make-sitemap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Hofer
|
@@ -28,8 +28,8 @@ files:
|
|
28
28
|
- bin/console
|
29
29
|
- bin/setup
|
30
30
|
- jekyll-make-sitemap.gemspec
|
31
|
-
- lib/jekyll/make
|
32
|
-
- lib/jekyll/make
|
31
|
+
- lib/jekyll/make/sitemap.rb
|
32
|
+
- lib/jekyll/make/sitemap/version.rb
|
33
33
|
homepage: https://github.com/hofers/jekyll-make-sitemap
|
34
34
|
licenses:
|
35
35
|
- MIT
|
data/lib/jekyll/make-sitemap.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require "jekyll"
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
class MakeSitemap
|
5
|
-
class << self
|
6
|
-
def generate(site, payload)
|
7
|
-
if payload.jekyll.environment == "production"
|
8
|
-
default_config = { 'pages' => true, 'posts' => true }
|
9
|
-
file = File.open("sitemap.txt", "w+")
|
10
|
-
config = site.config.has_key?("jekyll-make-sitemap") ? site.config["jekyll-make-sitemap"] : default_config
|
11
|
-
baseurl = site.config["url"]
|
12
|
-
collections = config.has_key?("collections") ? ["collections"] : []
|
13
|
-
|
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| process(file, post, baseurl) end
|
19
|
-
end
|
20
|
-
collections.each do |col|
|
21
|
-
site.collections[col].docs.each do |post| process(file, post, baseurl) end
|
22
|
-
end
|
23
|
-
|
24
|
-
file.close()
|
25
|
-
end
|
26
|
-
end
|
27
|
-
def process(file, doc, baseurl)
|
28
|
-
if !((doc.data.has_key?("tags") && doc.data["tags"].include?("sitemap-exclude")) || !doc.path.end_with?(".md"))
|
29
|
-
file.write "#{baseurl}#{doc.url}\n"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
Jekyll::Hooks.register :site, :after_init do |site|
|
37
|
-
File.new("sitemap.txt", "w")
|
38
|
-
end
|
39
|
-
|
40
|
-
Jekyll::Hooks.register :site, :pre_render do |site, payload|
|
41
|
-
Jekyll::MakeSitemap.generate(site, payload)
|
42
|
-
end
|