Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions studio/schemas/shortForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default {
maxLength: 96,
},
},
{
name: "mainImage",
title: "Main image",
type: "mainImage",
},
{
name: "slideshow",
title: "Slideshow",
Expand Down
55 changes: 54 additions & 1 deletion web/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import { graphql } from "gatsby";
import { Grid } from "theme-ui";
import { Divider, Grid, Themed } from "theme-ui";
import { mapEdgesToNodes, filterOutDocsWithoutSlugs } from "../lib/helpers";
import ArticlePreview from "../components/article-layouts/article-preview";
import BlockContent from "../components/block-content";
import Container from "../components/core/container";
import GraphQLErrorList from "../components/core/graphql-error-list";
Expand Down Expand Up @@ -63,6 +64,45 @@ export const query = graphql`
}
}
}
shortForms: allSanityShortForm(
limit: 1
sort: { fields: [publishedAt], order: DESC }
) {
edges {
node {
id
publishedAt
mainImage {
crop {
_key
_type
top
bottom
left
right
}
hotspot {
_key
_type
x
y
height
width
}
asset {
_id
}
alt
}
title
_rawExcerpt
_rawMembers(resolveReferences: { maxDepth: 5 })
slug {
current
}
}
}
}
}
`;

Expand All @@ -83,6 +123,10 @@ const IndexPage = (props) => {
? mapEdgesToNodes(data.projects).filter(filterOutDocsWithoutSlugs)
: [];

const shortFormNodes = (data || {}).shortForms
? mapEdgesToNodes(data.shortForms).filter(filterOutDocsWithoutSlugs)
: [];

if (!site) {
throw new Error(
'Missing "Site settings". Open the studio at http://localhost:3333 and add some content to "Site settings" and restart the development server.'
Expand Down Expand Up @@ -128,6 +172,15 @@ const IndexPage = (props) => {
<BlockContent blocks={page._rawBody || []} />
<Spacer height={5} />
<Section header="Quick Links">
<Themed.h3>Featured Short Form</Themed.h3>
{shortFormNodes && (
<ArticlePreview
key={1}
{...shortFormNodes[0]}
link={shortFormNodes[0].slug.current}
/>
)}
<Divider mb={3} color="text" />
<BlockContent blocks={page._rawBodySecondary || []} />
</Section>
</div>
Expand Down