Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
galaxyproject
GitHub Repository: galaxyproject/training-material
Path: blob/main/_plugins/by-tag-pages.rb
1677 views
1
require './_plugins/jekyll-topic-filter'
2
3
module Jekyll
4
module Generators
5
##
6
# This class generates the GTN's Tag Pages
7
class TagPageGenerator < Generator
8
safe true
9
10
##
11
# This generates the author pages
12
# Params
13
# +site+:: The site object
14
def generate(site)
15
if Jekyll.env == 'production'
16
_generate(site)
17
end
18
end
19
20
def _generate(site)
21
Jekyll.logger.info '[GTN/SyntheticTopics] Generating By-Tag Indexes'
22
Gtn::TopicFilter.list_all_tags(site).map do |tag|
23
site.data["by_tag_#{tag}"] = {
24
'name' => "by_tag_#{tag}",
25
'type' => 'use',
26
'title' => tag,
27
'summary' => "Tutorials covering #{tag}",
28
'tag_based' => true,
29
'hidden' => true,
30
}
31
32
topic_index = PageWithoutAFile.new(site, '', "tags/#{Jekyll::Utils.slugify(tag)}", 'index.md')
33
topic_index.content = ''
34
topic_index.data['layout'] = 'topic'
35
topic_index.data['topic_name'] = "by_tag_#{tag}"
36
topic_index.data['topic'] = site.data["by_tag_#{tag}"]
37
38
site.pages << topic_index
39
end
40
41
Jekyll.logger.info '[GTN/SyntheticTopics] Generating By-Tag Embeds'
42
Gtn::TopicFilter.list_all_tags(site).map do |tag|
43
topic_index = PageWithoutAFile.new(site, '', "tags/#{Jekyll::Utils.slugify(tag)}", 'embed.html')
44
topic_index.content = ''
45
topic_index.data['layout'] = 'topic-embed'
46
topic_index.data['topic_name'] = "by_tag_#{tag}"
47
topic_index.data['topic'] = site.data["by_tag_#{tag}"]
48
49
site.pages << topic_index
50
end
51
end
52
end
53
end
54
end
55
56