feat: preload the reader from the detail CTA

The Continue / Read-first-chapter CTA is the highest-intent link to the
heaviest route in the app. An effect now programmatically preloadData()s the
target chapter as soon as the detail resolves, so the reader's load and first
page images are warm before the tap. Complements the reader's own
next-chapter warming.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-06 21:47:53 +02:00
parent 3622dcc02f
commit bd6ae86a85
5 changed files with 98 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
<script lang="ts">
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
import { goto, preloadData } from '$app/navigation';
import { fileUrl, ApiError } from '$lib/api/client';
import { createBookmark, deleteBookmark, type Bookmark } from '$lib/api/bookmarks';
import {
@@ -143,6 +143,15 @@
}
}
// Warm the reader (its load + first page images) for the highest-intent
// link on the page — tapping Continue / Read then feels instant. Re-runs
// only when the target chapter changes.
$effect(() => {
const href = ctaTarget?.href;
if (!browser || !href) return;
preloadData(href).catch(() => {});
});
// Tell the root layout to drop its top padding so the hero can sit
// at the viewport top under the page-specific app bar. Scoped to
// <html> so the rule survives sibling re-renders; cleaned up on