docs(releases): the route serves the releases the docs document

It answered with the whole v3 and v4 history and the page threw two thirds
of it away, so the filter moves to where the list is built.
This commit is contained in:
Benjamin Canac
2026-09-09 18:42:39 +02:00
parent e4995b2a93
commit d8a1988f8d
4 changed files with 10 additions and 6 deletions
-3
View File
@@ -8,9 +8,6 @@ export interface Release {
url: string
}
/** The stable v4 line: this site documents v4, and v4.0.0 supersedes its alphas and betas. */
export const DOCUMENTED = /^v4\.\d+\.\d+$/
/** The versions, loaded by the `releases` middleware so the docs aside has them at render. */
export const useReleases = () => useState<Release[]>('releases', () => [])
+3 -1
View File
@@ -6,7 +6,9 @@ export default defineNuxtRouteMiddleware(async (to) => {
const releases = useReleases()
if (!releases.value.length) {
try {
releases.value = (await $fetch('/api/github/releases.json')).filter(release => DOCUMENTED.test(release.tag))
// typed explicitly: assigning the route's inferred type straight to the
// state ref sends TypeScript down its route table
releases.value = await $fetch<Release[]>('/api/github/releases.json')
} catch (error) {
// GitHub can be unreachable: the page renders an empty state rather than
// failing every navigation and the prerender crawl with it
+4 -2
View File
@@ -1,6 +1,8 @@
/** The releases, newest first. The notes are served per release by releases/[tag]. */
/** The releases the docs document, newest first. The notes are served per release by releases/[tag]. */
export default defineCachedEventHandler(async () => {
return (await fetchReleases()).map(({ markdown, ...release }) => release)
return (await fetchReleases())
.filter(release => DOCUMENTED.test(release.tag))
.map(({ markdown, ...release }) => release)
}, {
maxAge: 60 * 60,
// the response carries `cache-control` and an etag, which the changelog on
+3
View File
@@ -15,6 +15,9 @@ interface UnghRelease {
markdown: string
}
/** The stable v4 line: this site documents v4, and v4.0.0 supersedes its alphas and betas. */
export const DOCUMENTED = /^v4\.\d+\.\d+$/
/**
* The releases of nuxt/ui through ungh, newest first, v2 left out. Cached
* for an hour and shared by the list and the per-release routes, so ungh is