Skip to content

Commit e15ede4

Browse files
feat: add a reload button
1 parent 391a327 commit e15ede4

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

server/plugins/fallback-ui.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export default defineNitroPlugin(nitroApp => {
2+
nitroApp.hooks.hook('render:html', (html, { event }) => {
3+
if (event.path === '/spa.prerender-fallback.html') {
4+
html.head.push(`
5+
<noscript>
6+
<style>
7+
.noscript-container {
8+
display: flex; flex-direction: column; align-items: center;
9+
justify-content: center; height: 100vh; font-family: sans-serif;
10+
background: #0a0a0a; color: white; text-align: center;
11+
}
12+
.refresh-button {
13+
margin-top: 20px; padding: 12px 24px; background: #444;
14+
color: white; text-decoration: none; border-radius: 6px;
15+
border: 1px solid #666; cursor: pointer;
16+
}
17+
.refresh-button:hover { background: #555; }
18+
</style>
19+
</noscript>
20+
`)
21+
22+
html.bodyAppend.push(`
23+
<noscript>
24+
<div class="noscript-container">
25+
<h2>Generating Page...</h2>
26+
<p>This page hasn't been cached yet. Click below to view the content.</p>
27+
<a href="." class="refresh-button">Check for Content</a>
28+
</div>
29+
</noscript>
30+
`)
31+
}
32+
})
33+
})

0 commit comments

Comments
 (0)