fix/docs: release tags don't work for newly-created/updated icons (#1589)

As per 3391b5b717, the format of new GitHub release tags is just the version number without the `v` prefix. As we can see on https://github.com/lucide-icons/lucide/releases?page=2, versions older than 0.266.0 use a `v` prefix. The current docs assume that all versions contain the `v` prefix; this PR fixes it so that the format of versions both from before and after this change are accounted for.
This commit is contained in:
Emma Alexia
2023-10-17 21:30:26 +02:00
committed by GitHub
parent dbfce919fc
commit 1dce6a141a
5 changed files with 35 additions and 4 deletions
@@ -10,7 +10,7 @@ import { data } from './HomeHeroBefore.data'
:href="`https://github.com/lucide-icons/lucide/releases/tag/${data.version}`"
target="_blank"
rel="noreferrer noopener"
>{{ data.version }}</Badge>
>v{{ data.version }}</Badge>
</HomeContainer>
</template>
@@ -10,6 +10,7 @@ import { useRouter } from 'vitepress';
import IconInfo from './IconInfo.vue';
import Badge from '../base/Badge.vue';
import { computedAsync } from '@vueuse/core';
import { satisfies } from 'semver';
const props = defineProps<{
iconName: string
@@ -25,6 +26,12 @@ const icon = computedAsync<IconEntity | null>(async () => {
const emit = defineEmits(['close'])
const isOpen = computed(() => !!icon.value)
function releaseTagLink(version) {
const shouldAddV = satisfies(version, `<0.266.0`)
return `https://github.com/lucide-icons/lucide/releases/tag/${shouldAddV ? 'v' : ''}${version}`
}
function onClose() {
emit('close')
}
@@ -43,7 +50,7 @@ const Expand = createLucideIcon('Expand', expand)
<Badge
v-if="icon.createdRelease"
class="version"
:href="`https://github.com/lucide-icons/lucide/releases/tag/v${icon.createdRelease.version}`"
:href="releaseTagLink(icon.createdRelease.version)"
target="_blank"
rel="noreferrer noopener"
>v{{ icon.createdRelease.version }}</Badge>
+9 -2
View File
@@ -21,6 +21,7 @@ import Label from '../.vitepress/theme/components/base/Label.vue'
import VPButton from 'vitepress/dist/client/theme-default/components/VPButton.vue';
import { data } from './codeExamples.data'
import { camelCase, startCase } from 'lodash-es'
import { satisfies } from 'semver'
const { params } = useData()
@@ -35,6 +36,12 @@ const codeExample = computed(() => data.codeExamples?.map(
}
).join('') ?? []
)
function releaseTagLink(version) {
const shouldAddV = satisfies(version, `<0.266.0`)
return `https://github.com/lucide-icons/lucide/releases/tag/${shouldAddV ? 'v' : ''}${version}`
}
</script>
<div :class="$style.layout">
@@ -61,7 +68,7 @@ const codeExample = computed(() => data.codeExamples?.map(
>
<Label>Created:</Label>
<Badge
:href="`https://github.com/lucide-icons/lucide/releases/tag/v${params.createdRelease.version}`"
:href="releaseTagLink(params.createdRelease.version)"
target="_blank"
rel="noreferrer noopener"
>
@@ -74,7 +81,7 @@ const codeExample = computed(() => data.codeExamples?.map(
>
<Label>Last changed:</Label>
<Badge
:href="`https://github.com/lucide-icons/lucide/releases/tag/v${params.changedRelease.version}`"
:href="releaseTagLink(params.changedRelease.version)"
target="_blank"
rel="noreferrer noopener"
>
+1
View File
@@ -25,6 +25,7 @@
"license": "ISC",
"devDependencies": {
"@rollup/plugin-replace": "^5.0.2",
"@types/semver": "^7.5.3",
"h3": "^1.8.0",
"nitropack": "npm:nitropack-edge@latest",
"node-fetch": "2",