Skip to content

Commit 5298b09

Browse files
author
Carms Ng
authored
Merge pull request #39 from coderbunker/add-portfolio-link
Create Member Pages
2 parents 8edf031 + 2292efb commit 5298b09

File tree

10 files changed

+242
-28
lines changed

10 files changed

+242
-28
lines changed

gatsby-config.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ module.exports = {
77
},
88
plugins: [
99
`gatsby-transformer-json`,
10-
{
11-
resolve: `gatsby-source-filesystem`,
12-
options: {
13-
path: `${__dirname}/src/assets/content`,
14-
},
15-
},
10+
1611
`gatsby-plugin-postcss`,
1712
`gatsby-plugin-styled-components`,
1813
`gatsby-plugin-react-helmet`,
@@ -34,8 +29,15 @@ module.exports = {
3429
{
3530
resolve: `gatsby-source-filesystem`,
3631
options: {
32+
name: `content`,
33+
path: `${__dirname}/src/assets/content`,
34+
},
35+
},
36+
{
37+
resolve: `gatsby-source-filesystem`,
38+
options: {
39+
name: `locale`,
3740
path: `${__dirname}/locales`,
38-
name: `locale`
3941
}
4042
},
4143
`gatsby-transformer-sharp`,
@@ -79,7 +81,17 @@ module.exports = {
7981
keySeparator: false,
8082
nsSeparator: false
8183
},
82-
pages: []
84+
pages: [
85+
{
86+
matchPath: '/:language?/members/:name',
87+
getLanguageFromPath: true,
88+
excludeLanguages: []
89+
},
90+
{
91+
matchPath: '/preview',
92+
languages: ['en']
93+
}
94+
]
8395
}
8496
}
8597
],

gatsby-node.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const { graphql } = require("gatsby")
2+
const path = require(`path`)
3+
4+
// create member pages
5+
exports.createPages = async ({ graphql, actions }) => {
6+
const { createPage } = actions
7+
8+
const result = await graphql(`
9+
query {
10+
allMembersJson {
11+
nodes {
12+
en {
13+
name
14+
}
15+
fr {
16+
name
17+
}
18+
parent {
19+
id
20+
}
21+
}
22+
}
23+
allFile(
24+
filter: {extension: {eq: "json"}, relativeDirectory: {eq: "content/members"}}
25+
) {
26+
nodes {
27+
name
28+
id
29+
}
30+
}
31+
}
32+
`)
33+
34+
result.data.allMembersJson.nodes.forEach(node => {
35+
const member = node.en.name
36+
const id = node.parent.id
37+
const slug = result.data.allFile.nodes.find(node => node.id === id).name.substring(3, )
38+
39+
Object.keys(node).forEach(key => {
40+
if (key !== "parent") {
41+
const language = key
42+
const template = "MemberPage.js"
43+
44+
createPage({
45+
path: `${language === "en" ? "" : "/fr"}/members/${slug}`,
46+
component: path.resolve(`./src/templates/${template}`),
47+
context: { slug: slug, language: language, member: member }
48+
})
49+
}
50+
})
51+
})
52+
}
File renamed without changes.

src/components/MemberCard.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import * as React from "react";
2+
import styled from 'styled-components';
3+
import { FiLinkedin, FiGithub } from 'react-icons/fi';
4+
import { MdWeb } from 'react-icons/md'
5+
import { GatsbyImage } from "gatsby-plugin-image";
6+
7+
export default function MemberCard({ member }) {
8+
const { name, title, image, linkedin, github, website, highlights } = member
9+
10+
return (
11+
<MemberCardStyles>
12+
<div className="flex flex-1 md:flex-row-reverse overflow-hidden bg-peach md:bg-white">
13+
<GatsbyImage
14+
image={image?.childImageSharp?.gatsbyImageData}
15+
className="w-1/3-vw h-1/3-vw md:w-1/3 md:h-auto"
16+
imgStyle={{ objectPosition: `top center` }}
17+
alt={name}
18+
/>
19+
<div className="p-2 md:p-8 w-2/3">
20+
<div className="flex flex-col md:flex-row justify-between h-full md:h-auto">
21+
<div>
22+
<h1 className="text-sm sm:text-2xl sm:mb-2">{name}</h1>
23+
<p className="text-sm sm:text-xl">{title}</p>
24+
</div>
25+
<div className="text-sm sm:text-2xl md:text-3xl flex">
26+
{
27+
linkedin &&
28+
<a href={linkedin} aria-label="social media icon Linkedin" target="_blank" rel="noreferrer"><FiLinkedin className="mr-3"/></a>
29+
}
30+
{
31+
github &&
32+
<a href={github} aria-label="social media icon Github" target="_blank" rel="noreferrer"><FiGithub className="md:ml-3"/></a>
33+
}
34+
{
35+
website &&
36+
<a href={website} aria-label="social media icon Website" target="_blank" rel="noreferrer"><MdWeb className="md:ml-3"/></a>
37+
}
38+
</div>
39+
</div>
40+
{/* Highlights for large screens, show all */}
41+
<ul className="py-4 hidden md:block">
42+
{highlights.map(hl => <li key={hl}>{hl}</li>)}
43+
</ul>
44+
</div>
45+
</div>
46+
{/* highlights for small screen, show first few */}
47+
<ul className="text-sm py-4 block md:hidden">
48+
{highlights.map((hl, i) => <li key={hl + i}>{hl}</li>)}
49+
</ul>
50+
</MemberCardStyles>
51+
);
52+
}
53+
54+
const MemberCardStyles = styled.div`
55+
margin: 120px auto;
56+
border-radius: 10px;
57+
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
58+
background: rgba(255, 255, 255, 0.5);
59+
width: 100%;
60+
max-width: 960px;
61+
overflow: hidden;
62+
ul {
63+
list-style-type: "→";
64+
padding-left: 2rem;
65+
li {
66+
padding-left: 0.5rem;
67+
}
68+
}
69+
p, svg {
70+
color: var(--darkgrey);
71+
}
72+
a svg:hover {
73+
color: var(--black);
74+
}
75+
`;

src/components/carousel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { graphql, useStaticQuery } from 'gatsby';
3-
import CarouselCard from "./carousel-card";
3+
import CarouselCard from "./CarouselCard";
44

55
export default function Carousel({ teamIndex, setTeamIndex, locale }) {
66
// Query all team member info

src/components/contact.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import styled from 'styled-components';
44
import { StaticImage } from "gatsby-plugin-image";
55

66
import SiteBorderStyles from '../styles/SiteBorderStyles';
7-
import Footer from "./footer";
87

98
import { AiTwotoneMail, AiTwotonePhone } from 'react-icons/ai';
109
import { FiMapPin } from 'react-icons/fi'
@@ -47,7 +46,6 @@ export default function Contact() {
4746
<ContactForm />
4847
</div>
4948
</SiteBorderStyles>
50-
<Footer />
5149
<div
5250
className="absolute"
5351
style={{zIndex: `-1`, width: `50vw`, left: `0`, bottom: `5vh`}}>
@@ -63,6 +61,7 @@ export default function Contact() {
6361
}
6462

6563
const ContactStyles = styled.section`
64+
height: calc(100vh - 56px);
6665
position: relative;
6766
display: flex;
6867
flex-direction: column;

src/components/footer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FiGithub, FiLinkedin } from "react-icons/fi";
55
import { Trans } from "react-i18next";
66

77
const FooterStyle = styled.footer`
8+
padding: 100px;
89
background: var(--black);
910
padding: 0.5rem 0;
1011
color: var(--lightgrey);
@@ -15,7 +16,7 @@ export default function Footer() {
1516
<FooterStyle>
1617
<SiteBorderStyles>
1718
{/* social links*/}
18-
<div className="flex my-1 md:my-2 items-center justify-between md:justify-center md:text-xl">
19+
<div className="flex my-1 md:my-2 items-center justify-between md:justify-center">
1920
<p className="" style={{ color: `var(--lightgrey)` }}>
2021
© {new Date().getFullYear()} Coderbunker, inc.
2122
</p>

src/components/layout.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
33
import { useStaticQuery, graphql } from "gatsby";
44
import GlobalStyles from '../styles/GlobalStyles';
55
import Typography from '../styles/Typography';
6+
import Footer from "./footer";
67

78
import Header from "./header";
89

@@ -23,6 +24,7 @@ export default function Layout({ children }) {
2324
<GlobalStyles/>
2425
<Typography/>
2526
<main>{children}</main>
27+
<Footer />
2628
</>
2729
)
2830
}

src/pages/404.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,35 @@ import { graphql } from 'gatsby';
33
import { Trans } from "gatsby-plugin-react-i18next";
44
import Layout from "../components/layout";
55
import Seo from "../components/seo";
6-
import SiteBorderStyles from "../styles/SiteBorderStyles";
6+
import styled from "styled-components";
77

88
export default function NotFoundPage() {
99
return (
1010
<Layout>
1111
<Seo title="404" />
12-
<SiteBorderStyles>
13-
<section>
14-
<div className="text-left md:text-center py-4 md:pt-16 md:pb-8 lg:pt-24 md:pb-8">
15-
<h2 className="text-3xl lg:text-4xl">
16-
<span className="highlight-red">
17-
404
18-
</span>
19-
<Trans> Page Not Found</Trans>
20-
</h2>
21-
<p className="text-xl lg:text-2xl my-4" style={{color: `var(--darkgrey)`}}>
22-
<Trans>You just hit a route that doesn&#39;t exist... the sadness.</Trans>
23-
</p>
24-
</div>
25-
</section>
26-
</SiteBorderStyles>
12+
<FourOhFourStyles>
13+
<div className="text-left md:text-center py-4 md:pt-16 md:pb-8 lg:pt-24 md:pb-8">
14+
<h2 className="text-3xl lg:text-4xl">
15+
<span className="highlight-red">
16+
404
17+
</span>
18+
<Trans> Page Not Found</Trans>
19+
</h2>
20+
<p className="text-xl lg:text-2xl my-4" style={{color: `var(--darkgrey)`}}>
21+
<Trans>You just hit a route that doesn&#39;t exist... the sadness.</Trans>
22+
</p>
23+
</div>
24+
</FourOhFourStyles>
2725
</Layout>
2826
)
2927
}
3028

29+
const FourOhFourStyles = styled.div`
30+
height: calc(100vh - 56px);
31+
display: grid;
32+
place-content: center;
33+
`
34+
3135
export const query = graphql`
3236
query($language: String!) {
3337
locales: allLocale(filter: {language: {eq: $language}}) {

src/templates/MemberPage.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { graphql } from 'gatsby';
2+
import React from 'react'
3+
import MemberCard from '../components/MemberCard';
4+
import Layout from '../components/layout'
5+
import Seo from '../components/seo';
6+
import styled from 'styled-components';
7+
8+
export default function MemberPageTemplate({ data, pageContext }) {
9+
const locale = pageContext.language
10+
const member = data.membersJson[locale]
11+
12+
return (
13+
<Layout>
14+
<Seo title={member.name} />
15+
<MemberPageStyles>
16+
<MemberCard member={member} />
17+
</MemberPageStyles>
18+
</Layout>
19+
)
20+
}
21+
22+
const MemberPageStyles = styled.div`
23+
min-height: calc(100vh - 56px);
24+
display: grid;
25+
place-content: center;
26+
padding: 20px;
27+
`
28+
29+
export const data = graphql`
30+
query($member: String!) {
31+
membersJson(en: { name: { eq: $member } }) {
32+
en {
33+
name
34+
title
35+
linkedin
36+
website
37+
github
38+
image {
39+
childImageSharp {
40+
gatsbyImageData(
41+
width: 360,
42+
height: 500,
43+
placeholder: BLURRED,
44+
layout: CONSTRAINED
45+
)
46+
}
47+
}
48+
highlights
49+
}
50+
fr {
51+
name
52+
title
53+
linkedin
54+
website
55+
github
56+
image {
57+
childImageSharp {
58+
gatsbyImageData(
59+
width: 500,
60+
placeholder: BLURRED,
61+
layout: CONSTRAINED
62+
)
63+
}
64+
}
65+
highlights
66+
}
67+
}
68+
}
69+
`;

0 commit comments

Comments
 (0)