From 1dce6a141a4e8a1e95cd38e39f7b35041437ad35 Mon Sep 17 00:00:00 2001 From: Emma Alexia Date: Tue, 17 Oct 2023 15:30:26 -0400 Subject: [PATCH] fix/docs: release tags don't work for newly-created/updated icons (#1589) As per 3391b5b717a23312fe3ebc45ec2c40e66aa185a4, 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. --- .../theme/components/home/HomeHeroBefore.vue | 2 +- .../theme/components/icons/IconDetailOverlay.vue | 9 ++++++++- docs/icons/[name].md | 11 +++++++++-- docs/package.json | 1 + pnpm-lock.yaml | 16 ++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/docs/.vitepress/theme/components/home/HomeHeroBefore.vue b/docs/.vitepress/theme/components/home/HomeHeroBefore.vue index 52d078f25..9754ad365 100644 --- a/docs/.vitepress/theme/components/home/HomeHeroBefore.vue +++ b/docs/.vitepress/theme/components/home/HomeHeroBefore.vue @@ -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 }} + >v{{ data.version }} diff --git a/docs/.vitepress/theme/components/icons/IconDetailOverlay.vue b/docs/.vitepress/theme/components/icons/IconDetailOverlay.vue index df4cb772f..3e5ff0018 100644 --- a/docs/.vitepress/theme/components/icons/IconDetailOverlay.vue +++ b/docs/.vitepress/theme/components/icons/IconDetailOverlay.vue @@ -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(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) v{{ icon.createdRelease.version }} diff --git a/docs/icons/[name].md b/docs/icons/[name].md index 1400d83e2..69d1925f2 100644 --- a/docs/icons/[name].md +++ b/docs/icons/[name].md @@ -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}` +}
@@ -61,7 +68,7 @@ const codeExample = computed(() => data.codeExamples?.map( > @@ -74,7 +81,7 @@ const codeExample = computed(() => data.codeExamples?.map( > diff --git a/docs/package.json b/docs/package.json index 92f0b006a..1c479f116 100644 --- a/docs/package.json +++ b/docs/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8c92956d4..0c6707bda 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -137,6 +137,9 @@ importers: '@rollup/plugin-replace': specifier: ^5.0.2 version: 5.0.2(rollup@3.27.0) + '@types/semver': + specifier: ^7.5.3 + version: 7.5.3 h3: specifier: ^1.8.0 version: 1.8.0 @@ -6342,6 +6345,7 @@ packages: dependencies: is-glob: 4.0.3 micromatch: 4.0.5 + napi-wasm: 1.1.0 dev: true bundledDependencies: - napi-wasm @@ -7678,6 +7682,10 @@ packages: resolution: {integrity: sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==} dev: true + /@types/semver@7.5.3: + resolution: {integrity: sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==} + dev: true + /@types/send@0.17.1: resolution: {integrity: sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==} dependencies: @@ -16082,6 +16090,10 @@ packages: transitivePeerDependencies: - supports-color + /napi-wasm@1.1.0: + resolution: {integrity: sha512-lHwIAJbmLSjF9VDRm9GoVOy9AGp3aIvkjv+Kvz9h16QR3uSVYH78PNQUnT2U4X53mhlnV2M7wrhibQ3GHicDmg==} + dev: true + /natural-compare-lite@1.4.0: resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} dev: true @@ -20919,6 +20931,10 @@ packages: resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==} dev: true + /ufo@1.3.1: + resolution: {integrity: sha512-uY/99gMLIOlJPwATcMVYfqDSxUR9//AUcgZMzwfSTJPDKzA1S8mX4VLqa+fiAtveraQUBCz4FFcwVZBGbwBXIw==} + dev: true + /uglify-es@3.3.9: resolution: {integrity: sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==} engines: {node: '>=0.8.0'}