Skip to content

Commit f96a47e

Browse files
authored
Merge pull request #44 from ethmarks/refactor-components
Refactor ethmarks-components
2 parents a811995 + 1a22cd2 commit f96a47e

4 files changed

Lines changed: 29 additions & 21 deletions

File tree

layouts/partials/ethmarks-components-js.html renamed to assets/js/ethmarks-components.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
{{- $header := partial "header.html" . | jsonify -}}
2-
{{- $footer := partial "footer.html" . | jsonify -}}
3-
{{- $js := printf `// Ethmarks Web Components
4-
// Generated automatically from Hugo partials
1+
// Ethmarks Web Components
52

63
class EthmarksHeader extends HTMLElement {
74
connectedCallback() {
8-
this.innerHTML = %s;
5+
this.innerHTML = `
6+
<header>
7+
<a href="https://ethmarks.github.io/" id="title" tabindex="0" aria-label="Home">Ethan Marks</a>
8+
<nav>
9+
<a id="nav-home" class="staggered" href="https://ethmarks.github.io/">Home</a>
10+
<a id="nav-about" class="staggered" href="https://ethmarks.github.io/about/">About</a>
11+
<a id="nav-posts" class="staggered" href="https://ethmarks.github.io/posts/">Posts</a>
12+
<a id="nav-blips" class="staggered" href="https://ethmarks.github.io/blips/">Blips</a>
13+
<a id="nav-projects" class="staggered" href="https://ethmarks.github.io/tags/projects/">Projects</a>
14+
</nav>
15+
</header>`;
916

1017
const activeLink = this.getAttribute('active');
1118
if (activeLink) {
12-
// Remove any existing active classes
13-
const navLinks = this.querySelectorAll('nav a');
14-
navLinks.forEach(link => link.classList.remove('active'));
15-
16-
// Add active class to the specified link by ID
1719
const targetLink = this.querySelector('#nav-' + activeLink.toLowerCase());
1820
if (targetLink) {
1921
targetLink.classList.add('active');
@@ -24,7 +26,16 @@
2426

2527
class EthmarksFooter extends HTMLElement {
2628
connectedCallback() {
27-
this.innerHTML = %s;
29+
this.innerHTML = `
30+
<footer>
31+
<span id="source">
32+
<a href="https://github.com/ethmarks/ethmarks.github.io" id="sourcelink" target="_blank">Website Source</a>
33+
</span>
34+
<span id="copyright"><a href="https://ethmarks.github.io/about/">Ethan Marks</a>, &copy;2025</span>
35+
<span id="email">
36+
<a href="mailto:ethmarks.dev@gmail.com" target="_blank">Contact</a>
37+
</span>
38+
</footer>`;
2839

2940
const sourceLink = this.getAttribute('source');
3041
if (sourceLink) {
@@ -64,6 +75,3 @@
6475
// Register the custom elements
6576
customElements.define('ethmarks-header', EthmarksHeader);
6677
customElements.define('ethmarks-footer', EthmarksFooter);
67-
` $header $footer -}}
68-
{{- $resource := resources.FromString "js/ethmarks-components.js" $js -}}
69-
{{- $resource.Publish -}}

layouts/partials/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<span id="source">
33
<a href="https://github.com/ethmarks/ethmarks.github.io" id="sourcelink" target="_blank">Website Source</a>
44
</span>
5-
<span id="copyright"><a href="{{ "/about/" | absURL }}">Ethan Marks</a>, &copy;2025</span>
5+
<span id="copyright"><a href="/about/">Ethan Marks</a>, &copy;2025</span>
66
<span id="email">
77
<a href="mailto:ethmarks.dev@gmail.com" target="_blank">Contact</a>
88
</span>

layouts/partials/header.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<header>
2-
<a href="{{ "/" | absURL }}" id="title" tabindex="0" aria-label="Home">Ethan Marks</a>
2+
<a href="/" id="title" tabindex="0" aria-label="Home">Ethan Marks</a>
33
<nav>
4-
<a id="nav-home" class="staggered{{ if .IsHome }} active{{ end }}" href="{{ "/" | absURL }}">Home</a>
5-
<a id="nav-about" class="staggered{{ if eq .Section "about" }} active{{ end }}" href="{{ "/about/" | absURL }}">About</a>
6-
<a id="nav-posts" class="staggered{{ if eq .Section "posts" }} active{{ end }}" href="{{ "/posts/" | absURL }}">Posts</a>
4+
<a id="nav-home" class="staggered{{ if .IsHome }} active{{ end }}" href="/">Home</a>
5+
<a id="nav-about" class="staggered{{ if eq .Section "about" }} active{{ end }}" href="/about/">About</a>
6+
<a id="nav-posts" class="staggered{{ if eq .Section "posts" }} active{{ end }}" href="/posts/">Posts</a>
77
<a id="nav-blips" class="staggered" href="https://ethmarks.github.io/blips/">Blips</a>
8-
<a id="nav-projects" class="staggered{{ if eq .RelPermalink "/tags/projects/" }} active{{ end }}" href="{{ "/tags/projects/" | absURL }}">Projects</a>
8+
<a id="nav-projects" class="staggered{{ if eq .RelPermalink "/tags/projects/" }} active{{ end }}" href="/tags/projects/">Projects</a>
99
</nav>
1010
</header>

layouts/partials/publish.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{{ partial "publish-media.html" . }}
22
{{ partial "publish-scss.html" . }}
3-
{{ partial "ethmarks-components-js.html" . }}
3+
{{ (resources.Get "js/ethmarks-components.js").Publish }}

0 commit comments

Comments
 (0)