jekyll-categorize-pages 0.1.3 → 0.1.4
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/lib/generator.rb +20 -34
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07cc3ead386bb5808661119202181ad472b92cc0
|
4
|
+
data.tar.gz: b04b0b5c2e5c5ebadfc504e8abd1626744eae135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f039814c50a6a8b8fa19323711ddaa247c4c6b5a0f8bfc986ed79a556d79ef8eab799dd1258a741e8468f740ca71488ce2c6a0c0a661f0628adb6f9c130bd166
|
7
|
+
data.tar.gz: 75d9f2bcfad162ac6b147fcf09f33f108d34233d9c9395e63ae4136eea8f3e2919efee8c1a249e0a77fe4972b17938bc98a6dec6c6fcf4c7500ae2e31d4d000f
|
data/lib/generator.rb
CHANGED
@@ -2,15 +2,9 @@
|
|
2
2
|
require "jekyll"
|
3
3
|
|
4
4
|
module Jekyll
|
5
|
-
# You can create a generator when you need Jekyll
|
6
|
-
# to create additional content based on your own rules.
|
7
|
-
|
8
|
-
# A generator is a subclass of Jekyll::Generator that defines a generate method,
|
9
|
-
# which receives an instance of Jekyll::Site. The return value of generate is ignored.
|
10
|
-
|
11
5
|
|
12
6
|
# Injects front matter defaults to set default category/sub-category values
|
13
|
-
class
|
7
|
+
class CategorizePageGenerator < Jekyll::Generator
|
14
8
|
# priority :high
|
15
9
|
safe true
|
16
10
|
|
@@ -18,7 +12,7 @@ module Jekyll
|
|
18
12
|
@site.collections[name] ? @site.collections[name].docs : []
|
19
13
|
end
|
20
14
|
|
21
|
-
def
|
15
|
+
def add_category_and_sub_category(item, values)
|
22
16
|
# puts "adding: #{item.relative_path}"
|
23
17
|
# puts "values: #{values}"
|
24
18
|
|
@@ -35,32 +29,26 @@ module Jekyll
|
|
35
29
|
|
36
30
|
|
37
31
|
def isValid?(item)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
category = path[1] if path[1] != "index.md"
|
42
|
-
|
43
|
-
# ignore index.md pages
|
44
|
-
if path.include?("index.md")
|
45
|
-
return false
|
46
|
-
end
|
32
|
+
all_categories = @site.data["all_categories"] || [] # sub folders inside collection
|
33
|
+
path = item.relative_path.split('/')
|
47
34
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
return false
|
55
|
-
end
|
35
|
+
category = path[1] if path[1] != "index.md"
|
36
|
+
|
37
|
+
# ignore index.md pages
|
38
|
+
if path.include?("index.md")
|
39
|
+
return false
|
40
|
+
end
|
56
41
|
|
57
|
-
|
42
|
+
# if category folder has no sub categories
|
43
|
+
if path.length == 3
|
44
|
+
# puts "path: #{path}"
|
45
|
+
# puts "length: #{path.length}"
|
46
|
+
header_values = get_header_values_to_add(item)
|
47
|
+
add_category_only(item, header_values)
|
48
|
+
return false
|
49
|
+
end
|
58
50
|
|
59
|
-
|
60
|
-
# return false
|
61
|
-
# else
|
62
|
-
# return all_categories.include?(category)
|
63
|
-
# end
|
51
|
+
return all_categories.include?(category)
|
64
52
|
end
|
65
53
|
|
66
54
|
|
@@ -96,13 +84,11 @@ module Jekyll
|
|
96
84
|
if valid_category
|
97
85
|
header_values = get_header_values_to_add(item)
|
98
86
|
# puts "header_values: #{header_values}"
|
99
|
-
|
87
|
+
add_category_and_sub_category(item, header_values)
|
100
88
|
end
|
101
89
|
end
|
102
90
|
end
|
103
|
-
|
104
91
|
end
|
105
92
|
|
106
93
|
end
|
107
|
-
|
108
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-categorize-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
26
|
+
version: '3.6'
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- ''
|