UI enhancements: homepage de-duplication, copy code button, article links on projects, reading time
This commit is contained in:
parent
009655794d
commit
bf8b466229
6 changed files with 192 additions and 85 deletions
|
|
@ -220,6 +220,31 @@ img {
|
|||
}
|
||||
|
||||
/* --- Section Headings --- */
|
||||
.section-title-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin: 3rem 0 1.5rem;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.section-title-bar .section-heading {
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.section-link {
|
||||
font-size: 0.85rem;
|
||||
color: var(--accent-dim);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
transition: color var(--transition);
|
||||
}
|
||||
|
||||
.section-link:hover {
|
||||
color: var(--fg-bright);
|
||||
}
|
||||
|
||||
.section-heading {
|
||||
font-size: 1.2rem;
|
||||
color: var(--accent);
|
||||
|
|
@ -585,6 +610,38 @@ pre code {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
.copy-code-btn {
|
||||
position: absolute;
|
||||
top: 0.5rem;
|
||||
right: 0.5rem;
|
||||
padding: 0.2rem 0.55rem;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.72rem;
|
||||
color: var(--fg-dim);
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
transition: opacity var(--transition), color var(--transition), border-color var(--transition), background-color var(--transition);
|
||||
z-index: 2;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
pre:hover .copy-code-btn {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.copy-code-btn:hover {
|
||||
color: var(--fg-bright);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.copy-code-btn.copied {
|
||||
color: #50fa7b;
|
||||
border-color: #50fa7b;
|
||||
}
|
||||
|
||||
/* --- Tables --- */
|
||||
table {
|
||||
width: 100%;
|
||||
|
|
@ -716,26 +773,70 @@ th {
|
|||
background: var(--bg-alt);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
transition: border-color var(--transition), background-color var(--transition), transform var(--transition);
|
||||
transition: border-color var(--transition), background-color var(--transition);
|
||||
color: var(--fg);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.project-card:hover {
|
||||
border-color: var(--accent);
|
||||
border-color: var(--accent-dim);
|
||||
background: var(--bg-hover);
|
||||
transform: translateX(4px);
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
.project-card-inner {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.project-card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
margin-bottom: 0.35rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.project-card-name {
|
||||
font-size: 1rem;
|
||||
color: var(--fg-bright);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.project-card-name a {
|
||||
color: var(--accent);
|
||||
margin: 0 0 0.3rem;
|
||||
text-decoration: none;
|
||||
transition: color var(--transition);
|
||||
}
|
||||
|
||||
.project-card-name a:hover {
|
||||
color: var(--fg-bright);
|
||||
}
|
||||
|
||||
.project-arrow {
|
||||
display: inline-block;
|
||||
font-size: 0.85rem;
|
||||
transition: transform var(--transition);
|
||||
}
|
||||
|
||||
.project-card-name a:hover .project-arrow {
|
||||
transform: translate(2px, -2px);
|
||||
}
|
||||
|
||||
.project-article-link {
|
||||
font-size: 0.72rem;
|
||||
color: var(--accent);
|
||||
background: var(--accent-glow);
|
||||
border: 1px solid var(--accent-dim);
|
||||
padding: 0.15rem 0.5rem;
|
||||
border-radius: 3px;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
transition: background-color var(--transition), color var(--transition), border-color var(--transition);
|
||||
}
|
||||
|
||||
.project-article-link:hover {
|
||||
background: var(--accent);
|
||||
color: var(--bg);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.project-card-desc {
|
||||
|
|
@ -761,18 +862,6 @@ th {
|
|||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.project-card-arrow {
|
||||
color: var(--fg-dim);
|
||||
font-size: 1.2rem;
|
||||
margin-left: 1rem;
|
||||
transition: color var(--transition), transform var(--transition);
|
||||
}
|
||||
|
||||
.project-card:hover .project-card-arrow {
|
||||
color: var(--accent);
|
||||
transform: translateX(3px);
|
||||
}
|
||||
|
||||
/* --- Resume Page --- */
|
||||
.resume-page {
|
||||
max-width: 100%;
|
||||
|
|
|
|||
|
|
@ -58,18 +58,21 @@ title = "Divyam Ahuja"
|
|||
[[params.projects]]
|
||||
name = "Homelab"
|
||||
url = "#"
|
||||
article = "/posts/debugging-k8s-disk-pressure-homelab/"
|
||||
description = "Self-hosted high-availability infrastructure on Raspberry Pi 5"
|
||||
tags = ["Kubernetes", "WireGuard", "Rancher", "MetalLB"]
|
||||
|
||||
[[params.projects]]
|
||||
name = "chip_eight.js"
|
||||
url = "https://github.com/ahujadivyam/chip_eight.js"
|
||||
article = "/posts/i-built-a-chip8-emulator-in-javascript/"
|
||||
description = "A browser-based CHIP-8 virtual machine and interpreter written in vanilla JavaScript"
|
||||
tags = ["JavaScript", "Emulators", "Canvas", "WebAudio"]
|
||||
|
||||
[[params.projects]]
|
||||
name = "snake_wasm"
|
||||
url = "https://github.com/ahujadivyam/snake_wasm"
|
||||
article = "/posts/snake-game-in-cpp-and-webassembly/"
|
||||
description = "Classic Snake game in C++ using olcPixelGameEngine, compiled to WebAssembly via Emscripten"
|
||||
tags = ["C++", "WebAssembly", "Emscripten", "GameDev"]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,5 +11,33 @@
|
|||
</main>
|
||||
</div>
|
||||
{{- partial "footer.html" . -}}
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('pre').forEach(pre => {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'copy-code-btn';
|
||||
btn.type = 'button';
|
||||
btn.setAttribute('aria-label', 'Copy code to clipboard');
|
||||
btn.innerText = 'copy';
|
||||
btn.addEventListener('click', async () => {
|
||||
const codeEl = pre.querySelector('code');
|
||||
const text = codeEl ? codeEl.innerText : pre.innerText;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
btn.innerText = 'copied!';
|
||||
btn.classList.add('copied');
|
||||
setTimeout(() => {
|
||||
btn.innerText = 'copy';
|
||||
btn.classList.remove('copied');
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
btn.innerText = 'failed';
|
||||
}
|
||||
});
|
||||
pre.appendChild(btn);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
{{ define "main" }}
|
||||
<h1 class="page-title">Projects</h1>
|
||||
<p class="projects-intro">Things I've built or contributed to.</p>
|
||||
<p class="projects-intro">Things I've built, contributed to, or run in production.</p>
|
||||
|
||||
<div class="projects-grid">
|
||||
{{- range .Site.Params.projects }}
|
||||
{{- if eq .url "#" }}
|
||||
<div class="project-card">
|
||||
<div class="project-card-inner">
|
||||
<h3 class="project-card-name">{{ .name }}</h3>
|
||||
<div class="project-card-header">
|
||||
<h3 class="project-card-name">
|
||||
{{- if eq .url "#" -}}
|
||||
{{ .name }}
|
||||
{{- else -}}
|
||||
<a href="{{ .url }}" target="_blank" rel="noopener noreferrer">{{ .name }} <span class="project-arrow">↗</span></a>
|
||||
{{- end -}}
|
||||
</h3>
|
||||
{{- with .article }}
|
||||
<a href="{{ . }}" class="project-article-link">writeup ↗</a>
|
||||
{{- end }}
|
||||
</div>
|
||||
<p class="project-card-desc">{{ .description }}</p>
|
||||
{{- with .tags }}
|
||||
<div class="project-card-tags">
|
||||
|
|
@ -18,22 +28,6 @@
|
|||
{{- end }}
|
||||
</div>
|
||||
</div>
|
||||
{{- else }}
|
||||
<a href="{{ .url }}" class="project-card" target="_blank" rel="noopener noreferrer">
|
||||
<div class="project-card-inner">
|
||||
<h3 class="project-card-name">{{ .name }}</h3>
|
||||
<p class="project-card-desc">{{ .description }}</p>
|
||||
{{- with .tags }}
|
||||
<div class="project-card-tags">
|
||||
{{- range . }}
|
||||
<span class="project-card-tag">{{ . }}</span>
|
||||
{{- end }}
|
||||
</div>
|
||||
{{- end }}
|
||||
</div>
|
||||
<span class="project-card-arrow">→</span>
|
||||
</a>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
<span>{{ .Site.Params.author | upper }}</span>
|
||||
<span class="separator">·</span>
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "02 Jan 2006" }}</time>
|
||||
<span class="separator">·</span>
|
||||
<span class="reading-time">{{ .ReadingTime }} min read</span>
|
||||
{{- with .Params.tags }}
|
||||
<span class="separator">|</span>
|
||||
<span class="post-tags">
|
||||
|
|
|
|||
|
|
@ -13,16 +13,15 @@
|
|||
{{- $posts := where .Site.RegularPages "Section" "posts" -}}
|
||||
{{- if $posts }}
|
||||
<section>
|
||||
<h2 class="section-heading">Blog</h2>
|
||||
{{- $byYear := $posts.GroupByDate "2006" -}}
|
||||
{{- range $byYear }}
|
||||
<div class="archive-year">
|
||||
<h3 class="year-heading">{{ .Key }}</h3>
|
||||
<div class="section-title-bar">
|
||||
<h2 class="section-heading">Recent Writing</h2>
|
||||
<a href="/posts/" class="section-link">All posts →</a>
|
||||
</div>
|
||||
<ul class="post-list">
|
||||
{{- range .Pages }}
|
||||
{{- range first 4 $posts }}
|
||||
<li class="post-list-item">
|
||||
<time class="post-date" datetime="{{ .Date.Format "2006-01-02" }}">
|
||||
{{ .Date.Format "02 Jan" }}
|
||||
{{ .Date.Format "02 Jan 2006" }}
|
||||
</time>
|
||||
<div class="post-list-info">
|
||||
<a href="{{ .Permalink }}" class="post-title-link">{{ .Title }}</a>
|
||||
|
|
@ -37,20 +36,31 @@
|
|||
</li>
|
||||
{{- end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{- end }}
|
||||
</section>
|
||||
{{- end }}
|
||||
|
||||
{{- if .Site.Params.projects }}
|
||||
<section>
|
||||
<h2 class="section-heading">Projects</h2>
|
||||
<div class="section-title-bar">
|
||||
<h2 class="section-heading">Featured Projects</h2>
|
||||
<a href="/projects/" class="section-link">All projects →</a>
|
||||
</div>
|
||||
<div class="projects-grid">
|
||||
{{- range .Site.Params.projects }}
|
||||
{{- if eq .url "#" }}
|
||||
{{- range first 4 .Site.Params.projects }}
|
||||
<div class="project-card">
|
||||
<div class="project-card-inner">
|
||||
<h3 class="project-card-name">{{ .name }}</h3>
|
||||
<div class="project-card-header">
|
||||
<h3 class="project-card-name">
|
||||
{{- if eq .url "#" -}}
|
||||
{{ .name }}
|
||||
{{- else -}}
|
||||
<a href="{{ .url }}" target="_blank" rel="noopener noreferrer">{{ .name }} <span class="project-arrow">↗</span></a>
|
||||
{{- end -}}
|
||||
</h3>
|
||||
{{- with .article }}
|
||||
<a href="{{ . }}" class="project-article-link">writeup ↗</a>
|
||||
{{- end }}
|
||||
</div>
|
||||
<p class="project-card-desc">{{ .description }}</p>
|
||||
{{- with .tags }}
|
||||
<div class="project-card-tags">
|
||||
|
|
@ -61,27 +71,8 @@
|
|||
{{- end }}
|
||||
</div>
|
||||
</div>
|
||||
{{- else }}
|
||||
<a href="{{ .url }}" class="project-card" target="_blank" rel="noopener noreferrer">
|
||||
<div class="project-card-inner">
|
||||
<h3 class="project-card-name">{{ .name }}</h3>
|
||||
<p class="project-card-desc">{{ .description }}</p>
|
||||
{{- with .tags }}
|
||||
<div class="project-card-tags">
|
||||
{{- range . }}
|
||||
<span class="project-card-tag">{{ . }}</span>
|
||||
{{- end }}
|
||||
</div>
|
||||
{{- end }}
|
||||
</div>
|
||||
<span class="project-card-arrow">→</span>
|
||||
</a>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</div>
|
||||
<div style="margin-top: 1rem; text-align: right;">
|
||||
<a href="/projects/" class="post-title-link">View all projects →</a>
|
||||
</div>
|
||||
</section>
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue