Skip to content

Commit

Permalink
programatically generating job listing and pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Grant Glidewell committed May 20, 2019
1 parent 2b127e0 commit c135333
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 9 deletions.
23 changes: 23 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,27 @@ exports.createPages = async ({ actions, graphql }) => {
},
})
);

const jobs = await graphql(`
query {
allResumatorJob {
nodes {
title
description
department
}
}
}
`);

const JobTemplate = path.resolve(`src/templates/Job/index.js`);
jobs.data.allResumatorJob.nodes.map(job =>
createPage({
path: `/careers/${job.title.toLowerCase().replace(' ', '-')}`,
component: JobTemplate,
context: {
job,
},
})
);
};
2 changes: 1 addition & 1 deletion plugins/gatsby-source-resumator/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.sourceNodes = async (
const processDatum = node => {
return {
...node,
id: createNodeId(node.id), // TODO: what do their IDs look like?
id: createNodeId(node.id),
parent: null,
children: [],
internal: {
Expand Down
45 changes: 37 additions & 8 deletions src/pages/careers.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import React from 'react';
import { useStaticQuery, graphql } from 'gatsby';
import PropTypes from 'prop-types';
import styled from '@emotion/styled';
import { css } from '@emotion/core';

import { colors } from '../styles';
import Layout from '../components/layout';
import FullWidthSection from '../components/FullWidthSection';

export default () => {
const data = useStaticQuery(graphql`
query {
allResumatorJob {
nodes {
title
description
department
}
}
}
`);
const Filter = styled.nav`
width: 100%;
ul {
Expand All @@ -29,21 +40,36 @@ export default () => {
text-align: right;
line-height: 36px;
padding-right: 15px;
cursor: pointer;
/* cursor: pointer; */
&.active {
color: ${colors.darkgray};
text-decoration: underline;
}
}
`;

const JobList = styled.ul`
margin: 0 auto;
li {
list-style: none;
font-family: Canela-Bold;
font-size: 57px;
color: #282829;
letter-spacing: 0;
text-align: center;
line-height: 72px;
padding: 2rem;
}
`;

return (
<Layout
headerData={{
title: 'Careers',
height: '450px',
}}
>
<Filter>
{/* <Filter>
<ul
css={css`
margin: 0 auto !important;
Expand All @@ -61,16 +87,19 @@ export default () => {
<li>creative</li>
<li>delivery</li>
<li>strategy</li>
<li className='active'>engineering</li>
<li>engineering</li>
</ul>
</Filter>
<FullWidthSection>
<p>joblist</p>
</Filter> */}
<FullWidthSection height='100%'>
<JobList>
{data.allResumatorJob.nodes.map(job => (
<li>{job.title}</li>
))}
</JobList>
</FullWidthSection>
</Layout>
);
};

// TODO: fetch data from Jazz API
// TODO: Build out individual job page
// TODO: implement filtering
15 changes: 15 additions & 0 deletions src/templates/Job/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

import Layout from '../../components/layout';
import FullWidthSection from '../../components/FullWidthSection';

export default ({ pageContext }) => {
const { job } = pageContext;
return (
<Layout headerData={{ title: job.title }}>
<FullWidthSection>
<div dangerouslySetInnerHTML={{ __html: job.description }} />
</FullWidthSection>
</Layout>
);
};

0 comments on commit c135333

Please sign in to comment.