mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
docs: add releases page (#1004)
This commit is contained in:
23
docs/server/api/pulls.json.get.ts
Normal file
23
docs/server/api/pulls.json.get.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Octokit } from '@octokit/rest'
|
||||
|
||||
function isUserABot (user) {
|
||||
return user?.login?.endsWith('-bot') || user?.login?.endsWith('[bot]')
|
||||
}
|
||||
|
||||
export default cachedEventHandler(async () => {
|
||||
if (!process.env.NUXT_GITHUB_TOKEN) {
|
||||
return []
|
||||
}
|
||||
|
||||
const octokit = new Octokit({ auth: process.env.NUXT_GITHUB_TOKEN })
|
||||
|
||||
const pulls = await octokit.paginate(octokit.rest.pulls.list, {
|
||||
owner: 'nuxt',
|
||||
repo: 'ui',
|
||||
state: 'closed'
|
||||
})
|
||||
|
||||
return pulls.filter(pull => !!pull.merged_at).filter(pull => !isUserABot(pull.user))
|
||||
}, {
|
||||
maxAge: 60 * 60
|
||||
})
|
||||
18
docs/server/api/releases.json.get.ts
Normal file
18
docs/server/api/releases.json.get.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Octokit } from '@octokit/rest'
|
||||
|
||||
export default cachedEventHandler(async () => {
|
||||
if (!process.env.NUXT_GITHUB_TOKEN) {
|
||||
return []
|
||||
}
|
||||
|
||||
const octokit = new Octokit({ auth: process.env.NUXT_GITHUB_TOKEN })
|
||||
|
||||
const { data: releases } = await octokit.rest.repos.listReleases({
|
||||
owner: 'nuxt',
|
||||
repo: 'ui'
|
||||
})
|
||||
|
||||
return releases
|
||||
}, {
|
||||
maxAge: 60 * 60
|
||||
})
|
||||
Reference in New Issue
Block a user