From 170193146729f0c22582430f52a4e270e801ce5f Mon Sep 17 00:00:00 2001 From: Will Bamberg Date: Thu, 16 Feb 2023 13:16:17 -0800 Subject: [PATCH 01/10] Create a PWA sidebar --- kumascript/macros/PWASidebar.ejs | 117 +++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 kumascript/macros/PWASidebar.ejs diff --git a/kumascript/macros/PWASidebar.ejs b/kumascript/macros/PWASidebar.ejs new file mode 100644 index 000000000000..ee52caab8f17 --- /dev/null +++ b/kumascript/macros/PWASidebar.ejs @@ -0,0 +1,117 @@ +<% + +const sections = [ + { + name: "Guides", + contents: [ + "Guides/What_is_a_PWA", + "Guides/Benefits_of_PWAs", + { + name: "Guides/Main_features_of_PWAs", + contents: [ + "Guides/Main_features_of_PWAs/Installability", + "Guides/Main_features_of_PWAs/Offline_operation", + ], + }, + ], + }, + { + name: "Tutorials", + contents: [ + { + name: "Tutorials/Your_first_PWA", + contents: [ + "Tutorials/Your_first_PWA/First_step", + "Tutorials/Your_first_PWA/Next_step", + ], + }, + { + name: "Tutorials/Your_second_PWA", + contents: [ + "Tutorials/Your_second_PWA/First_step", + "Tutorials/Your_second_PWA/Next_step", + ], + }, + ], + }, + { + name: "How-to", + contents: [ + "How-to/Handle_app_updates", + "How-to/Implement_a_custom_install_flow", + ], + }, + { + name: "Reference", + contents: [], + }, +]; + +const sidebarURL = `/docs/Web/Progressive_Web_Apps/`; +const baseURL = `/${env.locale}${sidebarURL}`; + +async function getTitle(pageSlug) { + let page = await wiki.getPage(`${baseURL}${pageSlug}`); + if (!page.title) { + page = await wiki.getPage(`/en-US${sidebarURL}${pageSlug}`); + } + return page.title; +} + +async function renderSubsection(subsection) { + let output = `
  • ${await getTitle( + subsection.name + )}
      `; + + for (const item of subsection.contents) { + output += await renderItem(item); + } + output += "
  • "; + + return output; +} + +async function renderItem(item) { + let output = ""; + if (typeof item === "string") { + output += `
  • ${await getTitle( + item + )}
  • `; + } else { + output += `
    1. ${await renderSubsection(item)}
  • `; + } + return output; +} + +async function renderSection(section) { + let output = `
  • ${await getTitle(section.name)}
  • `; + + for (const item of section.contents) { + output += await renderItem(item); + } + + return output; +} + +async function renderSidebar() { + let output = '"; + + return output; +} + +const output = await renderSidebar(); + +%> + +<%-output%> From 1d9dd64a38b9362747f7cf23f0b38422ffd18770 Mon Sep 17 00:00:00 2001 From: Will Bamberg Date: Fri, 17 Feb 2023 12:03:55 -0800 Subject: [PATCH 02/10] Fix case for sidebar URL --- kumascript/macros/PWASidebar.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kumascript/macros/PWASidebar.ejs b/kumascript/macros/PWASidebar.ejs index ee52caab8f17..8740c92e8a2a 100644 --- a/kumascript/macros/PWASidebar.ejs +++ b/kumascript/macros/PWASidebar.ejs @@ -47,7 +47,7 @@ const sections = [ }, ]; -const sidebarURL = `/docs/Web/Progressive_Web_Apps/`; +const sidebarURL = `/docs/Web/Progressive_web_apps/`; const baseURL = `/${env.locale}${sidebarURL}`; async function getTitle(pageSlug) { From 301b902740646fb8910e67ca5bfb09d953747c86 Mon Sep 17 00:00:00 2001 From: wbamberg Date: Mon, 3 Apr 2023 11:48:31 -0700 Subject: [PATCH 03/10] Update kumascript/macros/PWASidebar.ejs Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com> --- kumascript/macros/PWASidebar.ejs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kumascript/macros/PWASidebar.ejs b/kumascript/macros/PWASidebar.ejs index 8740c92e8a2a..ddb891ee1f71 100644 --- a/kumascript/macros/PWASidebar.ejs +++ b/kumascript/macros/PWASidebar.ejs @@ -63,9 +63,7 @@ async function renderSubsection(subsection) { subsection.name )}
      `; - for (const item of subsection.contents) { - output += await renderItem(item); - } + output += (await Promise.all(subsection.contents.map(item => renderItem(item))).join(''); output += "
    "; return output; From 9b044f2f35bc92d661805478f883d2442b952ee5 Mon Sep 17 00:00:00 2001 From: wbamberg Date: Mon, 3 Apr 2023 11:48:40 -0700 Subject: [PATCH 04/10] Update kumascript/macros/PWASidebar.ejs Co-authored-by: Claas Augner <495429+caugner@users.noreply.github.com> --- kumascript/macros/PWASidebar.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kumascript/macros/PWASidebar.ejs b/kumascript/macros/PWASidebar.ejs index ddb891ee1f71..b0eb08265a50 100644 --- a/kumascript/macros/PWASidebar.ejs +++ b/kumascript/macros/PWASidebar.ejs @@ -94,7 +94,7 @@ async function renderSection(section) { } async function renderSidebar() { - let output = '