1
0
Эх сурвалжийг харах

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
Dave Powers 1 жил өмнө
parent
commit
5ff242b4c3

+ 9 - 0
lib/docs/core/manifest.rb

@@ -20,6 +20,15 @@ module Docs
         if doc.options[:attribution].is_a?(String)
           json[:attribution] = doc.options[:attribution].strip
         end
+
+        # parse doc aliases from JS file as Ruby hash
+        entry_file = File.open("assets/javascripts/models/entry.js")
+        data = entry_file.read
+        aliases = eval data.split("ALIASES = ").last.split(";").first
+
+        # set alias value
+        json["alias"] = aliases[json["slug"].to_sym]
+
         result << json
       end
     end