jekyll-categorize-pages 0.1.0 → 0.1.1

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 +61 -0
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d9de7576272046b9be5443bc9a692056a3620d0
4
- data.tar.gz: f975de2bbb19e56334f09f33ca7ca5be5b3e68e1
3
+ metadata.gz: 17aee4a8a5c4b14c937afe207f6a96fb6a84a002
4
+ data.tar.gz: 3fc1a8c032dad7609fba7d3d5296280988047c59
5
5
  SHA512:
6
- metadata.gz: 1731daa89e683d84fc2b3a80ebec6c857136693fb0c5dca56b2d745b5eab7fb2f64a96c0f2ad1378a15e2b700cc7505f219693cda66d0afe52c7a51e429f4a00
7
- data.tar.gz: 05d0c972925c52a7f38debb04e38256a83fca043fa64e9298a2969fc7361add29a0b8c6a6c8ded37a61226ae790b72e4e4bfcbbea8cb81d13ebb016a03c048a9
6
+ metadata.gz: af5d585f40f51321e000e593dbd98f7af6a221fe184b15c02ba8423748289a65fb56f4b6dffb032269cc1cb64b106699ea329285a84712b16338c1c4b5e18a90
7
+ data.tar.gz: ccd2933eae2fe8c84bf452205f3fa5d841e83f6796783f480d7f04c0fcab2d11a0d759be8f4f27816f284801b228d7d08645c2e6fa7caf6a06d1d699a9817b03
data/lib/generator.rb ADDED
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ require "jekyll"
3
+
4
+ module Jekyll
5
+
6
+ # Injects front matter defaults to set default category/sub-category values
7
+ class CategorizePagesGenerator < Jekyll::Generator
8
+ # priority :high
9
+ safe true
10
+
11
+ def log(*args)
12
+ puts args
13
+ end
14
+
15
+ def get_collection(name)
16
+ @site.collections[name] ? @site.collections[name].docs : []
17
+ end
18
+
19
+ def add_to_frontmatter(item)
20
+ item.data["category"] = @category # i.data is the front matter header
21
+ item.data["sub_category"] = @sub_category
22
+ end
23
+
24
+
25
+ def isValid?(item)
26
+ folders_to_categorize = @site.data["pagerrr_folders_to_categorize"] || []
27
+ puts folders_to_categorize
28
+ # all_categories.include?(page[:n])
29
+ path = item.relative_path.split('/')
30
+ # category = path[0].sub(/^_/, '') # Remove first letter if underscore
31
+ @category = path[1] if path[1] != "index.md"
32
+ @sub_category = path[2] if path[2] != "index.md"
33
+ file = path[3] if path[3] != "index.md"
34
+ # puts '^^^^^^^^^^^^^'
35
+ # puts @category
36
+ # puts @sub_category
37
+
38
+ return folders_to_categorize.include?(@category)
39
+ end
40
+
41
+
42
+
43
+ def generate(site)
44
+ puts "RAN!"
45
+ # @site = site
46
+ # # The collections to add category/sub category front matter values
47
+ # collections = ["pages"] # TODO: Move this variable to _config/_data
48
+
49
+ # for c in collections
50
+ # for item in get_collection(c)
51
+ # valid_category = isValid?(item)
52
+ # if valid_category
53
+ # add_to_frontmatter(item)
54
+ # end
55
+ # end
56
+ # end
57
+
58
+ end
59
+
60
+ end
61
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-categorize-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-08 00:00:00.000000000 Z
11
+ date: 2018-07-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -16,7 +16,8 @@ email:
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
- files: []
19
+ files:
20
+ - lib/generator.rb
20
21
  homepage: ''
21
22
  licenses:
22
23
  - MIT