🐛 fix content loading for comic nav
This commit is contained in:
4
app.py
4
app.py
@@ -131,7 +131,9 @@ def comic(comic_id):
|
|||||||
comic = get_comic_by_number(comic_id)
|
comic = get_comic_by_number(comic_id)
|
||||||
if not comic:
|
if not comic:
|
||||||
abort(404)
|
abort(404)
|
||||||
return render_template('comic.html', title=f"Comic #{comic_id}",
|
# Use comic title if present, otherwise use #X format (matching client-side behavior)
|
||||||
|
page_title = comic.get('title', f"#{comic_id}")
|
||||||
|
return render_template('comic.html', title=page_title,
|
||||||
comic=comic, total_comics=len(COMICS))
|
comic=comic, total_comics=len(COMICS))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show/hide header based on plain mode
|
// Show/hide header based on plain mode
|
||||||
const header = document.querySelector('.comic-header');
|
let header = document.querySelector('.comic-header');
|
||||||
if (comic.plain) {
|
if (comic.plain) {
|
||||||
if (header) {
|
if (header) {
|
||||||
header.style.display = 'none';
|
header.style.display = 'none';
|
||||||
@@ -60,10 +60,11 @@
|
|||||||
newHeader.className = 'comic-header';
|
newHeader.className = 'comic-header';
|
||||||
newHeader.innerHTML = '<h1></h1><p class="comic-date"></p>';
|
newHeader.innerHTML = '<h1></h1><p class="comic-date"></p>';
|
||||||
container.insertBefore(newHeader, container.firstChild);
|
container.insertBefore(newHeader, container.firstChild);
|
||||||
|
header = newHeader; // Update reference to the newly created element
|
||||||
}
|
}
|
||||||
// Update title and date
|
// Update title and date using the header reference
|
||||||
document.querySelector('.comic-header h1').textContent = title;
|
header.querySelector('h1').textContent = title;
|
||||||
document.querySelector('.comic-date').textContent = comic.date;
|
header.querySelector('.comic-date').textContent = comic.date;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update image and its link
|
// Update image and its link
|
||||||
@@ -74,7 +75,7 @@
|
|||||||
updateComicImageLink(comic.number);
|
updateComicImageLink(comic.number);
|
||||||
|
|
||||||
// Update author note
|
// Update author note
|
||||||
const transcriptDiv = document.querySelector('.comic-transcript');
|
let transcriptDiv = document.querySelector('.comic-transcript');
|
||||||
if (comic.author_note) {
|
if (comic.author_note) {
|
||||||
if (!transcriptDiv) {
|
if (!transcriptDiv) {
|
||||||
const container = document.querySelector('.comic-container');
|
const container = document.querySelector('.comic-container');
|
||||||
@@ -82,6 +83,7 @@
|
|||||||
newDiv.className = 'comic-transcript';
|
newDiv.className = 'comic-transcript';
|
||||||
newDiv.innerHTML = '<h3>Author Note</h3>';
|
newDiv.innerHTML = '<h3>Author Note</h3>';
|
||||||
container.appendChild(newDiv);
|
container.appendChild(newDiv);
|
||||||
|
transcriptDiv = newDiv; // Update reference to the newly created element
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear existing content after the h3
|
// Clear existing content after the h3
|
||||||
|
|||||||
Reference in New Issue
Block a user