From 88cc6646196c9f7e8493929f30102a471f6655e4 Mon Sep 17 00:00:00 2001 From: Michael DeMarco Date: Tue, 4 Jul 2023 17:20:51 -0700 Subject: [PATCH 1/3] fix: url bug; remove production check --- assets/js/util.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/assets/js/util.js b/assets/js/util.js index a7a0769c4d832..fc32f598a5bf7 100644 --- a/assets/js/util.js +++ b/assets/js/util.js @@ -102,9 +102,8 @@ const highlight = (content, term) => { }) .join(" ") .replaceAll(' ', " "); - return `${startIndex === 0 ? "" : "..."}${mappedText}${ - endIndex === splitText.length ? "" : "..." - }`; + return `${startIndex === 0 ? "" : "..."}${mappedText}${endIndex === splitText.length ? "" : "..." + }`; }; // Common utilities for search @@ -116,8 +115,9 @@ const resultToHTML = ({ url, title, content }) => { }; const redir = (id, term) => { - const shouldTrim = PRODUCTION && SEARCH_ENABLED; - const baseURLPrefix = shouldTrim ? "" : BASE_URL.replace(/\/$/g, ""); + // Remove the trailing slash from the base URL; `id` is already prefixed with a slash + const baseURLPrefix = BASE_URL.replace(/\/$/g, ""); + const urlString = `${baseURLPrefix}${id}#:~:text=${encodeURIComponent(term)}`; window.Million.navigate(new URL(urlString), ".singlePage"); closeSearch(); @@ -216,6 +216,7 @@ const displayResults = (term, finalResults, extractHighlight = false) => { } const anchors = [...document.getElementsByClassName("result-card")]; + anchors.forEach((anchor) => { anchor.onclick = () => redir(anchor.id, term); }); From 4cf9ed05d707c2f34079a671ecbc187f89cf61b9 Mon Sep 17 00:00:00 2001 From: Michael DeMarco Date: Tue, 4 Jul 2023 17:34:19 -0700 Subject: [PATCH 2/3] log url in prod --- .github/ISSUE_TEMPLATE/bug_report.md | 8 +++++--- assets/js/util.js | 4 +++- config.toml | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 189648d9c9539..d19b05a15893f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -12,6 +12,7 @@ A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: + 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' @@ -24,9 +25,10 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] + +- Device: [e.g. iPhone6] +- OS: [e.g. iOS] +- Browser [e.g. chrome, safari] **Additional context** Add any other context about the problem here. diff --git a/assets/js/util.js b/assets/js/util.js index fc32f598a5bf7..24e9fcc3b9366 100644 --- a/assets/js/util.js +++ b/assets/js/util.js @@ -117,8 +117,10 @@ const resultToHTML = ({ url, title, content }) => { const redir = (id, term) => { // Remove the trailing slash from the base URL; `id` is already prefixed with a slash const baseURLPrefix = BASE_URL.replace(/\/$/g, ""); - const urlString = `${baseURLPrefix}${id}#:~:text=${encodeURIComponent(term)}`; + + console.log({ urlString }); + window.Million.navigate(new URL(urlString), ".singlePage"); closeSearch(); plausible("Search", { diff --git a/config.toml b/config.toml index b95c83bb32946..0ef8569413823 100644 --- a/config.toml +++ b/config.toml @@ -1,18 +1,8 @@ -# joplin-garden-worker -engine = "hugo" -defaultFolder = "." -stripHtmlComments = true -includeTags = [ - "quartz" -] -[hugoOptions] - outputAsFolder = false - # quartz baseURL = "https://garden.michaeldemar.co/" languageCode = "en-us" relativeURLs = false -disablePathToLower = true +disablePathToLower = false ignoreFiles = [ "/content/templates/*", "/content/private/*", @@ -21,6 +11,16 @@ summaryLength = 20 paginate = 10 enableGitInfo = true +# joplin-garden-worker +engine = "hugo" +defaultFolder = "." +stripHtmlComments = true +includeTags = [ + "quartz" +] +[hugoOptions] + outputAsFolder = false + [markup] [markup.tableOfContents] endLevel = 3 From 46ae7fb5e8bbe2694122c654eb67b0fca4e7e4a1 Mon Sep 17 00:00:00 2001 From: Michael DeMarco Date: Tue, 4 Jul 2023 17:39:09 -0700 Subject: [PATCH 3/3] remove log; working --- assets/js/util.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/assets/js/util.js b/assets/js/util.js index 24e9fcc3b9366..0eb9914663bd6 100644 --- a/assets/js/util.js +++ b/assets/js/util.js @@ -119,8 +119,6 @@ const redir = (id, term) => { const baseURLPrefix = BASE_URL.replace(/\/$/g, ""); const urlString = `${baseURLPrefix}${id}#:~:text=${encodeURIComponent(term)}`; - console.log({ urlString }); - window.Million.navigate(new URL(urlString), ".singlePage"); closeSearch(); plausible("Search", {