jekyll-auto-cat-plus 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/jekyll-auto-cat-plus.rb +66 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 96482e5bba7e897bb2af450467c73be6949367c2baa1ebbc7acbb51a21e02e4f
|
4
|
+
data.tar.gz: 25ace76759df9d8e1f56ad70110f51f96997c65e32df6fb524bb8bb42aacdb21
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f32e01442b98ab458f0bc6bb8ec85571030ee829683414f657fa42dfef04e89801e05dab227bd0f45a38dc277f4f3b8c44b33b16ba0a7bd38ab8525bdbae0ef5
|
7
|
+
data.tar.gz: 22928609dfa6f08bd2449438dc2584e1f6376d41ca464c907df3d06922d4a7d8c2052770712d4ff1e13a36cfc728dfd30570297656cbd0e69c8b420cb16a04a0
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# /_post 아래의 폴더 구조를 통해 카테고리를 자동으로 생성한다.
|
2
|
+
# 메소드 재정의를 사용함.
|
3
|
+
module Jekyll
|
4
|
+
class Document
|
5
|
+
def categories_from_path(special_dir)
|
6
|
+
superdirs = relative_path.sub(special_dir, "")
|
7
|
+
superdirs = superdirs.split(File::SEPARATOR)
|
8
|
+
superdirs.reject! { |c| c.empty? || c == special_dir || c == basename }
|
9
|
+
|
10
|
+
merge_data!({ "categories" => superdirs }, :source => "file path")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# /_site 의 post 폴더 구조에 카테고리 페이지를 생성한다.
|
16
|
+
# post 와 category_page 모두 basename 이 index.html 이므로
|
17
|
+
# post를 카테고리 계층 사이에 생성하면 안된다.
|
18
|
+
module SamplePlugin
|
19
|
+
class CategoryPageGenerator < Jekyll::Generator
|
20
|
+
def generate(site)
|
21
|
+
site.categories.each do |category, posts|
|
22
|
+
site.pages << CategoryPage.new(site, category, posts)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Subclass of `Jekyll::Page` with custom method definitions.
|
28
|
+
class CategoryPage < Jekyll::Page
|
29
|
+
def initialize(site, category, posts)
|
30
|
+
@site = site # the current site instance.
|
31
|
+
@base = site.source # path to the source directory.
|
32
|
+
|
33
|
+
p_basename = posts.first.basename
|
34
|
+
p_special_dir = posts.first.collection.relative_directory
|
35
|
+
p_superdirs = posts.first.relative_path.sub(p_special_dir, "")
|
36
|
+
p_superdirs = p_superdirs.sub(/#{category}.*/,"") << category
|
37
|
+
@dir = p_superdirs # the directory the page will reside in.
|
38
|
+
|
39
|
+
# All pages have the same filename, so define attributes straight away.
|
40
|
+
@basename = 'index' # filename without the extension.
|
41
|
+
@ext = '.html' # the extension.
|
42
|
+
@name = 'index.html' # basically @basename + @ext.
|
43
|
+
|
44
|
+
# Initialize data hash with a key pointing to all posts under current category.
|
45
|
+
# This allows accessing the list in a template via `page.linked_docs`.
|
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)
|
54
|
+
end
|
55
|
+
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
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-auto-cat-plus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kkooing
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.7'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.7'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
description: jekyll-auto-cat-plus categorizes posts through the hierarchy under /_posts
|
34
|
+
and organizes them in the /_site folder. Plus, it creates category-pages between
|
35
|
+
the post hierarchy created in /_site.
|
36
|
+
email:
|
37
|
+
- kdw7968@naver.com
|
38
|
+
executables: []
|
39
|
+
extensions: []
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- lib/jekyll-auto-cat-plus.rb
|
43
|
+
homepage: https://github.com/kkooing
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.4.0
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.1.4
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: auto categorization of posts by folder hierarchy & category-pages
|
66
|
+
test_files: []
|