Keep the home title cursor on its last line

This commit is contained in:
2026-11-28 15:04:47 +08:00
parent 086b7509fe
commit 8a8f6ca0f3
4 changed files with 66 additions and 1 deletions
+3 -1
View File
@@ -3,11 +3,13 @@
const homeHero = document.querySelector('#main-content > .hero-home');
const homeTitle = homeHero?.querySelector('.hero-copy h1');
if (homeTitle) {
const lastLine = homeTitle.querySelector('.hero-accent') || homeTitle.querySelector('.hero-heading-primary') || homeTitle;
const cursor = document.createElement('span');
cursor.className = 'home-cursor';
cursor.setAttribute('aria-hidden', 'true');
cursor.textContent = '_';
homeTitle.append(cursor);
// A word joiner prevents a narrow line from wrapping just the cursor.
lastLine.append('\u2060', cursor);
}
const homeImage = homeHero?.querySelector('.hero-visual > img');