From 191e59fe188888e78792d367a5a7fe6c3b4ea2dc Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Mon, 2 Oct 2023 07:21:00 -0700 Subject: [PATCH] Fix navbar toggle on mobile/plugin page Previously, the scripts for the page had multiple entrypoints, which caused bootstrap to load multiple times (and thus to register navbar toggle listeners multiple times). --- build/bundleJs.ts | 1 - src/pages/plugin/[pluginName].mustache | 3 --- src/runtime/index.ts | 5 +++++ .../plugin/{pluginPage.ts => initializePluginPage.ts} | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) rename src/runtime/plugin/{pluginPage.ts => initializePluginPage.ts} (95%) diff --git a/build/bundleJs.ts b/build/bundleJs.ts index 171f531..f612726 100644 --- a/build/bundleJs.ts +++ b/build/bundleJs.ts @@ -10,7 +10,6 @@ const bundleJs = (buildConfig: BuildConfig, watch: boolean): Promise => { mode: 'production', entry: { main: path.join(runtimeDirectory, 'index.ts'), - 'plugin-page': path.join(runtimeDirectory, 'plugin', 'pluginPage.ts'), }, output: { path: buildConfig.distDir, diff --git a/src/pages/plugin/[pluginName].mustache b/src/pages/plugin/[pluginName].mustache index fb712c0..0ef3810 100644 --- a/src/pages/plugin/[pluginName].mustache +++ b/src/pages/plugin/[pluginName].mustache @@ -129,9 +129,6 @@ -{{! Initializes screenshots and postprocesses the README }} - - {{> plugin-documentation-link}} diff --git a/src/runtime/index.ts b/src/runtime/index.ts index d8056fc..b6fe238 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -1,5 +1,6 @@ import PluginDataManager from './PluginDataManager'; import initializeSearch from './search/initializeSearch'; +import initializePluginPage from './plugin/initializePluginPage'; import initializeDownloadPage from './initializeDownloadPage'; import 'bootstrap'; @@ -11,6 +12,10 @@ const siteRoot: string = (window as any).siteRoot; window.addEventListener('DOMContentLoaded', async () => { const page = (window as any).pageId ?? 'default'; + if (page === 'pluginDisplay') { + initializePluginPage(); + } + const pluginDataManager = await PluginDataManager.fromURL( `${siteRoot}/pluginData.json`, siteRoot, diff --git a/src/runtime/plugin/pluginPage.ts b/src/runtime/plugin/initializePluginPage.ts similarity index 95% rename from src/runtime/plugin/pluginPage.ts rename to src/runtime/plugin/initializePluginPage.ts index 00b57fa..ff39b5f 100644 --- a/src/runtime/plugin/pluginPage.ts +++ b/src/runtime/plugin/initializePluginPage.ts @@ -21,4 +21,4 @@ const initializePluginPage = () => { } }; -initializePluginPage(); +export default initializePluginPage;