From 87e8586a755731b28d173794d7dfe023d61e3947 Mon Sep 17 00:00:00 2001 From: reuixiy Date: Sun, 14 Jun 2020 17:41:47 +0800 Subject: [PATCH] fix: Do not load the script in 404 page (#200) Fixed #199 --- assets/js/lunr-search.js | 1 + layouts/404.html | 2 +- layouts/partials/head.html | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/js/lunr-search.js b/assets/js/lunr-search.js index 1f132e90..47d54345 100644 --- a/assets/js/lunr-search.js +++ b/assets/js/lunr-search.js @@ -7,6 +7,7 @@ window.addEventListener("DOMContentLoaded", event => { const form = document.getElementById("search"); const input = document.getElementById("search-input"); + form.addEventListener("submit", function(event) { event.preventDefault(); diff --git a/layouts/404.html b/layouts/404.html index 699729b0..6a8a9597 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -23,4 +23,4 @@

{{ i18n "pageNotFound" }}

- \ No newline at end of file + diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 8a5ed899..458ffd2c 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -26,7 +26,9 @@ {{- partial "style.html" . }} - {{ partial "script.html" . }} + {{ if ne .Kind "404" }} + {{ partial "script.html" . }} + {{ end }} {{- with .Site.Params.fontsLink -}}