Skip to content

Commit 209b090

Browse files
authored
change linking behavior (#11)
https://github.com/user-attachments/assets/0ab1d2cf-d95e-43d3-80ba-2442717bbeb0 Signed-off-by: Andrew Duffy <andrew@a10y.dev>
1 parent 96a94f3 commit 209b090

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ const ICON_SUN = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18"
4040

4141
const ICON_MOON = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>`;
4242

43+
const ICON_EXTERNAL = `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 7h10v10"/><path d="M7 17 17 7"/></svg>`;
44+
4345
const TOGGLE_SCRIPT = `
4446
function toggleTheme() {
4547
const root = document.documentElement;
@@ -176,27 +178,27 @@ function rfcPage(rfc: RFC, repoUrl: string | null, liveReload: boolean = false):
176178

177179
// Accepted date
178180
if (rfc.git.accepted) {
179-
const acceptedLink = repoUrl
180-
? `<a href="${repoUrl}/commit/${rfc.git.accepted.hash}" class="commit-link">${formatDate(rfc.git.accepted.date)}</a>`
181-
: formatDate(rfc.git.accepted.date);
181+
const commitLink = repoUrl
182+
? ` <a href="${repoUrl}/commit/${rfc.git.accepted.hash}" class="commit-link" title="View commit">${ICON_EXTERNAL}</a>`
183+
: "";
182184

183185
gitHeader += `
184186
<div class="rfc-meta-item">
185187
<span class="rfc-meta-label">Accepted:</span>
186-
${acceptedLink}
188+
<span class="rfc-meta-value">${formatDate(rfc.git.accepted.date)}${commitLink}</span>
187189
</div>`;
188190
}
189191

190192
// Last updated date
191193
if (rfc.git.lastUpdated) {
192-
const updatedLink = repoUrl
193-
? `<a href="${repoUrl}/commit/${rfc.git.lastUpdated.hash}" class="commit-link">${formatDate(rfc.git.lastUpdated.date)}</a>`
194-
: formatDate(rfc.git.lastUpdated.date);
194+
const commitLink = repoUrl
195+
? ` <a href="${repoUrl}/commit/${rfc.git.lastUpdated.hash}" class="commit-link" title="View commit">${ICON_EXTERNAL}</a>`
196+
: "";
195197

196198
gitHeader += `
197199
<div class="rfc-meta-item">
198200
<span class="rfc-meta-label">Last updated:</span>
199-
${updatedLink}
201+
<span class="rfc-meta-value">${formatDate(rfc.git.lastUpdated.date)}${commitLink}</span>
200202
</div>`;
201203
}
202204

styles.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,29 @@ th {
342342
color: var(--fg-muted);
343343
}
344344

345+
.rfc-meta-value {
346+
display: inline-flex;
347+
align-items: center;
348+
gap: 0.375rem;
349+
}
350+
345351
.commit-link {
352+
display: inline-flex;
353+
align-items: center;
346354
color: var(--link);
347355
}
348356

349357
.commit-link:hover {
350358
color: var(--link-hover);
351-
text-decoration: underline;
359+
}
360+
361+
.commit-link svg {
362+
display: block;
363+
transition: stroke-width 0.1s ease;
364+
}
365+
366+
.commit-link:hover svg {
367+
stroke-width: 2.5;
352368
}
353369

354370
.rfc-author {

0 commit comments

Comments
 (0)