jekyll-optional-front-matter 0.0.1 → 0.1.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fe8954cd00f73507e5758cfab84cbb43c5c841e
|
4
|
+
data.tar.gz: d8c156ef4f997e5204d68f2b8ae096e52d3a4a2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b66ccd1cd180988edbbe76eaab3526c32f52c7486034c63f82e3d39cb9bb713e75053419ba21a79aa74fef771527363907c3fd5d882a087e1526fe5f22984f6
|
7
|
+
data.tar.gz: 2e8d918fcc4910d45f661edfb2d4c0cec37e02a377d439eb8a60fd2252d32ec92a6b6845d1a998022ef8564c6091de378ec3ba2b8919a2dde2232cdd9af4341e
|
@@ -1,5 +1,19 @@
|
|
1
1
|
require "jekyll"
|
2
2
|
|
3
3
|
module JekyllOptionalFrontMatter
|
4
|
+
# Case-insensitive array of filenames to exclude. All files must first
|
5
|
+
# match the config-defined list of markdown extensions. If you'd like one
|
6
|
+
# of these files included in your site, simply add YAML front matter to it.
|
7
|
+
FILENAME_BLACKLIST = %w(
|
8
|
+
README
|
9
|
+
LICENSE
|
10
|
+
LICENCE
|
11
|
+
COPYING
|
12
|
+
CODE_OF_CONDUCT
|
13
|
+
CONTRIBUTING
|
14
|
+
ISSUE_TEMPLATE
|
15
|
+
PULL_REQUEST_TEMPLATE
|
16
|
+
).freeze
|
17
|
+
|
4
18
|
autoload :Generator, "jekyll-optional-front-matter/generator"
|
5
19
|
end
|
@@ -2,7 +2,7 @@ module JekyllOptionalFrontMatter
|
|
2
2
|
class Generator < Jekyll::Generator
|
3
3
|
attr_accessor :site
|
4
4
|
|
5
|
-
safe
|
5
|
+
safe true
|
6
6
|
priority :low
|
7
7
|
|
8
8
|
def initialize(site)
|
@@ -12,15 +12,27 @@ module JekyllOptionalFrontMatter
|
|
12
12
|
def generate(site)
|
13
13
|
@site = site
|
14
14
|
return if site.config["require_front_matter"]
|
15
|
-
site.pages.concat(
|
15
|
+
site.pages.concat(pages_to_add)
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
# An array of Jekyll::Pages to add, *excluding* blacklisted files
|
21
|
+
def pages_to_add
|
22
|
+
pages.reject { |page| blacklisted?(page) }
|
23
|
+
end
|
24
|
+
|
25
|
+
# An array of potential Jekyll::Pages to add, *including* blacklisted files
|
20
26
|
def pages
|
21
27
|
markdown_files.map { |static_file| page_from_static_file(static_file) }
|
22
28
|
end
|
23
29
|
|
30
|
+
# An array of Jekyll::StaticFile's with a site-defined markdown extension
|
31
|
+
def markdown_files
|
32
|
+
site.static_files.select { |file| markdown_converter.matches(file.extname) }
|
33
|
+
end
|
34
|
+
|
35
|
+
# Given a Jekyll::StaticFile, returns the file as a Jekyll::Page
|
24
36
|
def page_from_static_file(static_file)
|
25
37
|
base = static_file.instance_variable_get("@base")
|
26
38
|
dir = static_file.instance_variable_get("@dir")
|
@@ -28,12 +40,13 @@ module JekyllOptionalFrontMatter
|
|
28
40
|
Jekyll::Page.new(site, base, dir, name)
|
29
41
|
end
|
30
42
|
|
31
|
-
|
32
|
-
|
43
|
+
# Does the given Jekyll::Page match our filename blacklist?
|
44
|
+
def blacklisted?(page)
|
45
|
+
FILENAME_BLACKLIST.include?(page.basename.upcase)
|
33
46
|
end
|
34
47
|
|
35
48
|
def markdown_converter
|
36
|
-
site.find_converter_instance(Jekyll::Converters::Markdown)
|
49
|
+
@markdown_converter ||= site.find_converter_instance(Jekyll::Converters::Markdown)
|
37
50
|
end
|
38
51
|
end
|
39
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-optional-front-matter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|