Add contributors to icon overlay and add dot (#223)

* add contributers

* Add icon fetcher

* add contributing json

* Fix fetch call

* Add contributers to site

* Add caching for github api

* Fix build

* Move context provider

* Revert packages changes

* Fix mobile layout

* remove react-spring

* remove incorrect type prop
This commit is contained in:
Eric Fennis
2021-02-12 20:38:47 +01:00
committed by GitHub
parent c4dfe6b8cb
commit a7e8b3bcb7
12 changed files with 305 additions and 110 deletions

View File

@@ -2,6 +2,7 @@ import fs from "fs";
import path from "path";
import cheerio from 'cheerio';
import tags from '../../../tags.json';
import { getContributors } from "./fetchAllContributors";
const directory = path.join(process.cwd(), "../icons");
@@ -13,25 +14,26 @@ export function getAllNames() {
});
}
export function getData(name) {
export async function getData(name:string) {
const fullPath = path.join(directory, `${name}.svg`);
const fileContents = fs.readFileSync(fullPath, "utf8");
const $ = cheerio.load(fileContents);
const content = $("svg").html();
const contributors = await getContributors(name);
return {
name,
tags: tags[name] || [],
contributors,
src: fileContents,
content: content
};
}
export function getAllData() {
export async function getAllData() {
const names = getAllNames();
return names.map((name) => {
return getData(name);
});
return Promise.all(names.map((name) => getData(name)));
}