on master help sign in
grants: add gift posts
commit35fa90c2952ce8aab2f83abecccfb431bfa74f27 authorMatilde Park <matilde@tlon.io> dateFri 23 Jul 2021, 16:16 (5 years ago) parentf6b986c
4 files changed+56−4
components/PostPreview.js+5−1 content/updates/2020-02-06-update.md+3 content/updates/2021-06-16-update.md+3 pages/grants.js+45−3
components/PostPreview.js+5−1
@@ -3,11 +3,15 @@ import BackgroundImage from "./BackgroundImage";
33import { formatDate } from "../lib/lib";
44
55export default function PostPreview(props) {
6+ const section = props?.section ? props.section : "blog";
67 return (
78 <div className={`cursor-pointer ${props.className}`}>
89 {props.title ? <h3 className="mb-2">{props.title}</h3> : null}
910
10− <Link href={`/blog/${props.post.slug}`} key={`post-${props.post.slug}`}>
11+ <Link
12+ href={`/${section}/${props.post.slug}`}
13+ key={`post-${props.post.slug}`}
14+ >
1115 <div>
1216 <BackgroundImage
1317 className="w-full h-96 rounded-lg"
content/updates/2020-02-06-update.md+3
@@ -2,6 +2,9 @@
22title = "~2020.2.6 Update"
33date = 2020-02-06
44description = "A brief update from the Tlon team for ~2020.2.6."
5+[taxonomies]
6+grant_type = ["Gift"]
7+grant_category = []
58[extra]
69author = "Corrina"
710ship = "~roslet-tanner"
content/updates/2021-06-16-update.md+3
@@ -2,6 +2,9 @@
22title = "A brief update from urbit.org"
33date = 2021-06-16
44description = "A brief update from urbit.org for ~6.16.2021"
5+[taxonomies]
6+grant_type = ["Gift"]
7+grant_category = []
58[extra]
69author = ""
710ship = "~tirwyd-sarmes"
pages/grants.js+45−3
@@ -10,6 +10,7 @@ import SingleColumn from "../components/SingleColumn";
1010import BackgroundImage from "../components/BackgroundImage";
1111import TabCarousel from "../components/TabCarousel";
1212import Section from "../components/Section";
13+import PostPreview from "../components/PostPreview";
1314import GrantPreview from "../components/GrantPreview";
1415import {
1516 getAllPosts,
@@ -67,6 +68,7 @@ export default function Grants({
6768 types,
6869 featuredGrants,
6970 search,
71+ gifts,
7072}) {
7173 const [activeTags, setTags] = useState([]);
7274 const [activeTypes, setTypes] = useState(types);
@@ -177,11 +179,37 @@ export default function Grants({
177179 // Gift Grants
178180 }
179181 <Section wide>
180− <div className="measure pb-16">
182+ <div className="pb-16">
181183 <h2 className="pb-16">Gifts</h2>
182184 <p className="mb-8">
183− Gifts are given post facto for exceptional contributions.
185+ Gifts are given post-facto for exceptional contributions.
184186 </p>
187+ <div className="flex flex-wrap">
188+ <PostPreview
189+ post={gifts[0]}
190+ className={`w-full md:w-1/2 pr-0 pb-8 md:pr-4`}
191+ key={gifts[0].slug}
192+ section={gifts[0].section}
193+ />
194+ <PostPreview
195+ post={gifts[1]}
196+ className={`w-full md:w-1/2 pl-0 pb-8 md:pl-4`}
197+ key={gifts[1].slug}
198+ section={gifts[1].section}
199+ />
200+ <PostPreview
201+ post={gifts[2]}
202+ className={`w-full md:w-1/2 pr-0 pb-8 md:pr-4`}
203+ key={gifts[2].slug}
204+ section={gifts[2].section}
205+ />
206+ <PostPreview
207+ post={gifts[3]}
208+ className={`w-full md:w-1/2 pl-0 pb-8 md:pl-4`}
209+ key={gifts[3].slug}
210+ section={gifts[3].section}
211+ />
212+ </div>
185213 </div>
186214 </Section>
187215 {
@@ -291,6 +319,20 @@ export async function getStaticProps() {
291319 ["title", "slug", "date", "description", "extra", "taxonomies"],
292320 "grants"
293321 );
322+ let gifts = getAllPosts(
323+ ["title", "slug", "date", "description", "extra", "taxonomies"],
324+ "blog"
325+ );
326+ gifts.map((e) => (e.section = "blog"));
327+ let updates = getAllPosts(
328+ ["title", "slug", "date", "description", "extra", "taxonomies"],
329+ "updates"
330+ );
331+ updates.map((e) => (e.section = "updates"));
332+ gifts.push(...updates);
333+ gifts = gifts
334+ .filter((e) => e?.taxonomies?.grant_type?.includes("Gift"))
335+ .sort((a, b) => (a.date > b.date ? -1 : 1));
294336
295337 // The layout expects exactly 3
296338 const featuredGrants = [
@@ -302,6 +344,6 @@ export async function getStaticProps() {
302344 );
303345
304346 return {
305− props: { posts: posts, categories, types, featuredGrants },
347+ props: { posts: posts, categories, types, featuredGrants, gifts },
306348 };
307349}