jekyll-categorize-pages 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generator.rb +20 -34
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 067ee452f111d515a9edbbc7744851b03c5774cb
4
- data.tar.gz: 96c080bf3b2d149c1762dc1120c1fd16c177af4b
3
+ metadata.gz: 07cc3ead386bb5808661119202181ad472b92cc0
4
+ data.tar.gz: b04b0b5c2e5c5ebadfc504e8abd1626744eae135
5
5
  SHA512:
6
- metadata.gz: 972d6b1bd7cb2a816d99fa24db7f7859b5d3bdc15e5356edac9c20113a610c83483adbd2223729ac1315b06955c6a412764a429ad0adf7e1447ce5440aaef7fc
7
- data.tar.gz: dbfe0bf2ff994b76e8e4c794392576d4d09fede77d592f970eddcbe520eea20ac4b5527dda2306a83fd197759d86ee4fb1c3dec64b6a6cff554344f35471f130
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 InjectFm < Jekyll::Generator
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 add_to_frontmatter(item, values)
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
- all_categories = @site.data["all_categories"] || [] # sub folders inside collection
39
- path = item.relative_path.split('/')
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
- # if category folder has no sub categories
49
- if path.length == 3
50
- # puts "path: #{path}"
51
- # puts "length: #{path.length}"
52
- header_values = get_header_values_to_add(item)
53
- add_category_only(item, header_values)
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
- return all_categories.include?(category)
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
- # if path.include?("index.md")
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
- add_to_frontmatter(item, header_values)
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.3
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.0'
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.0'
26
+ version: '3.6'
27
27
  description:
28
28
  email:
29
29
  - ''