1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2025-06-22 22:07:52 +02:00
Files
simple-icons/scripts/release/update-slugs-table.js

34 lines
783 B
JavaScript
Raw Permalink Normal View History

2024-03-25 01:38:18 +08:00
#!/usr/bin/env node
// @ts-check
2021-03-03 11:57:33 +01:00
/**
2024-06-06 14:40:35 +02:00
* @file
2021-03-03 11:57:33 +01:00
* Generates a MarkDown file that lists every brand name and their slug.
*/
2024-03-25 01:38:18 +08:00
import fs from 'node:fs/promises';
import path from 'node:path';
2024-03-25 01:38:18 +08:00
import {getIconSlug, getIconsData} from '../../sdk.mjs';
const rootDirectory = path.resolve(import.meta.dirname, '..', '..');
2024-03-25 01:38:18 +08:00
const slugsFile = path.resolve(rootDirectory, 'slugs.md');
2021-03-03 11:57:33 +01:00
let content = `<!--
update the script at '${path.relative(rootDirectory, import.meta.filename)}'.
2021-03-03 11:57:33 +01:00
-->
# Simple Icons slugs
| Brand name | Brand slug |
| :--- | :--- |
`;
const icons = await getIconsData();
for (const icon of icons) {
2024-12-21 22:49:25 +08:00
const brandName = icon.title;
const brandSlug = getIconSlug(icon);
content += `| \`${brandName}\` | \`${brandSlug}\` |\n`;
}
2024-03-25 01:38:18 +08:00
await fs.writeFile(slugsFile, content);