mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-18 14:38:24 +00:00
feat(site): Better icon detail page and add unreleased flag (#4877)
* setup icon popularity call * Adjust sort button * Adjust sorting * Adds aliases * Format code * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Add check for env variable * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Improve styling on mobile * Better icon detail page * Update detail page * feat: make edit button more visible * Fix types * Add unreleased version tag * Adjust icon detail * Added edit button * format code * Replace pencil sparkles * Revert changes * Fix types * Add docs checks * Fix types * Fix awaiting release * revert icons changes * Format code * Fix type issues * Update CarbonAdOverlay to not display Disable CarbonAdOverlay by setting drawerOpen to false. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Fix types * Fix condition for showing awaiting release icons Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Format code --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Jakob Guddas <github@jguddas.de>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
Jakob Guddas
parent
99c1037550
commit
ba6751ac45
@@ -27,12 +27,13 @@ import iconNode from '../iconNodes/${iconName}.node.json' with { type: 'json' };
|
||||
import metaData from '../../../../icons/${iconName}.json' with { type: 'json' };
|
||||
import releaseData from '../releaseMetadata/${iconName}.json' with { type: 'json' };
|
||||
import popularity from '../iconPopularity/${iconName}.json' with { type: 'json' };
|
||||
import { IconMetaData, IconNode } from '~/.vitepress/theme/types';
|
||||
|
||||
const { tags, categories, contributors, aliases, deprecated, deprecationReason, toBeRemovedInVersion } = metaData;
|
||||
const { tags, categories, contributors, aliases, deprecated, deprecationReason, toBeRemovedInVersion }: IconMetaData = metaData;
|
||||
|
||||
const iconDetails = {
|
||||
name: '${iconName}',
|
||||
iconNode,
|
||||
iconNode: iconNode as IconNode,
|
||||
contributors,
|
||||
tags,
|
||||
categories,
|
||||
|
||||
@@ -20,6 +20,7 @@ if (!fs.existsSync(iconNodesDirectory)) {
|
||||
|
||||
const iconIndexFile = path.resolve(iconNodesDirectory, `index.ts`);
|
||||
const iconIndexFileImports = [];
|
||||
const iconIndexFileNodes = [];
|
||||
const iconIndexFileExports = [];
|
||||
const iconIndexFileDefaultExports = [];
|
||||
|
||||
@@ -32,7 +33,10 @@ const writeIconFiles = Object.entries(icons).map(async ([iconName, { children }]
|
||||
await fs.promises.writeFile(location, output, 'utf-8');
|
||||
|
||||
iconIndexFileImports.push(
|
||||
`import ${toCamelCase(iconName)}Node from './${iconName}.node.json' with { type: "json" };`,
|
||||
`import ${toCamelCase(iconName)}Json from './${iconName}.node.json' with { type: "json" };`,
|
||||
);
|
||||
iconIndexFileNodes.push(
|
||||
`const ${toCamelCase(iconName)}Node = ${toCamelCase(iconName)}Json as IconNode;`,
|
||||
);
|
||||
iconIndexFileExports.push(` ${toCamelCase(iconName)}Node as ${toCamelCase(iconName)},`);
|
||||
iconIndexFileDefaultExports.push(` '${iconName}': ${toCamelCase(iconName)}Node,`);
|
||||
@@ -43,16 +47,19 @@ try {
|
||||
await fs.promises.writeFile(
|
||||
iconIndexFile,
|
||||
`\
|
||||
import type { IconNode } from '../../theme/types';
|
||||
${iconIndexFileImports.join('\n')}
|
||||
|
||||
${iconIndexFileNodes.join('\n')}
|
||||
|
||||
export {
|
||||
${iconIndexFileExports.join('\n')}
|
||||
}
|
||||
|
||||
export default {
|
||||
${iconIndexFileDefaultExports.join('\n')}
|
||||
}
|
||||
`,
|
||||
} satisfies Record<string, IconNode>;
|
||||
`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ if (!fs.existsSync(iconNodesDirectory)) {
|
||||
|
||||
const iconIndexFile = path.resolve(iconNodesDirectory, `index.ts`);
|
||||
const iconIndexFileImports: string[] = [];
|
||||
const iconIndexFileNodes: string[] = [];
|
||||
const iconIndexFileExports: string[] = [];
|
||||
const iconIndexFileDefaultExports: string[] = [];
|
||||
|
||||
@@ -32,7 +33,10 @@ const writeIconFiles = Object.entries(icons).map(async ([iconName, { children }]
|
||||
await fs.promises.writeFile(location, output, 'utf-8');
|
||||
|
||||
iconIndexFileImports.push(
|
||||
`import ${toCamelCase(iconName)}Node from './${iconName}.node.json' with { type: "json" };`,
|
||||
`import ${toCamelCase(iconName)}Json from './${iconName}.node.json' with { type: "json" };`,
|
||||
);
|
||||
iconIndexFileNodes.push(
|
||||
`const ${toCamelCase(iconName)}Node = ${toCamelCase(iconName)}Json as IconNode;`,
|
||||
);
|
||||
iconIndexFileExports.push(` ${toCamelCase(iconName)}Node as ${toCamelCase(iconName)},`);
|
||||
iconIndexFileDefaultExports.push(` '${iconName}': ${toCamelCase(iconName)}Node,`);
|
||||
@@ -43,16 +47,19 @@ try {
|
||||
await fs.promises.writeFile(
|
||||
iconIndexFile,
|
||||
`\
|
||||
import type { IconNode } from '../../../theme/types';
|
||||
${iconIndexFileImports.join('\n')}
|
||||
|
||||
${iconIndexFileNodes.join('\n')}
|
||||
|
||||
export {
|
||||
${iconIndexFileExports.join('\n')}
|
||||
}
|
||||
|
||||
export default {
|
||||
${iconIndexFileDefaultExports.join('\n')}
|
||||
}
|
||||
`,
|
||||
} satisfies Record<string, IconNode>;
|
||||
`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
|
||||
@@ -40,7 +40,21 @@ const fetchAllReleases = async () => {
|
||||
);
|
||||
};
|
||||
|
||||
const getIconNamesAtTag = async (tag: string) => {
|
||||
// --full-tree resolves `icons/` from the repo root instead of the cwd (docs/)
|
||||
const files = await git.raw(['ls-tree', '--full-tree', '--name-only', tag, 'icons/']);
|
||||
|
||||
return new Set(
|
||||
files
|
||||
.split('\n')
|
||||
.filter((file) => file.endsWith('.svg'))
|
||||
.map((file) => path.basename(file, '.svg')),
|
||||
);
|
||||
};
|
||||
|
||||
const tags = await fetchAllReleases();
|
||||
const forkIconNames = await getIconNamesAtTag(tags[0]);
|
||||
const releasedIconNames = await getIconNamesAtTag(tags[tags.length - 1]);
|
||||
|
||||
const comparisonsPromises = tags.map(async (tag, index) => {
|
||||
const previousTag = tags[index - 1];
|
||||
@@ -150,19 +164,26 @@ try {
|
||||
const iconName = path.basename(iconJsonFile, '.json');
|
||||
const metaDir = path.resolve(releaseMetaDataDirectory, `${iconName}.json`);
|
||||
|
||||
if (!(iconName in newReleaseMetaData)) {
|
||||
const metaData = await fs.promises.readFile(path.join(ICONS_DIR, iconJsonFile), 'utf-8');
|
||||
const iconMetaData = JSON.parse(metaData);
|
||||
const aliases = iconMetaData.aliases ?? [];
|
||||
|
||||
const fromFork = [iconName, ...aliases.map((alias) => alias.name)].some((name) =>
|
||||
forkIconNames.has(name),
|
||||
);
|
||||
const awaitingRelease = !releasedIconNames.has(iconName);
|
||||
|
||||
if (!(iconName in newReleaseMetaData) && !fromFork && !awaitingRelease) {
|
||||
console.error(`Could not find release metadata for icon '${iconName}'.`);
|
||||
}
|
||||
|
||||
const contents = {
|
||||
fromFork,
|
||||
awaitingRelease,
|
||||
...defaultReleaseMetaData,
|
||||
...(newReleaseMetaData[iconName] ?? {}),
|
||||
};
|
||||
|
||||
const metaData = await fs.promises.readFile(path.join(ICONS_DIR, iconJsonFile), 'utf-8');
|
||||
const iconMetaData = JSON.parse(metaData);
|
||||
const aliases = iconMetaData.aliases ?? [];
|
||||
|
||||
if (aliases.length) {
|
||||
aliases.forEach((alias) => {
|
||||
if (!(alias.name in newReleaseMetaData)) {
|
||||
|
||||
Reference in New Issue
Block a user