Created
November 7, 2019 19:21
-
-
Save usulpro/22c67e9bdc9f03bb0819ae4d1161827c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lib/getPage.js | |
import { getEntry } from "./contentful-client"; | |
import { selectImages, selectTemplate } from "./cms-selectors"; | |
export const getPage = async entryId => { | |
const customPage = await getEntry(entryId); | |
const { | |
url, | |
title, | |
seoTitle, | |
seoDescription, | |
headerImage, | |
template, | |
} = customPage.fields; | |
const headerBackground = selectImages([headerImage])[0]; | |
const page = { | |
title: seoTitle, | |
description: seoDescription, | |
canonical: `/${url}`, | |
}; | |
const header = { | |
background: headerBackground && headerBackground.url, | |
title, | |
}; | |
const content = selectTemplate(template); | |
return { page, header, content }; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment