Update page title, URL and meta when navigating between lightbox slides
goToSlide() now calls history.replaceState + updates document.title, description, og:title/description/url and canonical on each slide change. replaceState is used so swipe/keyboard navigation doesn't pollute history. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+14
-1
@@ -297,9 +297,22 @@
|
||||
if (lbIndex) {
|
||||
lbIndex.innerHTML = `<b>${String(lbIdx + 1).padStart(3,'0')}</b> / ${lbList.length}`;
|
||||
}
|
||||
lbBuildMeta(lbList[lbIdx]);
|
||||
const p = lbList[lbIdx];
|
||||
lbBuildMeta(p);
|
||||
syncThumbs();
|
||||
preloadNeighbors(lbIdx);
|
||||
if (p && smooth) {
|
||||
const postTitle = p.title + ' — Roux';
|
||||
const postUrl = new URL(p.url, location.origin).href;
|
||||
document.title = postTitle;
|
||||
history.replaceState({ slug: p.slug }, '', p.url);
|
||||
setMeta('name', 'description', p.description || null);
|
||||
setMeta('property', 'og:title', postTitle);
|
||||
setMeta('property', 'og:description', p.description || null);
|
||||
setMeta('property', 'og:url', postUrl);
|
||||
const canon = document.querySelector('link[rel="canonical"]');
|
||||
if (canon) canon.href = postUrl;
|
||||
}
|
||||
}
|
||||
|
||||
function preloadNeighbors(idx) {
|
||||
|
||||
Reference in New Issue
Block a user