-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathblog.js
More file actions
99 lines (86 loc) · 3.31 KB
/
Copy pathblog.js
File metadata and controls
99 lines (86 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// import Head from 'next/head'
import React, { useState } from 'react'
import { Landing } from '../components/landing.jsx'
import { Navbar } from '../components/navbar'
import { Footer } from '../components/footer'
import { HighlightBox } from '../components/dualcol/_box'
import { getAllFilesFrontMatter } from '../lib/mdx'
import {
SimpleGrid,
Container,
Box,
} from '@chakra-ui/react'
import BlogLayout from '../layouts/blog'
import { NextSeo } from 'next-seo'
const title = "Blog"
const description = "Like reading? Feel free to explore all of our awesome tech blogs!"
const url = "https://www.bitproject.org/blog"
export default function Workshops({ posts }) {
const [searchValue, setSearchValue] = useState('')
const filteredBlogPosts = posts
.sort(
(a, b) =>
Number(new Date(b.publishedAt)) - Number(new Date(a.publishedAt))
)
.filter((frontMatter) =>
frontMatter.title.toLowerCase().includes(searchValue.toLowerCase()) ||
frontMatter.summary.toLowerCase().includes(searchValue.toLowerCase())
)
return (
<>
<NextSeo
title={title}
description={description}
canonical={url}
openGraph={{
url,
title,
description,
images: [
{
url: 'https://www.bitproject.org/_next/image?url=%livecode.png&w=2048&q=75',
alt: 'Bit Project Live Coding',
type: 'image/png',
},
],
}}
/>
<Navbar />
<Landing
heading="Blogs"
description="Like reading? Feel free to explore all of our awesome blogs!"
logoImage="/tv.png"
cta1link={' https://www.notion.so/bitproject/Welcome-to-Serverless-Camp-e218f86daf4248509350709cd9fa8017'}
cta2link={'https://airtable.com/shr9hT8pEXpAAM00Z'}
/>
<Box as="section" bg="black" color="white">
<Container
maxW="container.xl"
pb="10"
>
<SimpleGrid columns={{ sm: 1, md: 2, lg: 3 }} spacing="40px" bg="black" justify="center" >
{filteredBlogPosts.map((frontMatter) => (
<HighlightBox key={frontMatter.title} title={frontMatter.title} companyLogo={frontMatter.companyLogo} image={frontMatter.image} link={`${frontMatter.category}/${frontMatter.slug}`} mx="auto" cohort={frontMatter.cohort} />
))}
</SimpleGrid>
</Container>
</Box>
<Footer />
</>
)
}
export function Blog({ mdxSource, frontMatter }) {
const content = hydrate(mdxSource, {
components: MDXComponents
})
return <BlogLayout frontMatter={frontMatter}>{content}</BlogLayout>
}
export async function getStaticProps() {
const categories = ['projects', 'workshops'];
const finalPosts = [];
for (var i = 0; i < categories.length; i++) {
const retrievedPosts = await getAllFilesFrontMatter(categories[i])
finalPosts.push(...retrievedPosts)
}
return { props: { posts: finalPosts } }
}