tailwind-ctp-intellisense/packages/tailwindcss-language-service/src/util/docsUrl.ts

17 lines
498 B
TypeScript
Raw Normal View History

import * as semver from './semver'
2020-04-28 20:42:43 +00:00
export function docsUrl(version: string, paths: string | string[]): string {
let major = 0
2020-11-27 17:05:58 +00:00
let url = 'https://tailwindcss-v0.netlify.app/docs/'
2020-04-28 20:42:43 +00:00
if (semver.gte(version, '0.99.0')) {
major = 1
2020-11-27 17:05:58 +00:00
url = 'https://v1.tailwindcss.com/docs/'
}
if (semver.gte(version, '1.99.0')) {
major = 2
2020-04-28 20:42:43 +00:00
url = 'https://tailwindcss.com/docs/'
}
const path = Array.isArray(paths) ? paths[major] || paths[paths.length - 1] : paths
2020-04-28 20:42:43 +00:00
return `${url}${path}`
}