diff --git a/functions/search-default.js b/functions/search-default.js index dcacb75..6b904bd 100644 --- a/functions/search-default.js +++ b/functions/search-default.js @@ -43,7 +43,7 @@ fetch("/static/scripts/posts.json") // Insert the default-single-post-preview.css at the end of the head tag document.head.insertAdjacentHTML( "beforeend", - '' + '' ) // Define an empty string that will hold the search result(s) diff --git a/static/scripts/clean-blog-scripts.js b/static/scripts/clean-blog-scripts.js deleted file mode 100644 index f5ad645..0000000 --- a/static/scripts/clean-blog-scripts.js +++ /dev/null @@ -1,47 +0,0 @@ -window.addEventListener("DOMContentLoaded", () => { - let scrollPos = 0 - const mainNav = document.getElementById("mainNav") - const headerHeight = mainNav.clientHeight - window.addEventListener("scroll", function () { - const currentTop = document.body.getBoundingClientRect().top * -1 - if (currentTop < scrollPos) { - // Scrolling Up - if (currentTop > 0 && mainNav.classList.contains("is-fixed")) { - mainNav.classList.add("is-visible") - } else { - mainNav.classList.remove("is-visible", "is-fixed") - } - } else { - // Scrolling Down - mainNav.classList.remove(["is-visible"]) - if (currentTop > headerHeight && !mainNav.classList.contains("is-fixed")) { - mainNav.classList.add("is-fixed") - } - } - scrollPos = currentTop - }) -}) - -// RESPONSIVE IMAGES IN PAGES AND POSTS -const main = document.getElementById("main") -const images = main.querySelectorAll("img") -images.forEach((image) => { - image.classList.add("img-fluid") -}) - -// Detect external links -const isExternalLink = (url) => { - const tmp = document.createElement("a") - tmp.href = url - return tmp.host !== window.location.host -} -// Select all links -const allLinks = document.querySelectorAll("a") -// Add attributes and icon to each external link -allLinks.forEach((link) => { - if (isExternalLink(link)) { - link.setAttribute("target", "_blank") - link.setAttribute("rel", "external noopener noreferrer") - link.insertAdjacentHTML("beforeend", ` `) - } -}) diff --git a/static/scripts/themes/clean-blog/clean-blog-scripts.js b/static/scripts/themes/clean-blog/clean-blog-scripts.js new file mode 100644 index 0000000..c7ac143 --- /dev/null +++ b/static/scripts/themes/clean-blog/clean-blog-scripts.js @@ -0,0 +1,53 @@ +window.addEventListener("DOMContentLoaded", () => { + let scrollPos = 0 + const mainNav = document.getElementById("mainNav") + const headerHeight = mainNav.clientHeight + window.addEventListener("scroll", function () { + const currentTop = document.body.getBoundingClientRect().top * -1 + if (currentTop < scrollPos) { + // Scrolling Up + if (currentTop > 0 && mainNav.classList.contains("is-fixed")) { + mainNav.classList.add("is-visible") + } else { + mainNav.classList.remove("is-visible", "is-fixed") + } + } else { + // Scrolling Down + mainNav.classList.remove(["is-visible"]) + if (currentTop > headerHeight && !mainNav.classList.contains("is-fixed")) { + mainNav.classList.add("is-fixed") + } + } + scrollPos = currentTop + }) + + // RESPONSIVE IMAGES IN PAGES AND POSTS + const main = document.getElementById("main") + // Ensure that a page or a post is displayed + if (main) { + const images = main.querySelectorAll("img") + images.forEach((image) => { + image.classList.add("img-fluid") + }) + } + + // Detect external links + const isExternalLink = (url) => { + const tmp = document.createElement("a") + tmp.href = url + return tmp.host !== window.location.host + } + // Select all links + const allLinks = document.querySelectorAll("a") + // Add attributes and icon to each external link + allLinks.forEach((link) => { + if (isExternalLink(link)) { + link.setAttribute("target", "_blank") + link.setAttribute("rel", "external noopener noreferrer") + link.insertAdjacentHTML( + "beforeend", + ` ` + ) + } + }) +}) diff --git a/static/scripts/default-scripts.js b/static/scripts/themes/default/default-scripts.js similarity index 97% rename from static/scripts/default-scripts.js rename to static/scripts/themes/default/default-scripts.js index 858985b..ff28045 100644 --- a/static/scripts/default-scripts.js +++ b/static/scripts/themes/default/default-scripts.js @@ -1,4 +1,4 @@ -import { isExternalLink } from "./is-external-link.js" +import { isExternalLink } from "../../is-external-link.js" // Utility function to ensure that the trailing slash is not considered when highlighting the menu item function removeTrailingSlash(str) { diff --git a/static/styles/clean-blog-styles.css b/static/styles/themes/clean-blog/clean-blog-styles.css similarity index 100% rename from static/styles/clean-blog-styles.css rename to static/styles/themes/clean-blog/clean-blog-styles.css diff --git a/static/styles/default-pagination.css b/static/styles/themes/default/default-pagination.css similarity index 100% rename from static/styles/default-pagination.css rename to static/styles/themes/default/default-pagination.css diff --git a/static/styles/default-single-post-preview.css b/static/styles/themes/default/default-single-post-preview.css similarity index 96% rename from static/styles/default-single-post-preview.css rename to static/styles/themes/default/default-single-post-preview.css index a90c9c0..7aad4c0 100644 --- a/static/styles/default-single-post-preview.css +++ b/static/styles/themes/default/default-single-post-preview.css @@ -74,7 +74,7 @@ } .blog-card .details .date:before { content: ""; - background: url("../icons/date-post-details.svg"); + background: url("../../../icons/date-post-details.svg"); position: absolute; width: 16px; height: 16px; @@ -84,7 +84,7 @@ } .blog-card .details .tags ul:before { content: ""; - background: url("../icons/tag-post-details.svg"); + background: url("../../../icons/tag-post-details.svg"); position: absolute; width: 16px; height: 16px; diff --git a/static/styles/default-styles.min.css b/static/styles/themes/default/default-styles.min.css similarity index 100% rename from static/styles/default-styles.min.css rename to static/styles/themes/default/default-styles.min.css diff --git a/views/posts/templates.md b/views/posts/templates.md index c4c4a76..c5b21a7 100644 --- a/views/posts/templates.md +++ b/views/posts/templates.md @@ -49,7 +49,7 @@ Now paste the following block of code: - +