diff --git a/docs/tokens/tokens.11ty.cjs b/docs/tokens/tokens.11ty.cjs index 97716df4ad..a00bfa6cfa 100644 --- a/docs/tokens/tokens.11ty.cjs +++ b/docs/tokens/tokens.11ty.cjs @@ -26,6 +26,8 @@ const { * @property {DesignToken[]} [themeTokens] theme tokens in the category * @property {string[]} [exclude] token paths to exclude from render * @property {string[]} [include] token paths to include in render + * @property {Set} [seenPaths] which token paths have we already + * rendered */ /* eslint-enable jsdoc/check-tag-names */ @@ -365,6 +367,10 @@ module.exports = class TokensPage { /** @param {Options} options */ async renderCategory(options) { + if (options.seenPaths?.has(options.path)) { + return ''; + } + options.seenPaths?.add(options.path); // these are token metadata, don't display them switch (options.name) { case 'attributes': @@ -383,23 +389,23 @@ module.exports = class TokensPage { if (options.level >= 4) { return html`
+ data-name="${options.name}" + data-parent="${options.parent?.name}" + data-path="${options.path}" + data-slug="${options.slug}"> ${content}
`; } else { return html` -
+
${content} -
+ `; } } @@ -408,12 +414,13 @@ module.exports = class TokensPage { const { exclude, include, path, slug } = tokenCategory; const name = path.split('.').pop(); const tokens = resolveTokens(path); + const seenPaths = new Set(); return html` - ${await this.renderCategory({ tokens, name, path, slug, level: 1, exclude, include })} + ${await this.renderCategory({ tokens, name, path, slug, level: 1, exclude, include, seenPaths })} ${await this.renderFile('./docs/_includes/partials/component/feedback.html')} `; }