diff --git a/src/kompendium/source.ts b/src/kompendium/source.ts index 2cfb824..03a00e3 100644 --- a/src/kompendium/source.ts +++ b/src/kompendium/source.ts @@ -42,7 +42,7 @@ export async function getSources( const styles = await Promise.all( styleNames.map(getStyle(component.dirPath)) ); - const links = await getLinks(component); + const links = await getSourceFileLinks(component); return [ { @@ -87,12 +87,28 @@ const getStyle = }; }; -async function getLinks( +async function getSourceFileLinks( component: JsonDocsComponent ): Promise { - const linkTags = component.docsTags.filter((tag) => tag.name === 'link'); + const deprecatedLinkTags = component.docsTags.filter( + (tag) => tag.name === 'link' + ); + if (deprecatedLinkTags.length > 0) { + // eslint-disable-next-line no-console + console.warn( + 'Using the @link tag to link source files for display alongside examples is deprecated. ' + + 'Use @sourceFileLink instead.' + ); + } - return Promise.all(linkTags.map(getLink(component))); + const linkTags = component.docsTags.filter( + (tag) => tag.name === 'sourceFileLink' + ); + const backwardsCompatibleLinkTags = [...linkTags, ...deprecatedLinkTags]; + + return Promise.all( + backwardsCompatibleLinkTags.map(getLink(component)) + ); } const getLink =