Skip to content

Commit

Permalink
amend employers page
Browse files Browse the repository at this point in the history
  • Loading branch information
seanjermey committed Oct 16, 2023
1 parent fbef84c commit b0dac41
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/helpers/employerHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import data from "../../.sourceflow/employers.json";
import CollectionHelper from "@/helpers/CollectionHelper";

export const employerHelper = new CollectionHelper(data);
14 changes: 8 additions & 6 deletions src/pages/great-places-to-work/[url_slug]/index.page.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Content } from "@/ui";
import { getRoute } from "@/getters/getRoute";
import unslug from "unslug";
import { generateImage } from "@/faker/generateImage";
import { generateBody } from "@/faker/generateBody";
import { generateArrayOf } from "@/faker/generateArrayOf";
import { generateTitle } from "@/faker/generateTitle";
import { generateNarrativePanel } from "@/faker/generateNarrativePanel";
import { generateJob } from "@/faker/generateJob";
import { generatePromoItem } from "@/faker/generatePromoItem";
import { employerHelper } from "@/helpers/employerHelper";

export default function EmployerPage({ content }) {
return (
Expand All @@ -18,6 +18,8 @@ export default function EmployerPage({ content }) {
}

export async function getStaticProps({ params: { url_slug } }) {
const employer = employerHelper.find(url_slug);

return {
props: {
meta: {},
Expand All @@ -28,7 +30,7 @@ export async function getStaticProps({ params: { url_slug } }) {
items: [
{ label: "Find a Job", href: getRoute("jobs") },
{ label: "Great Places To Work", href: getRoute("employers") },
{ label: unslug(url_slug), href: getRoute("employer", { url_slug }) },
{ label: employer.name, href: getRoute("employer", { url_slug }) },
],
},
},
Expand All @@ -37,16 +39,16 @@ export async function getStaticProps({ params: { url_slug } }) {
props: {
title: {
path: `page.${url_slug}.component.Header.title`,
placeholder: `Working with ${unslug(url_slug)}`,
placeholder: `Working with ${employer.name}`,
},
img: generateImage({ width: 1440, height: 365 }),
img: employer.cover_image ?? null,
},
},
{
component: "RichText",
props: {
className: "bg-primary text-white py-5",
body: generateBody(),
body: employer.content,
},
},
{
Expand Down Expand Up @@ -104,5 +106,5 @@ export async function getStaticProps({ params: { url_slug } }) {
}

export async function getStaticPaths() {
return { paths: [], fallback: false };
return { paths: employerHelper.toPaths(), fallback: false };
}
15 changes: 15 additions & 0 deletions src/pages/great-places-to-work/index.page.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Content } from "@/ui";
import { getRoute } from "@/getters/getRoute";
import { employerHelper } from "@/helpers/employerHelper";
import { getAsset } from "@/getters/getAsset";

export default function EmployersPage({ content }) {
return (
Expand All @@ -10,6 +12,8 @@ export default function EmployersPage({ content }) {
}

export async function getStaticProps() {
const employers = employerHelper.fetch();

return {
props: {
meta: {},
Expand All @@ -29,6 +33,17 @@ export async function getStaticProps() {
],
},
},
{
component: "PromoSection",
props: {
items: employers.map((i) => ({
title: i.name,
description: i.description,
img: i.card_image ?? i.cover_image ?? getAsset("_theme.employer.card.img.fallback") ?? null,
href: getRoute("employer", { url_slug: i.url_slug }),
})),
},
},
],
},
};
Expand Down
6 changes: 2 additions & 4 deletions src/ui/PromoItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import { trimText } from "@/functions/trimText";
export default function PromoItem({ className, title, img, description, href }) {
return (
<a href={href} className={clsx(className, classes.card)}>
<figure>
<SourceFlowImage src={img} size="380x220" alt={title} />
</figure>
<figure>{img && <SourceFlowImage src={img} size="380x220" alt={title} />}</figure>
<div className={classes.card__body}>
<h5>{trimText(title, 50)}</h5>
<p>{trimText(description, 150)}</p>
<div dangerouslySetInnerHTML={{ __html: description }} />
</div>
</a>
);
Expand Down
6 changes: 4 additions & 2 deletions src/ui/PromoItem/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.card {
text-align: left;
border: 1px solid lightgray;
border-top: 4px solid var(#{--bs-tertiary});
border-top-right-radius: var(#{--bs-border-radius});
border-top-left-radius: var(#{--bs-border-radius});
Expand All @@ -24,11 +25,12 @@
&__body {
flex-grow: 1;
padding: $spacer * 2 $spacer $spacer;
border: 1px solid lightgray;
border-top: 1px solid lightgray;

h5 {
min-height: 57.6px;
min-height: 48px;
color: var(#{--bs-primary});
margin-bottom: 0;
}
}
}

0 comments on commit b0dac41

Please sign in to comment.