diff --git a/astro.config.mjs b/astro.config.mjs index 7da25fe..35ef428 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -11,6 +11,9 @@ export default defineConfig({ }, }), ], - adapter: node({ mode: "standalone" }), + adapter: node({ mode: "standalone", checkOrigin: false }), output: "server", + security: { + checkOrigin: false + } }); \ No newline at end of file diff --git a/src/assets/js/main.js b/src/assets/js/main.js index d7ec691..30cb966 100644 --- a/src/assets/js/main.js +++ b/src/assets/js/main.js @@ -1,3 +1,25 @@ -const filterfacet = (event) => { - console.log(event); -} \ No newline at end of file +import * as bootstrap from 'bootstrap'; +window.bootstrap = bootstrap; + + +// trap browser back and close the modal if open +const cardModal = document.getElementById('cardModal'); +// Push a new history state when the modal is shown +cardModal.addEventListener('shown.bs.modal', () => { + history.pushState({ modalOpen: true }, null, '#cardModal'); +}); +// Listen for the browser's back button (popstate event) +window.addEventListener('popstate', (e) => { + if (cardModal.classList.contains('show')) { + const modalInstance = bootstrap.Modal.getInstance(cardModal); + if (modalInstance) { + modalInstance.hide(); + } + } +}); +// Trigger a back navigation when the modal is closed via its native controls (X, backdrop click) +cardModal.addEventListener('hide.bs.modal', () => { + if (history.state && history.state.modalOpen) { + history.back(); + } +}); \ No newline at end of file diff --git a/src/layouts/Main.astro b/src/layouts/Main.astro index 26a3ef1..5e42ae6 100644 --- a/src/layouts/Main.astro +++ b/src/layouts/Main.astro @@ -38,22 +38,7 @@ import '/src/assets/css/main.scss'; - - + \ No newline at end of file diff --git a/src/pages/partials/cards.astro b/src/pages/partials/cards.astro index 3f6a0a4..598f309 100644 --- a/src/pages/partials/cards.astro +++ b/src/pages/partials/cards.astro @@ -122,7 +122,7 @@ const facets = searchResults.results.slice(1).map((result: any) => {
- +
{facets.map((facet) => (