on master help sign in
grants: add gift posts
35fa90cMatilde Park
components/PostPreview.js+5−1
@@ -3,11 +3,15 @@ import BackgroundImage from "./BackgroundImage";
3import { formatDate } from "../lib/lib";
3import { formatDate } from "../lib/lib";
4
4
5export default function PostPreview(props) {
5export default function PostPreview(props) {
6+ const section = props?.section ? props.section : "blog";
6 return (
7 return (
7 <div className={`cursor-pointer ${props.className}`}>
8 <div className={`cursor-pointer ${props.className}`}>
8 {props.title ? <h3 className="mb-2">{props.title}</h3> : null}
9 {props.title ? <h3 className="mb-2">{props.title}</h3> : null}
9
10
11+ <Link
12+ href={`/${section}/${props.post.slug}`}
10− <Link href={`/blog/${props.post.slug}`} key={`post-${props.post.slug}`}>
13+ key={`post-${props.post.slug}`}
14+ >
11 <div>
15 <div>
12 <BackgroundImage
16 <BackgroundImage
13 className="w-full h-96 rounded-lg"
17 className="w-full h-96 rounded-lg"
content/updates/2020-02-06-update.md+3
@@ -2,6 +2,9 @@
2title = "~2020.2.6 Update"
2title = "~2020.2.6 Update"
3date = 2020-02-06
3date = 2020-02-06
4description = "A brief update from the Tlon team for ~2020.2.6."
4description = "A brief update from the Tlon team for ~2020.2.6."
5+[taxonomies]
6+grant_type = ["Gift"]
7+grant_category = []
5[extra]
8[extra]
6author = "Corrina"
9author = "Corrina"
7ship = "~roslet-tanner"
10ship = "~roslet-tanner"
content/updates/2021-06-16-update.md+3
@@ -2,6 +2,9 @@
2title = "A brief update from urbit.org"
2title = "A brief update from urbit.org"
3date = 2021-06-16
3date = 2021-06-16
4description = "A brief update from urbit.org for ~6.16.2021"
4description = "A brief update from urbit.org for ~6.16.2021"
5+[taxonomies]
6+grant_type = ["Gift"]
7+grant_category = []
5[extra]
8[extra]
6author = ""
9author = ""
7ship = "~tirwyd-sarmes"
10ship = "~tirwyd-sarmes"
pages/grants.js+45−3
@@ -10,6 +10,7 @@ import SingleColumn from "../components/SingleColumn";
10import BackgroundImage from "../components/BackgroundImage";
10import BackgroundImage from "../components/BackgroundImage";
11import TabCarousel from "../components/TabCarousel";
11import TabCarousel from "../components/TabCarousel";
12import Section from "../components/Section";
12import Section from "../components/Section";
13+import PostPreview from "../components/PostPreview";
13import GrantPreview from "../components/GrantPreview";
14import GrantPreview from "../components/GrantPreview";
14import {
15import {
15 getAllPosts,
16 getAllPosts,
@@ -67,6 +68,7 @@ export default function Grants({
67 types,
68 types,
68 featuredGrants,
69 featuredGrants,
69 search,
70 search,
71+ gifts,
70}) {
72}) {
71 const [activeTags, setTags] = useState([]);
73 const [activeTags, setTags] = useState([]);
72 const [activeTypes, setTypes] = useState(types);
74 const [activeTypes, setTypes] = useState(types);
@@ -177,11 +179,37 @@ export default function Grants({
177 // Gift Grants
179 // Gift Grants
178 }
180 }
179 <Section wide>
181 <Section wide>
180− <div className="measure pb-16">
182+ <div className="pb-16">
181 <h2 className="pb-16">Gifts</h2>
183 <h2 className="pb-16">Gifts</h2>
182 <p className="mb-8">
184 <p className="mb-8">
183− Gifts are given post facto for exceptional contributions.
185+ Gifts are given post-facto for exceptional contributions.
184 </p>
186 </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>
185 </div>
213 </div>
186 </Section>
214 </Section>
187 {
215 {
@@ -291,6 +319,20 @@ export async function getStaticProps() {
291 ["title", "slug", "date", "description", "extra", "taxonomies"],
319 ["title", "slug", "date", "description", "extra", "taxonomies"],
292 "grants"
320 "grants"
293 );
321 );
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));
294
336
295 // The layout expects exactly 3
337 // The layout expects exactly 3
296 const featuredGrants = [
338 const featuredGrants = [
@@ -302,6 +344,6 @@ export async function getStaticProps() {
302 );
344 );
303
345
304 return {
346 return {
305− props: { posts: posts, categories, types, featuredGrants },
347+ props: { posts: posts, categories, types, featuredGrants, gifts },
306 };
348 };
307}
349}