jekyll-categorize-pages 0.1.0 → 0.1.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/lib/generator.rb +61 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17aee4a8a5c4b14c937afe207f6a96fb6a84a002
|
4
|
+
data.tar.gz: 3fc1a8c032dad7609fba7d3d5296280988047c59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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-
|
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
|