diff --git a/_plugins/jekyll-i18n-api-context.rb b/_plugins/jekyll-i18n-api-context.rb deleted file mode 100644 index 876f8bf..0000000 --- a/_plugins/jekyll-i18n-api-context.rb +++ /dev/null @@ -1,20 +0,0 @@ -# THIS IS AN DRAFT. Ignore it now. (Emerson Rocha, 2021-05-16) -# -# https://jekyllrb.com/docs/plugins/generators/ - -# module Reading -# class Generator < Jekyll::Generator -# def generate(site) -# book_data = site.data['books'] -# ongoing = book_data.select { |book| book['status'] == 'ongoing' } -# done = book_data.select { |book| book['status'] == 'finished' } - -# # get template -# reading = site.pages.find { |page| page.name == 'reading.html'} - -# # inject data into template -# reading.data['ongoing'] = ongoing -# reading.data['done'] = done -# end -# end -# end \ No newline at end of file diff --git a/_plugins/jekyll-i18n-api-generator.rb b/_plugins/jekyll-i18n-api-generator.rb deleted file mode 100644 index 0ed9a11..0000000 --- a/_plugins/jekyll-i18n-api-generator.rb +++ /dev/null @@ -1,52 +0,0 @@ -# THIS IS AN DRAFT. Ignore it now. (Emerson Rocha, 2021-05-16) -# -# https://jekyllrb.com/docs/plugins/generators/ - -# module SamplePlugin -# class CategoryPageGenerator < Jekyll::Generator -# safe true - -# def generate(site) -# site.categories.each do |category, posts| -# site.pages << CategoryPage.new(site, category, posts) -# end -# end -# end - -# # Subclass of `Jekyll::Page` with custom method definitions. -# class CategoryPage < Jekyll::Page -# def initialize(site, category, posts) -# @site = site # the current site instance. -# @base = site.source # path to the source directory. -# @dir = category # the directory the page will reside in. - -# # All pages have the same filename, so define attributes straight away. -# @basename = 'index' # filename without the extension. -# @ext = '.html' # the extension. -# @name = 'index.html' # basically @basename + @ext. - -# # Initialize data hash with a key pointing to all posts under current category. -# # This allows accessing the list in a template via `page.linked_docs`. -# @data = { -# 'linked_docs' => posts -# } - -# # Look up front matter defaults scoped to type `categories`, if given key -# # doesn't exist in the `data` hash. -# data.default_proc = proc do |_, key| -# site.frontmatter_defaults.find(relative_path, :categories, key) -# end -# end - -# # Placeholders that are used in constructing page URL. -# def url_placeholders -# { -# :category => @dir, -# :basename => basename, -# :output_ext => output_ext, -# } -# end -# end -# end - -# Liquid::Template.register_filter(Jekyll::DataPageLinkGenerator) \ No newline at end of file diff --git a/_plugins/jekyll-i18n-api.rb b/_plugins/jekyll-i18n-api.rb new file mode 100644 index 0000000..70112c4 --- /dev/null +++ b/_plugins/jekyll-i18n-api.rb @@ -0,0 +1,52 @@ +# THIS IS AN DRAFT. Ignore it now. (Emerson Rocha, 2021-05-16) +# +# https://jekyllrb.com/docs/plugins/generators/ + +module SamplePlugin + class CategoryPageGenerator < Jekyll::Generator + safe true + + def generate(site) + site.categories.each do |category, posts| + site.pages << CategoryPage.new(site, category, posts) + end + end + end + + # Subclass of `Jekyll::Page` with custom method definitions. + class CategoryPage < Jekyll::Page + def initialize(site, category, posts) + @site = site # the current site instance. + @base = site.source # path to the source directory. + @dir = category # the directory the page will reside in. + + # All pages have the same filename, so define attributes straight away. + @basename = 'index' # filename without the extension. + @ext = '.html' # the extension. + @name = 'index.html' # basically @basename + @ext. + + # Initialize data hash with a key pointing to all posts under current category. + # This allows accessing the list in a template via `page.linked_docs`. + @data = { + 'linked_docs' => posts + } + + # Look up front matter defaults scoped to type `categories`, if given key + # doesn't exist in the `data` hash. + data.default_proc = proc do |_, key| + site.frontmatter_defaults.find(relative_path, :categories, key) + end + end + + # Placeholders that are used in constructing page URL. + def url_placeholders + { + :category => @dir, + :basename => basename, + :output_ext => output_ext, + } + end + end + end + +# Liquid::Template.register_filter(Jekyll::DataPageLinkGenerator) \ No newline at end of file