mirror of
https://github.com/nuxt/ui.git
synced 2026-09-14 19:51:10 +08:00
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:
@@ -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', () => [])
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user