1
0
mirror of https://github.com/simple-icons/simple-icons.git synced 2024-12-16 01:10:30 +02:00
simple-icons/scripts/release/update-slugs-table.js

37 lines
966 B
JavaScript
Raw Normal View History

2024-03-24 19:38:18 +02:00
#!/usr/bin/env node
2021-03-03 12:57:33 +02:00
/**
2024-06-06 14:40:35 +02:00
* @file
2021-03-03 12:57:33 +02:00
* Generates a MarkDown file that lists every brand name and their slug.
*/
2024-03-24 19:38:18 +02:00
import fs from 'node:fs/promises';
import path from 'node:path';
2024-03-24 19:38:18 +02:00
import {fileURLToPath} from 'node:url';
import {getIconSlug, getIconsData} from '../../sdk.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
2021-03-03 12:57:33 +02:00
2024-03-24 19:38:18 +02:00
const rootDirectory = path.resolve(__dirname, '..', '..');
const slugsFile = path.resolve(rootDirectory, 'slugs.md');
2021-03-03 12:57:33 +02:00
let content = `<!--
This file is automatically generated. If you want to change something, please
2024-03-24 19:38:18 +02:00
update the script at '${path.relative(rootDirectory, __filename)}'.
2021-03-03 12:57:33 +02:00
-->
# Simple Icons slugs
| Brand name | Brand slug |
| :--- | :--- |
`;
const icons = await getIconsData();
for (const icon of icons) {
const brandName = icon.title;
const brandSlug = getIconSlug(icon);
content += `| \`${brandName}\` | \`${brandSlug}\` |\n`;
}
2024-03-24 19:38:18 +02:00
await fs.writeFile(slugsFile, content);