mirror of
https://github.com/TrezOne/congo-hindi-gujarati.git
synced 2026-07-19 09:03:02 -04:00
♻️ Move home switcher JS to external file
This commit is contained in:
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,27 @@
|
|||||||
|
function switchHomeLayout() {
|
||||||
|
const pageDiv = document.getElementById("page");
|
||||||
|
const profileDiv = document.getElementById("profile");
|
||||||
|
const layoutCode = document.querySelectorAll("code[id=layout]");
|
||||||
|
if (pageDiv.style.display === "none") {
|
||||||
|
pageDiv.style.display = "block";
|
||||||
|
profileDiv.style.display = "none";
|
||||||
|
layoutCode.forEach(function (el) {
|
||||||
|
el.innerText = "page";
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
pageDiv.style.display = "none";
|
||||||
|
profileDiv.style.display = "block";
|
||||||
|
layoutCode.forEach(function (el) {
|
||||||
|
el.innerText = "profile";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("DOMContentLoaded", (event) => {
|
||||||
|
document.querySelectorAll("#switch-layout-button").forEach((button) =>
|
||||||
|
button.addEventListener("click", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
switchHomeLayout();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -13,7 +13,7 @@ dateFormat = "2 January 2006"
|
|||||||
|
|
||||||
[author]
|
[author]
|
||||||
name = "Congo"
|
name = "Congo"
|
||||||
image = "author.jpg"
|
image = "img/author.jpg"
|
||||||
# headline = ""
|
# headline = ""
|
||||||
bio = "This is an example author bio, and although there's a stock photo of a dog here, this article was actually created by a human. :dog:"
|
bio = "This is an example author bio, and although there's a stock photo of a dog here, this article was actually created by a human. :dog:"
|
||||||
links = [
|
links = [
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ This is a demo site built entirely using Congo. It also contains a complete set
|
|||||||
<span class="flex items-center justify-between grow dark:text-neutral-300">
|
<span class="flex items-center justify-between grow dark:text-neutral-300">
|
||||||
<span class="prose dark:prose-invert">This is a demo of the <code id="layout">page</code> layout.</span>
|
<span class="prose dark:prose-invert">This is a demo of the <code id="layout">page</code> layout.</span>
|
||||||
<button
|
<button
|
||||||
|
id="switch-layout-button"
|
||||||
class="px-4 !text-neutral !no-underline rounded-md bg-primary-600 hover:!bg-primary-500 dark:bg-primary-800 dark:hover:!bg-primary-700"
|
class="px-4 !text-neutral !no-underline rounded-md bg-primary-600 hover:!bg-primary-500 dark:bg-primary-800 dark:hover:!bg-primary-700"
|
||||||
onclick="switchLayout()"
|
|
||||||
>
|
>
|
||||||
Switch layout ↻
|
Switch layout ↻
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,27 +1,8 @@
|
|||||||
|
{{ $jsHome := resources.Get "js/home.js" | resources.Minify | resources.Fingerprint "sha512" }}
|
||||||
<div id="page">
|
<div id="page">
|
||||||
{{ partial "partials/home/page.html" . }}
|
{{ partial "partials/home/page.html" . }}
|
||||||
</div>
|
</div>
|
||||||
<div id="profile" class="hidden h-full">
|
<div id="profile" class="hidden h-full">
|
||||||
{{ partial "partials/home/profile.html" . }}
|
{{ partial "partials/home/profile.html" . }}
|
||||||
</div>
|
</div>
|
||||||
|
<script defer type="text/javascript" src="{{ $jsHome.RelPermalink }}" integrity="{{ $jsHome.Data.Integrity }}"></script>
|
||||||
<script type="text/javascript">
|
|
||||||
function switchLayout() {
|
|
||||||
const pageDiv = document.getElementById("page");
|
|
||||||
const profileDiv = document.getElementById("profile");
|
|
||||||
const layoutCode = document.querySelectorAll("code[id=layout]");
|
|
||||||
if (pageDiv.style.display === "none") {
|
|
||||||
pageDiv.style.display = "block";
|
|
||||||
profileDiv.style.display = "none";
|
|
||||||
layoutCode.forEach(function (el) {
|
|
||||||
el.innerText = "page";
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
pageDiv.style.display = "none";
|
|
||||||
profileDiv.style.display = "block";
|
|
||||||
layoutCode.forEach(function (el) {
|
|
||||||
el.innerText = "profile";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user