diff --git a/.dumi/theme/builtins/TokenTable/index.tsx b/.dumi/theme/builtins/TokenTable/index.tsx index 4453121bf0..89ce7641d9 100644 --- a/.dumi/theme/builtins/TokenTable/index.tsx +++ b/.dumi/theme/builtins/TokenTable/index.tsx @@ -102,12 +102,14 @@ const TokenTable: FC = ({ type }) => { const data = useMemo( () => - tokenMeta[type].map((token) => ({ - name: token.token, - desc: lang === 'cn' ? token.desc : token.descEn, - type: token.type, - value: (defaultToken as any)[token.name], - })), + Object.entries(tokenMeta) + .filter(([, meta]) => meta.source === type) + .map(([token, meta]) => ({ + name: token, + desc: lang === 'cn' ? meta.desc : meta.descEn, + type: meta.type, + value: (defaultToken as any)[token], + })), [type, lang], ); diff --git a/scripts/generate-token-meta.js b/scripts/generate-token-meta.js index 1df073410f..92d9b629bf 100644 --- a/scripts/generate-token-meta.js +++ b/scripts/generate-token-meta.js @@ -65,7 +65,21 @@ function main() { (item) => !tokenMeta.seed.some((seedItem) => seedItem.token === item.token), ); - fs.writeJsonSync(output, tokenMeta, 'utf8'); + const finalMeta = Object.entries(tokenMeta).reduce((acc, [key, value]) => { + value.forEach((item) => { + acc[item.token] = { + name: item.name, + nameEn: item.nameEn, + desc: item.desc, + descEn: item.descEn, + type: item.type, + source: key, + }; + }); + return acc; + }, {}); + + fs.writeJsonSync(output, finalMeta, 'utf8'); // eslint-disable-next-line no-console console.log(`✅ Token Meta has been written to ${output}`); }