@@ -21,6 +21,7 @@ def write_yaml_file(file_path, data)
2121 file . write ( "id: " + data [ "id" ] + "\n " )
2222 file . write ( "url: " + data [ "url" ] + "\n " )
2323 file . write ( "title: " + data [ "title" ] + "\n " )
24+ file . write ( "pri: " + data [ "pri" ] . to_s + "\n " )
2425 end
2526 #puts file_path
2627 end
@@ -88,6 +89,7 @@ def generate_links(page, ids, titles)
8889 "id" => page_id + "##{ heading_id } " ,
8990 "url" => page_url + "##{ heading_id } " ,
9091 "title" => '"' + render_title ( page , heading . text ) + '"' ,
92+ "pri" => 50 ,
9193 }
9294 #register_id(page, link_data["id"], link_data["title"], ids, titles)
9395
@@ -111,6 +113,7 @@ def generate_links(page, ids, titles)
111113 "id" => anchor_id ,
112114 "url" => page_url + "##{ anchor_name } " ,
113115 "title" => '"' + ( anchor_text . empty? ? anchor_id : render_title ( page , anchor_text ) ) + '"' ,
116+ "pri" => 50 ,
114117 }
115118 #register_id(page, link_data["id"], link_data["title"], ids, titles)
116119
@@ -125,11 +128,29 @@ def generate_links(page, ids, titles)
125128 "id" => page_id ,
126129 "url" => page_url ,
127130 "title" => '"' + page_title + '"' ,
131+ "pri" => 50 ,
128132 }
129133 register_id ( page , page_link_data [ "id" ] , page_link_data [ "title" ] , ids , titles )
130134
131135 # Write data to separate YAML file for each page
132- page_file_path = "#{ page_id } .#{ link_ext } "
136+ page_file_path = "#{ page_link_data [ "id" ] } .#{ link_ext } "
137+ page_file_path = "_data/links/" + page_file_path . gsub ( /\/ |:|\s / , "-" ) . downcase
138+ write_yaml_file ( page_file_path , page_link_data )
139+
140+ # Create links data for the page short_title too
141+ page_short_title = page . data [ "short_title" ]
142+ if page_short_title and not page_short_title . empty?
143+ page_link_data = {
144+ "id" => page_id + "_short_title" ,
145+ "url" => page_url ,
146+ "title" => '"' + page_short_title + '()"' ,
147+ "pri" => 100 ,
148+ }
149+ register_id ( page , page_link_data [ "id" ] , page_link_data [ "title" ] , ids , titles )
150+ end
151+
152+ # Write data to separate YAML file for each page short_title
153+ page_file_path = "#{ page_link_data [ "id" ] } .#{ link_ext } "
133154 page_file_path = "_data/links/" + page_file_path . gsub ( /\/ |:|\s / , "-" ) . downcase
134155 write_yaml_file ( page_file_path , page_link_data )
135156
0 commit comments