aboutsummaryrefslogtreecommitdiff
path: root/_plugins/linter.rb
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-12-27 22:19:07 -0300
committerEuAndreh <eu@euandre.org>2020-12-27 22:19:07 -0300
commitfb658f10b5c0db6ec7d1d3064517ad3cd240ca0b (patch)
treea70b881bf7ac2e414bba416ce2cc3a9662a91b7c /_plugins/linter.rb
parentUse explicit sh script call (diff)
downloadeuandre.org-fb658f10b5c0db6ec7d1d3064517ad3cd240ca0b.tar.gz
euandre.org-fb658f10b5c0db6ec7d1d3064517ad3cd240ca0b.tar.xz
linter.rb: Add all_documents iterator
Diffstat (limited to '')
-rw-r--r--_plugins/linter.rb52
1 files changed, 23 insertions, 29 deletions
diff --git a/_plugins/linter.rb b/_plugins/linter.rb
index 188aede..5d78c17 100644
--- a/_plugins/linter.rb
+++ b/_plugins/linter.rb
@@ -21,20 +21,8 @@ module Jekyll
def assert_unique_ids(site)
@known_ids = Set[]
- site.collections.each do |name, collection|
- collection.docs.each do |document|
- unless document.data['generated'] then
- insert_id name, document
- end
- end
- end
-
- site.pages.each do |page|
- unless IGNORED_PAGES.include? page.path
- unless page.data['generated'] then
- insert_id 'page', page
- end
- end
+ all_documents(site) do |collection_name, document|
+ insert_id collection_name, document
end
end
@@ -71,7 +59,7 @@ module Jekyll
'screencasts' => 'cast'
}
- def assert_frontmatter_fields(site, name, document)
+ def assert_frontmatter_fields(name, document)
title = assert_field document, 'title'
lang = assert_field document, 'lang'
ref = assert_field document, 'ref'
@@ -127,20 +115,8 @@ module Jekyll
end
def assert_frontmatter(site)
- site.collections.each do |name, collection|
- collection.docs.each do |document|
- unless document.data['generated']
- assert_frontmatter_fields site, name, document
- end
- end
- end
-
- site.pages.each do |page|
- unless IGNORED_PAGES.include? page.path
- unless page.data['generated']
- assert_frontmatter_fields site, 'page', page
- end
- end
+ all_documents(site) do |collection_name, document|
+ assert_frontmatter_fields collection_name, document
end
end
@@ -163,5 +139,23 @@ module Jekyll
assert_frontmatter(site)
assert_git_annex(site)
end
+
+ def all_documents(site)
+ site.collections.each do |name, collection|
+ collection.docs.each do |document|
+ unless document.data['generated']
+ yield name, document
+ end
+ end
+ end
+
+ site.pages.each do |page|
+ unless IGNORED_PAGES.include? page.path
+ unless page.data['generated']
+ yield 'page', page
+ end
+ end
+ end
+ end
end
end