jekyll-auto-cat-plus 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/jekyll-auto-cat-plus.rb +46 -47
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff47c161d2285fcea5af5e9d656333aa2e686dc673142e7da4adb3e253c20133
|
4
|
+
data.tar.gz: a27ecea0292ec9f1a108a0bb578a73a7275a4a18b26f43764fe47593b49343ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee2ebb90808271a066776134609acb6f624fa9ee21e6cceec8fa1c6e43408ada653548f76e26a700dd1c21517a13785cd94031b6ca8f7fade84357811e0546e5
|
7
|
+
data.tar.gz: 72aeedb60ef05ac74125d1c5d6d1af9805bb6b5696ecffb9c8b7a61e6204e6ff3c043d82dc08498758a0ddbd8864583a6c4134776bd034036cb0cf4546ec433c
|
data/lib/jekyll-auto-cat-plus.rb
CHANGED
@@ -10,57 +10,56 @@ module Jekyll
|
|
10
10
|
merge_data!({ "categories" => superdirs }, :source => "file path")
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
site.pages << CategoryPage.new(site, category, posts)
|
13
|
+
# /_site 의 post 폴더 구조에 카테고리 페이지를 생성한다.
|
14
|
+
# post 와 category_page 모두 basename 이 index.html 이므로
|
15
|
+
# post를 카테고리 계층 사이에 생성하면 안된다.
|
16
|
+
module SamplePlugin
|
17
|
+
class CategoryPageGenerator < Jekyll::Generator
|
18
|
+
def generate(site)
|
19
|
+
site.categories.each do |category, posts|
|
20
|
+
site.pages << CategoryPage.new(site, category, posts)
|
21
|
+
end
|
23
22
|
end
|
24
23
|
end
|
25
|
-
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
# Subclass of `Jekyll::Page` with custom method definitions.
|
26
|
+
class CategoryPage < Jekyll::Page
|
27
|
+
def initialize(site, category, posts)
|
28
|
+
@site = site # the current site instance.
|
29
|
+
@base = site.source # path to the source directory.
|
30
|
+
|
31
|
+
p_basename = posts.first.basename
|
32
|
+
p_special_dir = posts.first.collection.relative_directory
|
33
|
+
p_superdirs = posts.first.relative_path.sub(p_special_dir, "")
|
34
|
+
p_superdirs = p_superdirs.sub(/#{category}.*/,"") << category
|
35
|
+
@dir = p_superdirs # the directory the page will reside in.
|
36
|
+
|
37
|
+
# All pages have the same filename, so define attributes straight away.
|
38
|
+
@basename = 'index' # filename without the extension.
|
39
|
+
@ext = '.html' # the extension.
|
40
|
+
@name = 'index.html' # basically @basename + @ext.
|
41
|
+
|
42
|
+
# Initialize data hash with a key pointing to all posts under current category.
|
43
|
+
# This allows accessing the list in a template via `page.linked_docs`.
|
44
|
+
@data = {
|
45
|
+
'linked_docs' => posts
|
46
|
+
}
|
47
|
+
|
48
|
+
# Look up front matter defaults scoped to type `categories`, if given key
|
49
|
+
# doesn't exist in the `data` hash.
|
50
|
+
data.default_proc = proc do |_, key|
|
51
|
+
site.frontmatter_defaults.find(relative_path, :categories, key)
|
52
|
+
end
|
53
|
+
end
|
38
54
|
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
@data = {
|
47
|
-
'linked_docs' => posts
|
48
|
-
}
|
49
|
-
|
50
|
-
# Look up front matter defaults scoped to type `categories`, if given key
|
51
|
-
# doesn't exist in the `data` hash.
|
52
|
-
data.default_proc = proc do |_, key|
|
53
|
-
site.frontmatter_defaults.find(relative_path, :categories, key)
|
55
|
+
# Placeholders that are used in constructing page URL.
|
56
|
+
def url_placeholders
|
57
|
+
{
|
58
|
+
:category => @dir,
|
59
|
+
:basename => basename,
|
60
|
+
:output_ext => output_ext,
|
61
|
+
}
|
54
62
|
end
|
55
63
|
end
|
56
|
-
|
57
|
-
# Placeholders that are used in constructing page URL.
|
58
|
-
def url_placeholders
|
59
|
-
{
|
60
|
-
:category => @dir,
|
61
|
-
:basename => basename,
|
62
|
-
:output_ext => output_ext,
|
63
|
-
}
|
64
|
-
end
|
65
64
|
end
|
66
|
-
end
|
65
|
+
end
|