2024-03-25 01:38:18 +08:00
|
|
|
#!/usr/bin/env node
|
2025-03-04 03:12:53 +01:00
|
|
|
// @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';
|
2021-12-25 06:22:56 -08:00
|
|
|
import path from 'node:path';
|
2024-03-25 01:38:18 +08:00
|
|
|
import {getIconSlug, getIconsData} from '../../sdk.mjs';
|
2021-12-25 06:22:56 -08:00
|
|
|
|
2025-05-27 19:22:37 +08:00
|
|
|
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 = `<!--
|
2025-05-27 19:22:37 +08:00
|
|
|
|
|
|
|
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 |
|
|
|
|
| :--- | :--- |
|
|
|
|
`;
|
|
|
|
|
2023-08-07 22:38:52 -06:00
|
|
|
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`;
|
2023-08-07 22:38:52 -06:00
|
|
|
}
|
2024-03-25 01:38:18 +08:00
|
|
|
|
2023-08-07 22:38:52 -06:00
|
|
|
await fs.writeFile(slugsFile, content);
|