Skip to content

Commit 5ff242b

Browse files
committed
Add field to docs.json denoting available aliases
- read JavaScript file defining slug/alias mapping - parse aliases object as Ruby hash - add alias key to JSON output with value or null
1 parent df68815 commit 5ff242b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/docs/core/manifest.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ def as_json
2020
if doc.options[:attribution].is_a?(String)
2121
json[:attribution] = doc.options[:attribution].strip
2222
end
23+
24+
# parse doc aliases from JS file as Ruby hash
25+
entry_file = File.open("assets/javascripts/models/entry.js")
26+
data = entry_file.read
27+
aliases = eval data.split("ALIASES = ").last.split(";").first
28+
29+
# set alias value
30+
json["alias"] = aliases[json["slug"].to_sym]
31+
2332
result << json
2433
end
2534
end

0 commit comments

Comments
 (0)