Skip to content

Commit

Permalink
fix: deprecate non-standard use of @link and use @sourceFileLink
Browse files Browse the repository at this point in the history
…instead
  • Loading branch information
adrianschmidt committed Nov 8, 2023
1 parent a1bbe7d commit 15aa2b1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/kompendium/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
{
Expand Down Expand Up @@ -87,12 +87,28 @@ const getStyle =
};
};

async function getLinks(
async function getSourceFileLinks(
component: JsonDocsComponent
): Promise<JsonDocsSource[]> {
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<JsonDocsSource>(linkTags.map(getLink(component)));
const linkTags = component.docsTags.filter(
(tag) => tag.name === 'sourceFileLink'
);
const backwardsCompatibleLinkTags = [...linkTags, ...deprecatedLinkTags];

return Promise.all<JsonDocsSource>(
backwardsCompatibleLinkTags.map(getLink(component))
);
}

const getLink =
Expand Down

0 comments on commit 15aa2b1

Please sign in to comment.