diff --git a/package-lock.json b/package-lock.json
index 7462149c..445341db 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "coryd.dev",
- "version": "1.5.5",
+ "version": "1.5.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "coryd.dev",
- "version": "1.5.5",
+ "version": "1.5.6",
"license": "MIT",
"dependencies": {
"@cdransf/api-text": "^1.5.0",
diff --git a/package.json b/package.json
index 229db553..36ee7dfd 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "coryd.dev",
- "version": "1.5.5",
+ "version": "1.5.6",
"description": "The source for my personal site. Built using 11ty (and other tools).",
"type": "module",
"engines": {
diff --git a/src/assets/scripts/index.js b/src/assets/scripts/index.js
index bff8a111..c6762b47 100644
--- a/src/assets/scripts/index.js
+++ b/src/assets/scripts/index.js
@@ -1,260 +1,269 @@
-window.addEventListener('load', () => {
+window.addEventListener("load", () => {
// menu keyboard controls
- ;(() => {
- const menuInput = document.getElementById('menu-toggle')
- const menuButtonContainer = document.querySelector('.menu-button-container')
- const menuItems = document.querySelectorAll('.menu-primary li')
+ (() => {
+ const menuInput = document.getElementById("menu-toggle");
+ const menuButtonContainer = document.querySelector(
+ ".menu-button-container"
+ );
+ const menuItems = document.querySelectorAll(".menu-primary li");
- menuButtonContainer.addEventListener('keydown', (e) => {
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault()
- menuInput.checked = !menuInput.checked
+ menuButtonContainer.addEventListener("keydown", (e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ menuInput.checked = !menuInput.checked;
}
- })
+ });
menuItems.forEach((item) => {
- item.addEventListener('keydown', (e) => {
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault()
- item.querySelector('a').click()
+ item.addEventListener("keydown", (e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ item.querySelector("a").click();
}
- })
- })
+ });
+ });
- document.addEventListener('keydown', (e) => {
- if (e.key === 'Escape' && menuInput.checked) menuInput.checked = false
- })
- })()
+ document.addEventListener("keydown", (e) => {
+ if (e.key === "Escape" && menuInput.checked) menuInput.checked = false;
+ });
+ })();
// modal keyboard controls and scroll management
- ;(() => {
- const modalInputs = document.querySelectorAll('.modal-input')
- if (!modalInputs) return
+ (() => {
+ const modalInputs = document.querySelectorAll(".modal-input");
+ if (!modalInputs) return;
const toggleBodyScroll = (disableScroll) => {
if (disableScroll) {
- document.body.style.overflow = 'hidden'
+ document.body.style.overflow = "hidden";
} else {
- document.body.style.overflow = ''
+ document.body.style.overflow = "";
}
- }
+ };
const checkModals = () => {
- let isAnyModalOpen = false
+ let isAnyModalOpen = false;
modalInputs.forEach((modalInput) => {
- if (modalInput.checked) isAnyModalOpen = true
- })
- toggleBodyScroll(isAnyModalOpen)
- }
+ if (modalInput.checked) isAnyModalOpen = true;
+ });
+ toggleBodyScroll(isAnyModalOpen);
+ };
modalInputs.forEach((modalInput) => {
- modalInput.addEventListener('change', checkModals)
- })
+ modalInput.addEventListener("change", checkModals);
+ });
- document.addEventListener('keydown', (e) => {
- if (e.key === 'Escape') {
+ document.addEventListener("keydown", (e) => {
+ if (e.key === "Escape") {
modalInputs.forEach((modalInput) => {
- if (modalInput.checked) modalInput.checked = false
- })
- toggleBodyScroll(false)
+ if (modalInput.checked) modalInput.checked = false;
+ });
+ toggleBodyScroll(false);
}
- })
+ });
- checkModals()
- })()
+ checkModals();
+ })();
// text toggle for media pages
- ;(() => {
- const button = document.querySelector('[data-toggle-button]')
- const content = document.querySelector('[data-toggle-content]')
- const text = document.querySelectorAll('[data-toggle-content] p')
- const minHeight = 500 // this needs to match the height set on [data-toggle-content].text-toggle-hidden in text-toggle.css
- const interiorHeight = Array.from(text).reduce((acc, node) => acc + node.scrollHeight, 0)
+ (() => {
+ const button = document.querySelector("[data-toggle-button]");
+ const content = document.querySelector("[data-toggle-content]");
+ const text = document.querySelectorAll("[data-toggle-content] p");
+ const minHeight = 500; // this needs to match the height set on [data-toggle-content].text-toggle-hidden in text-toggle.css
+ const interiorHeight = Array.from(text).reduce(
+ (acc, node) => acc + node.scrollHeight,
+ 0
+ );
- if (!button || !content || !text) return
+ if (!button || !content || !text) return;
if (interiorHeight < minHeight) {
- content.classList.remove('text-toggle-hidden')
- button.style.display = 'none'
- return
+ content.classList.remove("text-toggle-hidden");
+ button.style.display = "none";
+ return;
}
- button.addEventListener('click', () => {
- const isHidden = content.classList.toggle('text-toggle-hidden')
- button.textContent = isHidden ? 'Show more' : 'Show less'
- })
- })()
+ button.addEventListener("click", () => {
+ const isHidden = content.classList.toggle("text-toggle-hidden");
+ button.textContent = isHidden ? "Show more" : "Show less";
+ });
+ })();
// search logic
- ;(() => {
- if (!MiniSearch || !document.querySelector('.search__form')) return
-
+ (() => {
+ if (!MiniSearch || !document.querySelector(".search__form--input")) return;
+
const miniSearch = new MiniSearch({
- fields: ['title', 'description', 'tags', 'type'],
- idField: 'id',
- storeFields: ['id', 'title', 'url', 'description', 'type', 'tags', 'total_plays'],
- searchOptions: {
- boost: { title: 2, tags: 1.5 },
- prefix: true,
- fuzzy: 0.3,
- },
- })
-
- const $form = document.querySelector('.search__form')
- const $input = document.querySelector('.search__form--input')
- const $typeCheckboxes = document.querySelectorAll('.search__form--type input[type="checkbox"]')
- const $results = document.querySelector('.search__results')
- const $loadMoreButton = document.querySelector('.search__load-more')
-
- const PAGE_SIZE = 10
- let currentPage = 1
- let currentResults = []
- let totalResults = 0
- let resultsById = {}
- let debounceTimeout
-
- const parseMarkdown = (markdown = '') =>
- markdown
- .replace(/\*\*(.*?)\*\*/g, '$1')
- .replace(/\*(.*?)\*/g, '$1')
+ fields: ["title", "description", "tags", "type"],
+ });
+ const $form = document.querySelector(".search__form");
+ const $input = document.querySelector(".search__form--input");
+ const $fallback = document.querySelector(".search__form--fallback");
+ const $typeCheckboxes = document.querySelectorAll(
+ '.search__form--type input[type="checkbox"]'
+ );
+ const $results = document.querySelector(".search__results");
+ const $loadMoreButton = document.querySelector(".search__load-more");
+
+ $form.removeAttribute("action");
+ $form.removeAttribute("method");
+ if ($fallback) $fallback.remove();
+
+ const PAGE_SIZE = 10;
+ let currentPage = 1;
+ let currentResults = [];
+ let total = 0;
+ let resultsById = {};
+ let debounceTimeout;
+
+ const parseMarkdown = (markdown) => {
+ if (!markdown) return "";
+ return markdown
+ .replace(/\*\*(.*?)\*\*/g, "$1")
+ .replace(/\*(.*?)\*/g, "$1")
.replace(/\[(.*?)\]\((.*?)\)/g, '$1')
- .replace(/\n/g, '
')
- .replace(/[#*_~`]/g, '')
-
+ .replace(/\n/g, "
")
+ .replace(/[#*_~`]/g, "");
+ };
+
const truncateDescription = (markdown, maxLength = 150) => {
- const htmlDescription = parseMarkdown(markdown)
- const tempDiv = document.createElement('div')
- tempDiv.innerHTML = htmlDescription
- const plainText = tempDiv.textContent || tempDiv.innerText || ''
- return plainText.length > maxLength ? `${plainText.substring(0, maxLength)}...` : plainText
- }
-
+ const htmlDescription = parseMarkdown(markdown);
+ const tempDiv = document.createElement("div");
+ tempDiv.innerHTML = htmlDescription;
+ const plainText = tempDiv.textContent || tempDiv.innerText || "";
+ return plainText.length > maxLength
+ ? `${plainText.substring(0, maxLength)}...`
+ : plainText;
+ };
+
const formatArtistTitle = (title, totalPlays) =>
- totalPlays > 0 ? `${title} ${totalPlays} plays` : title
-
- const updateLoadMoreButton = () => {
- const moreResultsToShow = currentPage * PAGE_SIZE < totalResults
- $loadMoreButton.style.display = moreResultsToShow ? 'block' : 'none'
- }
-
- const renderSearchResults = results => {
- const resultHTML = results.map(({ title, url, description, type, total_plays }) => {
- const truncatedDesc = truncateDescription(description)
- const formattedTitle = type === 'artist' && total_plays !== undefined
- ? formatArtistTitle(title, total_plays)
- : title
-
- return `
-
${truncatedDesc}
-${truncatedDesc}
-${truncatedDesc}
+${truncatedDesc}
+