mirror of
https://github.com/pheralb/svgl.git
synced 2025-02-11 09:40:31 +08:00
32 lines
748 B
JavaScript
32 lines
748 B
JavaScript
import React from "react";
|
|
import useSWR from "swr";
|
|
import Grid from "components/grid";
|
|
import Library from "components/card/library";
|
|
import Loader from "animations/loader";
|
|
|
|
const fetcher = (url) => fetch(url).then((res) => res.json());
|
|
|
|
const Libraries = () => {
|
|
const { data, error } = useSWR("/api/icons", fetcher);
|
|
if (error) return <div>failed to load</div>;
|
|
if (!data) return <Loader />;
|
|
return (
|
|
<>
|
|
<Grid>
|
|
{data.map((link) => (
|
|
<>
|
|
<div key={link}>
|
|
<Library
|
|
image={link.image}
|
|
title={link.title}
|
|
url={link.url}
|
|
/>
|
|
</div>
|
|
</>
|
|
))}
|
|
</Grid>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Libraries; |