Skip to content
Snippets Groups Projects
Commit 15cff5b6 authored by David Schwarzmann's avatar David Schwarzmann
Browse files

docs: Render latest version on next branch

parent 6f95dc1c
No related branches found
No related tags found
No related merge requests found
import axios from "axios";
import semver from "semver";
export default async function({ siteVersion, projectId }) {
return axios.get(`https://git.fitko.de/api/v4/projects/${projectId}/repository/tags`)
.catch((error) => {
throw `Fetching of latest tags failed with ${error.response.status}`
})
.then(async ({ data }) => {
if (siteVersion === 'next') {
return data[0].name
} else {
export default async function ({siteVersion, projectId}) {
if (siteVersion === 'next') {
return 'latest'
} else {
return axios.get(`https://git.fitko.de/api/v4/projects/${projectId}/repository/tags`)
.catch((error) => {
throw `Fetching of latest tags failed with ${error.response.status}`
})
.then(async ({data}) => {
const versionRange = `~${siteVersion}`
const suitableVersions = await data
.filter(({ name }) => semver.satisfies(name, versionRange))
.map(({ name }) => name)
.filter(({name}) => semver.satisfies(name, versionRange))
.map(({name}) => name)
.sort()
return semver.maxSatisfying(suitableVersions, versionRange)
}
})
})
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment