feat: format
This commit is contained in:
parent
9effc1cab9
commit
24685b693c
1 changed files with 8 additions and 12 deletions
|
|
@ -7,15 +7,11 @@ class SiteHeader extends HTMLElement {
|
||||||
const path = window.location.pathname;
|
const path = window.location.pathname;
|
||||||
const isHome = path === "/" || path === "/index.html";
|
const isHome = path === "/" || path === "/index.html";
|
||||||
const topic = this.getTopic();
|
const topic = this.getTopic();
|
||||||
|
|
||||||
const promptText = isHome
|
const promptText = isHome ? "barrett@ruth:~$" : `barrett@ruth:~$ ${topic}`;
|
||||||
? "barrett@ruth:~$"
|
|
||||||
: `barrett@ruth:~$ ${topic}`;
|
const clickHandler = isHome ? "refresh(event)" : "goHome(event)";
|
||||||
|
|
||||||
const clickHandler = isHome
|
|
||||||
? "refresh(event)"
|
|
||||||
: "goHome(event)";
|
|
||||||
|
|
||||||
this.innerHTML = `
|
this.innerHTML = `
|
||||||
<header>
|
<header>
|
||||||
<a href="/" style="text-decoration: none; color: inherit" onclick="${clickHandler}">
|
<a href="/" style="text-decoration: none; color: inherit" onclick="${clickHandler}">
|
||||||
|
|
@ -32,7 +28,7 @@ class SiteHeader extends HTMLElement {
|
||||||
</header>
|
</header>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTopic() {
|
getTopic() {
|
||||||
const pathname = window.location.pathname.split("/");
|
const pathname = window.location.pathname.split("/");
|
||||||
if (pathname.includes("about.html")) {
|
if (pathname.includes("about.html")) {
|
||||||
|
|
@ -61,8 +57,8 @@ class SiteFooter extends HTMLElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the custom elements
|
// Register the custom elements
|
||||||
customElements.define('site-header', SiteHeader);
|
customElements.define("site-header", SiteHeader);
|
||||||
customElements.define('site-footer', SiteFooter);
|
customElements.define("site-footer", SiteFooter);
|
||||||
|
|
||||||
// Add styles once when DOM is loaded
|
// Add styles once when DOM is loaded
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue