Skip to content

Commit 61c6e60

Browse files
committed
add updates to resources sidebar
1 parent 2112997 commit 61c6e60

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

data/resources_navigation.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@
125125
"path": "/resources/versions/",
126126
"children": []
127127
},
128+
{
129+
"name": "Updates",
130+
"id": "updates",
131+
"path": "/resources/updates/",
132+
"children": []
133+
},
128134
{
129135
"name": "Legal & Branding",
130136
"id": "brand",

modules/resources/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ def get_menu():
5252
"external_link": False,
5353
"children": [],
5454
},
55+
{
56+
"display_name": "Updates",
57+
"url": "/resources/updates/",
58+
"external_link": False,
59+
"children": [],
60+
},
5561
{
5662
"display_name": "Legal & Branding",
5763
"url": "/resources/legal-and-branding/",

modules/resources/resources.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,39 @@ def generate_static_pages():
219219

220220
if not [key["module_name"] for key in modules.run_ptr if key["module_name"] == "versions"]:
221221
util.buildhelpers.remove_element_from_sub_menu(resources_config.module_name, "Version History")
222+
223+
# Below code used to get a list of all updates children
224+
updates_dict_list = {}
225+
updates_name = []
226+
updates_path = []
227+
for static_page in os.listdir(static_pages_dir):
228+
with open(os.path.join(static_pages_dir, static_page), "r", encoding="utf8") as md:
229+
content = md.read()
230+
if static_page.startswith("updates-"):
231+
temp_string = static_page.replace(".md", "")
232+
temp_string = temp_string.split("-")
233+
temp_string = temp_string[1].capitalize() + " " + temp_string[2]
234+
updates_name.append(temp_string)
235+
temp_string = static_page.replace(".md", "")
236+
updates_path.append("/resources/updates/" + temp_string + "/")
237+
updates_name.sort(key=lambda date: datetime.strptime(date, "%B %Y"), reverse=True)
238+
updates_path.sort(key=lambda date: datetime.strptime(date, "/resources/updates/updates-%B-%Y/"), reverse=True)
239+
updates_dict_list["updates_name"] = updates_name
240+
updates_dict_list["updates_path"] = updates_path
241+
242+
# Below code used to add the updates children to the resources sidebar
243+
updates_index = 0
244+
temp_dict = {}
245+
for i in range(len(site_config.resource_nav["children"])):
246+
if site_config.resource_nav["children"][i]["name"] == "Updates":
247+
updates_index = i
248+
249+
for i in range(len(updates_dict_list["updates_name"])):
250+
temp_dict["name"] = updates_dict_list["updates_name"][i]
251+
temp_dict["path"] = updates_dict_list["updates_path"][i]
252+
temp_dict["children"] = []
253+
site_config.resource_nav["children"][updates_index]["children"].append(temp_dict.copy())
254+
temp_dict = {}
222255

223256
for static_page in os.listdir(static_pages_dir):
224257
with open(os.path.join(static_pages_dir, static_page), "r", encoding="utf8") as md:

0 commit comments

Comments
 (0)