diff --git a/site/src/components/IconDetailOverlay.tsx b/site/src/components/IconDetailOverlay.tsx index 5c1cb0741..228e406a3 100644 --- a/site/src/components/IconDetailOverlay.tsx +++ b/site/src/components/IconDetailOverlay.tsx @@ -6,7 +6,7 @@ import {useContext, useEffect, useRef} from "react"; import {IconStyleContext} from "./CustomizeIconContext"; import {IconWrapper} from "./IconWrapper"; import ModifiedTooltip from "./ModifiedTooltip"; -import { IconData } from "../lib/icons"; +import { IconEntity } from "../types"; type IconDownload = { src: string; @@ -16,7 +16,7 @@ type IconDownload = { interface IconDetailOverlayProps { open: boolean close: () => void - icon?: IconData + icon?: IconEntity } const IconDetailOverlay = ({ open = true, close, icon }: IconDetailOverlayProps) => { @@ -152,7 +152,7 @@ const IconDetailOverlay = ({ open = true, close, icon }: IconDetailOverlayProps) className="icon-large" > { icon.contributors.map((commit, index) => ( - - + + diff --git a/site/src/components/IconList.tsx b/site/src/components/IconList.tsx index ec97d6600..918305671 100644 --- a/site/src/components/IconList.tsx +++ b/site/src/components/IconList.tsx @@ -2,8 +2,8 @@ import { Grid } from '@chakra-ui/react'; import Link from 'next/link'; import { useRouter } from 'next/router'; import { memo } from 'react'; -import { IconEntity } from '../types'; import IconListItem from './IconListItem'; +import { IconEntity } from '../types'; interface IconListProps { icons: IconEntity[]; diff --git a/site/src/components/IconListItem.tsx b/site/src/components/IconListItem.tsx index 7444b6b95..540404682 100644 --- a/site/src/components/IconListItem.tsx +++ b/site/src/components/IconListItem.tsx @@ -1,19 +1,16 @@ import { Button, ButtonProps, Flex, Text, useToast } from '@chakra-ui/react'; import download from 'downloadjs'; import { memo } from 'react'; -import { Contributor } from '../lib/fetchAllContributors'; import { useCustomizeIconContext } from './CustomizeIconContext'; import { IconWrapper } from './IconWrapper'; interface IconListItemProps { name: string; - content: string; - contributors: Contributor[] - src: string; onClick?: ButtonProps['onClick'] + src: string; } -const IconListItem = ({ name, content, onClick, src: svg }: IconListItemProps) => { +const IconListItem = ({ name, onClick, src: svg }: IconListItemProps) => { const toast = useToast(); const { color, size, strokeWidth, iconsRef } = useCustomizeIconContext(); @@ -53,7 +50,7 @@ const IconListItem = ({ name, content, onClick, src: svg }: IconListItemProps) = { - content: string; + src: string; } export const IconWrapper = forwardRef((props, ref) => { @@ -17,11 +17,12 @@ export const IconWrapper = forwardRef((props, r strokeLinejoin: 'round', }; - const { content, ...rest } = props; + const { src, ...rest } = props; const attrs = { ...defaultAttrs, ...rest, }; + const content = src.replace(/]*>|<\/svg>/g, ''); return ; }); diff --git a/site/src/lib/fetchAllContributors.ts b/site/src/lib/fetchAllContributors.ts index 49d72ae50..c5feb9482 100644 --- a/site/src/lib/fetchAllContributors.ts +++ b/site/src/lib/fetchAllContributors.ts @@ -1,11 +1,7 @@ import crypto from 'crypto'; import fs from 'fs'; import path from 'path'; - -export interface Contributor { - author: string - commit: string -} +import { Contributor } from '../types'; const IGNORE_COMMIT_MESSAGES = ['fork', 'optimize']; @@ -54,9 +50,8 @@ export const filterCommits = (commits) => !IGNORE_COMMIT_MESSAGES.some(ignoreItem => commit.message.toLowerCase().includes(ignoreItem), )) - .map(({ sha, author }) => ({ + .map(({ author }) => ({ author: author && author.login ? author.login : null, - commit: sha, })) .filter(({ author }, index, self) => self.findIndex((commit) => commit.author === author) === index); diff --git a/site/src/lib/icons.tsx b/site/src/lib/icons.tsx index cbb0e8f02..49c1f3e78 100644 --- a/site/src/lib/icons.tsx +++ b/site/src/lib/icons.tsx @@ -2,7 +2,8 @@ import fs from "fs"; import path from "path"; import { parseSync, stringify } from 'svgson'; import tags from '../../../tags.json'; -import { Contributor, getContributors } from "./fetchAllContributors"; +import { IconEntity } from "../types"; +import { getContributors } from "./fetchAllContributors"; const directory = path.join(process.cwd(), "../icons"); @@ -28,20 +29,11 @@ export async function getData(name: string) { name, tags: tags[name] || [], contributors, - src: fileContent, - content: svgContent + src: fileContent }; } -export interface IconData { - name: string - tags: string[] - contributors: Contributor[] - src: string - content: string -} - -export async function getAllData(): Promise { +export async function getAllData(): Promise { const names = getAllNames(); return Promise.all(names.map((name) => getData(name))); diff --git a/site/src/pages/index.tsx b/site/src/pages/index.tsx index 4bb15b23a..06a167c37 100644 --- a/site/src/pages/index.tsx +++ b/site/src/pages/index.tsx @@ -1,5 +1,5 @@ import Layout from '../components/Layout'; -import { getAllData, IconData } from '../lib/icons'; +import { getAllData } from '../lib/icons'; import IconOverview from '../components/IconOverview'; import IconDetailOverlay from '../components/IconDetailOverlay'; @@ -8,9 +8,10 @@ import Header from '../components/Header'; import MobileMenu from '../components/MobileMenu'; import { useMemo } from 'react'; import { GetStaticPropsResult, NextPage } from 'next'; +import { IconEntity } from '../types'; interface HomePageProps { - data: IconData[] + data: IconEntity[] } const HomePage: NextPage = ({ data }) => { diff --git a/site/src/types.ts b/site/src/types.ts index 4227e88f9..7475420c6 100644 --- a/site/src/types.ts +++ b/site/src/types.ts @@ -1,5 +1,4 @@ export interface IconEntity { - content: string; contributors: Contributor[]; name: string; src: string; @@ -8,5 +7,4 @@ export interface IconEntity { export interface Contributor { author: string; - commit: string; }