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';
|
2021-12-25 16:22:56 +02:00
|
|
|
import path from 'node:path';
|
2024-03-24 19:38:18 +02:00
|
|
|
import {fileURLToPath} from 'node:url';
|
|
|
|
import {getIconSlug, getIconsData} from '../../sdk.mjs';
|
2021-12-25 16:22:56 +02:00
|
|
|
|
|
|
|
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 |
|
|
|
|
| :--- | :--- |
|
|
|
|
`;
|
|
|
|
|
2023-08-08 06:38:52 +02:00
|
|
|
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
|
|
|
|
2023-08-08 06:38:52 +02:00
|
|
|
await fs.writeFile(slugsFile, content);
|