]> git.ardis.lu - ardislu.dev/commitdiff
Build home component regardless of path
authorArdis Lu <ardisglu@gmail.com>
Wed, 17 Aug 2022 03:43:03 +0000 (20:43 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 17 Aug 2022 03:43:03 +0000 (20:43 -0700)
Fixes bug where home is undefined when users search after opening an article direct link

script.js

index 4e7591758c0515cf0511056b0c6beb17fdf5fa09..0e9792c68a914f52f44285f3614233f2fcfee028 100644 (file)
--- a/script.js
+++ b/script.js
@@ -201,6 +201,7 @@ async function showPage(path) {
   if (globalThis.metadata.size === 0) {
     globalThis.metadata = await fetchPostMetadata();
     globalThis.flexIndex = buildFlexIndex(globalThis.metadata);
+    globalThis.components.set('home', buildHomeComponent(globalThis.metadata));
   }
 
   if (path === '/home' || path === '/') {
@@ -211,9 +212,7 @@ async function showPage(path) {
       editUrl: 'https://docs.google.com/spreadsheets/d/1pfGF8yBu3D0GPTezygLuzu3Cif8SkjhtG98nL-czlhc/edit'
     });
 
-    const homeComponent = buildHomeComponent(globalThis.metadata);
-    globalThis.components.set('home', homeComponent);
-    document.querySelector('main').replaceWith(homeComponent);
+    document.querySelector('main').replaceWith(globalThis.components.get('home'));
   }
   else if (globalThis.metadata.has(path)) {
     const post = globalThis.metadata.get(path);
This page took 0.036399 seconds and 4 git commands to generate.