jekyll-theme-anurina-bootstrap 0.0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b0e50aec0ba4b595021e50dc248c8d75d4ec7b785db918afd0e095de22602484
4
+ data.tar.gz: 364c15f33fa846487c6a71de93a0e9830524ee3098d02a0b1b8ad3c098fca1fd
5
+ SHA512:
6
+ metadata.gz: 71a284f630b6f441a83e14da1718f8b5be66bcab090c8de7e1962b709999c58e76ec4706421043ee406faebf5b09bd682929f569c4916cfa7f61533bbb3845d1
7
+ data.tar.gz: '048f2a88d18494832949df6293aa7189929cd76f898835efce23aca1fd95a816f8ce36ad05a3566308e717a187c0eaaf87284ec02d484782ba2e2484c8a364fe'
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # Bootstrap Plugin For jekyll-theme-anurina
2
+
3
+ This is a Jekyll plugin for (jekyll-theme-anurina)[https://github.com/theanurin/jekyll-theme-anurina] theme.
4
+
5
+ This plugin provide necessary configuration to make user's life more painless.
@@ -0,0 +1,119 @@
1
+ require "jekyll"
2
+
3
+ class MisconfigurationError < RuntimeError
4
+ end
5
+
6
+ #
7
+ # Hook: Just after the site initializes. Good for modifying the configuration of the site. Triggered once per build / serve session
8
+ # https://jekyllrb.com/docs/plugins/hooks/
9
+ #
10
+ Jekyll::Hooks.register :site, :after_init do |site|
11
+ if site.config["permalink"] == "none"
12
+ Jekyll.logger.info "Anurina:", "Check config 'permalink' is 'none'"
13
+ elsif site.config["permalink"] == "" || site.config["permalink"] == "date"
14
+ site.config["permalink"] = "none"
15
+ Jekyll.logger.info "Anurina:", "Set config 'permalink' to 'none'"
16
+ else
17
+ raise MisconfigurationError.new(
18
+ "Pls remove 'permalink' from your config.yml or set explicitly to 'none'. Current value is '#{site.config["permalink"]}'."
19
+ )
20
+ end
21
+
22
+ if site.config["collections_dir"] == "content"
23
+ Jekyll.logger.info "Anurina:", "Check config 'collections_dir' is 'content'"
24
+ elsif site.config["collections_dir"] != ""
25
+ raise MisconfigurationError.new("Pls remove 'collections_dir' from your config.yml or set explicitly to 'content'")
26
+ else
27
+ site.config["collections_dir"] = "content"
28
+ Jekyll.logger.info "Anurina:", "Set config 'collections_dir' to 'content'"
29
+ end
30
+
31
+ site.config["collections"].each do |name, config|
32
+ if name == "drafts"
33
+ Jekyll.logger.info "Anurina:", "Checking collection '#{name}' output to be 'false'"
34
+ if config["output"] != false
35
+ raise MisconfigurationError.new("A collection '#{name}' is not supported by the theme. Pls remove it from your config.yml at all or set 'output' explicitly to 'false'. Collections are reserved for multi-language usage (it will be generated automatically).")
36
+ end
37
+ elsif name == "posts"
38
+ # Skip posts due to unable to disable it via config.yaml
39
+ # see https://talk.jekyllrb.com/t/i-dont-want-posts-on-my-website-how-to-remove-this-default-collection/1605
40
+ else
41
+ raise MisconfigurationError.new("Pls remove 'collections' from your config.yml. Collections are reserved for multi-language usage (it will be generated automatically).")
42
+ end
43
+ end
44
+
45
+ # Remove all collection provided by config.yaml
46
+ site.config["collections"].each do |name, config|
47
+ site.config["collections"].delete(name)
48
+ end
49
+
50
+ raise MisconfigurationError.new(
51
+ "Pls provider locale sequence in your _config.yaml. A value for anurina->locale->sequence is not presented."
52
+ ) unless site.config["anurina"] && site.config["anurina"]["locale"] && site.config["anurina"]["locale"]["sequence"]
53
+ locales = site.config["anurina"]["locale"]["sequence"]
54
+ locales.each_with_index do |locale, index|
55
+ #
56
+ # See https://stackoverflow.com/questions/8758340/is-there-a-regex-to-test-if-a-string-is-for-a-locale
57
+ #
58
+ raise MisconfigurationError.new(
59
+ "Bad locale name '#{locale}'. The name is not match to /^[a-zA-Z]{2,4}(([\-\_][a-zA-Z]{4})+)?([\-\_][a-zA-Z]{2})?$/"
60
+ ) unless locale.match(/^[a-zA-Z]{2,4}(([\-\_][a-zA-Z]{4})+)?([\-\_][a-zA-Z]{2})?$/)
61
+
62
+ #
63
+ # Setup Front Matter Defaults. See https://jekyllrb.com/docs/configuration/front-matter-defaults/
64
+ #
65
+ site.config["defaults"].push({
66
+ "scope" => {
67
+ "path" => "", # an empty string here means all files in the project (or collection by type)
68
+ "type" => locale,
69
+ },
70
+ "values" => {
71
+ "layout" => "page",
72
+ # "permalink" => "/:collection/:slug",
73
+ }
74
+ })
75
+ site.config["defaults"].push({
76
+ "scope" => {
77
+ "path" => "_#{locale}/news",
78
+ "type" => locale,
79
+ },
80
+ "values" => {
81
+ "layout" => "post",
82
+ # "permalink" => "/#{locale}/news/:slug",
83
+ }
84
+ })
85
+ # Jekyll.logger.info "Anurina:", site.config["defaults"]
86
+
87
+ # raise MisconfigurationError
88
+
89
+ site.config["collections"][locale] = {
90
+ "output" => true,
91
+ "paginate" => true,
92
+ "lang_sort_order": index
93
+ }
94
+
95
+ Jekyll.logger.info "Anurina:", "Register ##{index} locale collection '#{locale}'"
96
+ end
97
+ end
98
+
99
+ #
100
+ # Hook: Whenever a page is initialized
101
+ # https://jekyllrb.com/docs/plugins/hooks/
102
+ #
103
+ Jekyll::Hooks.register :pages, :post_init do |page, payload|
104
+ if page.dir == "/content/"
105
+ raise MisconfigurationError.new("Pls move page '#{page.relative_path}' outside of 'content/' directory. The directory 'content/' are reserved for collections usage ONLY.")
106
+ end
107
+ end
108
+
109
+ #
110
+ # Hook: Whenever a post is initialized
111
+ # https://jekyllrb.com/docs/plugins/hooks/
112
+ #
113
+ Jekyll::Hooks.register :documents, :post_init do |document, payload|
114
+ collection_name = document.collection.label
115
+ if collection_name == "posts" || collection_name == "drafts"
116
+ Jekyll.logger.info "Anurina:", "Processing document #{document.relative_path}"
117
+ raise MisconfigurationError.new("Pls remove unsupported 'content/_posts' and 'content/_drafts' from your project to use the theme.")
118
+ end
119
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-theme-anurina-bootstrap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Max Anurin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-01-19 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: 4.3.3
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: 4.3.3
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ description:
34
+ email:
35
+ - jekyll-theme@anurin.name
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - README.md
41
+ - lib/jekyll-theme-anurina-bootstrap.rb
42
+ homepage: https://github.com/theanurin/jekyll-theme-anurina-bootstrap
43
+ licenses:
44
+ - MIT
45
+ metadata:
46
+ source_code_uri: https://github.com/theanurin/jekyll-theme-anurina-bootstrap
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: 3.0.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.5.22
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: A custom Jekyll plugin with Ruby logic
66
+ test_files: []