Skip to content

Commit 8c286ee

Browse files
committed
Add supporters page to blog
1 parent bbfc02d commit 8c286ee

File tree

5 files changed

+80
-16
lines changed

5 files changed

+80
-16
lines changed

package-lock.json

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"gray-matter": "4.0.2",
3737
"react": "^16.13.0",
3838
"react-dom": "^16.13.0",
39-
"react-free-style": "^11.0.1",
39+
"react-free-style": "^11.1.0",
4040
"remark": "^12.0.0",
4141
"remark-highlight.js": "^6.0.0",
4242
"remark-html": "^11.0.2",

src/components/layout.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { ReactNode } from "react";
22
import { styled } from "react-free-style";
3+
import Link from "next/link";
34

45
const Main = styled("div");
56

@@ -124,8 +125,11 @@ const BorderTop = styled("div", {
124125
});
125126

126127
const Header = styled("ul", {
128+
display: "flex",
129+
justifyContent: "space-between",
130+
flexWrap: "wrap",
127131
margin: 0,
128-
padding: "2em 0",
132+
padding: "1.5em 0",
129133
fontSize: "1.2em",
130134
});
131135

@@ -134,6 +138,11 @@ const HeaderLink = styled("a", {
134138
textDecoration: "none",
135139
borderBottom: "2px solid transparent",
136140
"&:hover": { borderBottomColor: "var(--brand-color)" },
141+
"&.active": { borderBottomColor: "var(--brand-color)" },
142+
});
143+
144+
const PrimaryHeaderLink = styled(HeaderLink, {
145+
fontWeight: "bold",
137146
});
138147

139148
const Content = styled("div", {
@@ -255,13 +264,27 @@ const Content = styled("div", {
255264
// "pre .diff-chunk": { color: "#aaa" },
256265
});
257266

258-
export const Layout = ({ children }: { children: ReactNode }) => {
267+
export type Props = {
268+
page?: "index" | "supporters";
269+
children: ReactNode;
270+
};
271+
272+
export const Layout = ({ page, children }: Props) => {
259273
return (
260274
<Main>
261275
<BorderTop />
262276
<Container>
263277
<Header>
264-
<HeaderLink href="/">Writing</HeaderLink>
278+
<Link href="/" passHref>
279+
<PrimaryHeaderLink className={page === "index" ? "active" : ""}>
280+
Writing
281+
</PrimaryHeaderLink>
282+
</Link>
283+
<Link href="/supporters/" passHref>
284+
<HeaderLink className={page === "supporters" ? "active" : ""}>
285+
Supporters
286+
</HeaderLink>
287+
</Link>
265288
</Header>
266289

267290
<Content>{children}</Content>

src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const Index: React.FC<Props> = ({ posts }) => {
2828
<Head>
2929
<title>Blake Embrey</title>
3030
</Head>
31-
<Layout>
31+
<Layout page="index">
3232
{posts.map((x) => {
3333
return (
3434
<Article key={x.title}>

src/pages/supporters.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from "react";
2+
import Head from "next/head";
3+
import { Layout } from "../components/layout";
4+
5+
export type Props = {
6+
supporters: Array<{ name: string; url: string }>;
7+
};
8+
9+
const Supporters: React.FC<Props> = ({ supporters }) => {
10+
return (
11+
<>
12+
<Head>
13+
<title>Supporters • Blake Embrey</title>
14+
</Head>
15+
<Layout page="supporters">
16+
<ul>
17+
{supporters.map((x) => {
18+
return (
19+
<li key={x.name}>
20+
<a href={x.url}>{x.name}</a>
21+
</li>
22+
);
23+
})}
24+
</ul>
25+
</Layout>
26+
</>
27+
);
28+
};
29+
30+
export default Supporters;
31+
32+
export const getStaticProps = async (): Promise<{ props: Props }> => {
33+
return {
34+
props: {
35+
supporters: [
36+
{ name: "Ideal Postcodes", url: "https://ideal-postcodes.co.uk/" },
37+
{ name: "RaiderIO", url: "https://raider.io/" },
38+
],
39+
},
40+
};
41+
};

0 commit comments

Comments
 (0)