jekyll-open-sdg-plugins 1.0.0.rc11 → 1.0.0.rc12
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3ddcd012812807b48b5b94dbbedfe47d4c3187f60383439fa0eb26c1f28e90f
|
4
|
+
data.tar.gz: 64a473bdd4e7f3c64f2d9cf2e1c1e1b7659b2273f96b4089e0f4c74f0a8a09fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bc05be3e1b50b49560c235df08893590ba67ace6b59056c77d049f7bb650ce955cc1ec1257145a7a02835f5245f4d8e84816eda4cf616e31a9549dac519b96f
|
7
|
+
data.tar.gz: 994312f102ed250a8978d812aacc7d598767d062b5c9b065c420012311199345514cd0765b4af19bdd483bd684d9f83b405c3427c14ce54e9fcc93c7112650cb
|
@@ -5,6 +5,7 @@ require_relative "jekyll-open-sdg-plugins/create_indicators"
|
|
5
5
|
require_relative "jekyll-open-sdg-plugins/create_goals"
|
6
6
|
require_relative "jekyll-open-sdg-plugins/create_pages"
|
7
7
|
require_relative "jekyll-open-sdg-plugins/sdg_variables"
|
8
|
+
require_relative "jekyll-open-sdg-plugins/search_index"
|
8
9
|
|
9
10
|
module JekyllOpenSdgPlugins
|
10
11
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require_relative "helpers"
|
3
|
+
|
4
|
+
module JekyllOpenSdgPlugins
|
5
|
+
class SearchIndex < Jekyll::Generator
|
6
|
+
safe true
|
7
|
+
priority :lowest
|
8
|
+
# NOTE: This must be executed **after** the sdg_variables.rb file, since it
|
9
|
+
# relies heavily on the variables created there.
|
10
|
+
|
11
|
+
def generate(site)
|
12
|
+
|
13
|
+
# Generate a hash of items to include in the search index.
|
14
|
+
search_items = {}
|
15
|
+
|
16
|
+
site.collections.keys.each do |collection|
|
17
|
+
site.collections[collection].docs.each do |doc|
|
18
|
+
# We segregate the search items by language.
|
19
|
+
language = doc.data['language']
|
20
|
+
if !search_items.has_key? language
|
21
|
+
search_items[language] = {}
|
22
|
+
end
|
23
|
+
# We'll be adding properties to this basic hash.
|
24
|
+
item = {
|
25
|
+
# The 'type' can be used on the front-end to describe a search result.
|
26
|
+
# It is assumed that all the collection names are translated in the
|
27
|
+
# "general" translation group. Eg: general.indicators, general.goals
|
28
|
+
'type' => opensdg_translate_key('general.' + collection, site.data['translations'], language)
|
29
|
+
}
|
30
|
+
if collection == 'indicators'
|
31
|
+
# For indicators, we assign the following properties for each item.
|
32
|
+
# The URL of the page.
|
33
|
+
item['url'] = doc.data['indicator']['url']
|
34
|
+
# For the title, use the indicator name.
|
35
|
+
item['title'] = doc.data['indicator']['name']
|
36
|
+
# For the content, use the 'page_content' field.
|
37
|
+
item['content'] = doc.data['indicator']['page_content']
|
38
|
+
# For the hidden field, use the ID number.
|
39
|
+
item['hidden'] = doc.data['indicator']['number']
|
40
|
+
# Also index any additional metadata fields.
|
41
|
+
if site.config['search_index_extra_fields']
|
42
|
+
site.config['search_index_extra_fields'].each do |field|
|
43
|
+
if doc.data['indicator'].has_key? field
|
44
|
+
item['hidden'] += ' ' + doc.data['indicator'][field]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
elsif collection == 'goals'
|
49
|
+
# For goals, we assign the following properties for each item.
|
50
|
+
# The URL of the page.
|
51
|
+
item['url'] = doc.data['goal']['url']
|
52
|
+
# For the title we use the goal name.
|
53
|
+
item['title'] = doc.data['goal']['name']
|
54
|
+
# For the content, currently nothing here.
|
55
|
+
item['content'] = ''
|
56
|
+
# For the hidden field, use the ID number.
|
57
|
+
item['hidden'] = doc.data['goal']['number']
|
58
|
+
else
|
59
|
+
# Otherwise assume it is a normal Jekyll document.
|
60
|
+
item['url'] = doc.url
|
61
|
+
item['title'] = doc.data['title']
|
62
|
+
item['content'] = doc.content
|
63
|
+
item['hidden'] = ''
|
64
|
+
end
|
65
|
+
|
66
|
+
# Save this item in the language-specific search index.
|
67
|
+
search_items[language][item['url']] = item
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Stow the data for later use in Jekyll templates.
|
72
|
+
site.data['search_items'] = search_items
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-open-sdg-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brock Fanning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/jekyll-open-sdg-plugins/fetch_remote_data.rb
|
58
58
|
- lib/jekyll-open-sdg-plugins/helpers.rb
|
59
59
|
- lib/jekyll-open-sdg-plugins/sdg_variables.rb
|
60
|
+
- lib/jekyll-open-sdg-plugins/search_index.rb
|
60
61
|
- lib/jekyll-open-sdg-plugins/translate_key.rb
|
61
62
|
- lib/jekyll-open-sdg-plugins/version.rb
|
62
63
|
homepage: https://github.com/open-sdg/jekyll-open-sdg-plugins
|