* Move the site to the root directory * Update Site name Co-authored-by: Eric Fennis <eric.fennis@endurance.com>
33 lines
669 B
TypeScript
33 lines
669 B
TypeScript
import fs from "fs";
|
|
import path from "path";
|
|
import tags from '../../../tags.json';
|
|
|
|
const directory = path.join(process.cwd(), "../icons");
|
|
|
|
export function getAllNames() {
|
|
const fileNames = fs.readdirSync(directory);
|
|
|
|
return fileNames.map((fileName) => {
|
|
return fileName.replace(/\.svg$/, "");
|
|
});
|
|
}
|
|
|
|
export function getData(name) {
|
|
const fullPath = path.join(directory, `${name}.svg`);
|
|
const fileContents = fs.readFileSync(fullPath, "utf8");
|
|
|
|
return {
|
|
name,
|
|
tags: tags[name] || [],
|
|
src: fileContents,
|
|
};
|
|
}
|
|
|
|
export function getAllData() {
|
|
const names = getAllNames();
|
|
|
|
return names.map((name) => {
|
|
return getData(name);
|
|
});
|
|
}
|