digital-gardeners/pages/index.js

81 lines
2.6 KiB
JavaScript
Raw Normal View History

2021-09-05 16:37:21 +02:00
import fs from "fs";
import matter from "gray-matter";
import Link from "next/link";
import path from "path";
import Container from "../components/Container";
import Layout from "../components/Layout";
import Sidemenu from "../components/Sidemenu";
import Card from "../components/Card";
2021-09-05 17:09:03 +02:00
import { gardenFilePath, GARDENS_PATH } from "../utils/mdxUtils";
2021-09-05 16:37:21 +02:00
import { motion } from "framer-motion";
export default function Index({ gardens }) {
2021-09-05 16:37:21 +02:00
return (
<Container>
<Sidemenu />
<Layout>
<motion.div
initial="hidden"
animate="visible"
variants={{
hidden: { opacity: 0, y: -50 },
visible: {
opacity: 1,
y: 0,
transition: {
delay: 0.1,
ease: "easeInOut",
duration: 0.7,
},
},
}}
>
2021-09-06 17:36:23 +02:00
<h1 className="sm:text-4xl mb-6 font-semibold">
2021-09-05 16:37:21 +02:00
Garden of Digital Gardens
</h1>
2021-09-06 17:36:23 +02:00
<h2 className="text-xl text-deepGreen font-serif font-light max-w-5xl leading-tight">
2021-09-05 16:37:21 +02:00
A collection of digital gardens, tools, and resources
for gardeners
2021-09-06 17:36:23 +02:00
</h2>
2021-09-05 16:37:21 +02:00
</motion.div>
<motion.ul
initial="hidden"
animate="show"
variants={{
hidden: { opacity: 0, y: 50 },
show: {
opacity: 1,
y: 0,
transition: {
delay: 0.6,
ease: "easeInOut",
duration: 0.7,
},
},
}}
className="flex flex-wrap mt-24"
>
{gardens.map((garden) => (
<Card garden={garden} />
2021-09-05 16:37:21 +02:00
))}
</motion.ul>
</Layout>
</Container>
);
}
export function getStaticProps() {
const gardens = gardenFilePath.map((filePath) => {
2021-09-05 16:37:21 +02:00
const source = fs.readFileSync(path.join(GARDENS_PATH, filePath));
const { content, data } = matter(source);
return {
content,
data,
filePath,
};
});
return { props: { gardens } };
2021-09-05 16:37:21 +02:00
}