digital-gardeners/pages/index.js

115 lines
3.9 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 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";
2021-09-06 18:03:24 +02:00
const tools = [
{
title: "Roam Research",
description: "A personal notes system for interconnected thought",
url: "https://roamresearch.com/",
},
{
title: "Roam Garden",
description:
"Allows you to turn a Roam Research graph into a public website",
url: "https://roam.garden/",
},
{
title: "Gatsby Theme Garden",
description: "Gatsby theme that supports using Roam as a source",
url: "https://github.com/mathieudutour/gatsby-digital-garden/",
},
];
export default function Index({ gardens }) {
2021-09-05 16:37:21 +02:00
return (
<Container>
<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-10 11:22:45 +02:00
<h1 className="sm:text-4xl text-black 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"
>
2021-09-06 17:55:45 +02:00
{gardens.slice(0, 7).map((garden) => (
<Card garden={garden} />
2021-09-05 16:37:21 +02:00
))}
2021-09-06 18:03:24 +02:00
<li>
<Link href="/directory">
<a className="text-deepGreen text-lg">
View all gardens
</a>
</Link>
</li>
</motion.ul>
<motion.ul>
{tools.slice(0, 7).map((tool) => (
<div>
<h2 className="text-xl text-deepGreen font-serif font-light max-w-5xl leading-tight">
{tool.title}
</h2>
<p className="text-lg">{tool.description}</p>
</div>
))}
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
}