forked from invopop/gobl.docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_mint_navigation.rb
More file actions
39 lines (32 loc) · 872 Bytes
/
Copy pathgenerate_mint_navigation.rb
File metadata and controls
39 lines (32 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require "json"
require "active_support/inflector"
# Automate the generation of Mintlify's navigation json
ActiveSupport::Inflector.inflections do |inflect|
inflect.acronym "GOBL"
inflect.acronym "UUID"
inflect.acronym "URL"
inflect.acronym "DSig"
inflect.acronym "ID"
inflect.acronym "CBC"
end
DOCS_DIR = "draft-0"
pages = Hash.new { |hash, key| hash[key] = [] }
Dir
.glob("#{DOCS_DIR}/**/*.mdx")
.each do |file|
dir = File.dirname(file).split("/").last
path = dir == DOCS_DIR ? dir : "#{DOCS_DIR}/" + dir
page = File.basename(file, ".mdx")
pages[dir] << "#{path}/#{page}"
end
parent_pages = pages[DOCS_DIR]
pages.delete(DOCS_DIR)
puts JSON.generate(
{
group: DOCS_DIR,
pages: [
parent_pages,
pages.map { |k, v| { group: k.camelize, pages: v } },
].flatten,
},
)