-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move themes static files to respective directories
- Loading branch information
Showing
16 changed files
with
65 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
` <i class="fa-solid fa-arrow-up-right-from-square" title="External link"></i>` | ||
) | ||
} | ||
}) | ||
}) |
2 changes: 1 addition & 1 deletion
2
static/scripts/default-scripts.js → ...scripts/themes/default/default-scripts.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters