html fallback when watchFile null

This commit is contained in:
Aaron Carlino 2019-11-20 13:56:11 +13:00
parent 63833a4f28
commit 856d707efa
2 changed files with 8 additions and 1 deletions

View File

@ -7,7 +7,12 @@ import { setCurrentNode } from '../utils/nodes';
const Template: StatelessComponent<SingleFileQuery> = (result): ReactElement => {
const currentNode = result.data.silverstripeDocument;
const { html } = currentNode.watchFile;
let html;
if (currentNode.watchFile) {
html = currentNode.watchFile.html;
} else {
html = currentNode.parent.html;
}
const { title, slug } = currentNode;
const { relativePath, gitRemote: { ref, webLink } } = currentNode.parent.parent;
const editLink = `${webLink}/edit/${ref}/${relativePath}`;
@ -43,6 +48,7 @@ export const pageQuery = graphql`
}
parent {
... on MarkdownRemark {
html
parent {
... on File {
relativePath

View File

@ -11,6 +11,7 @@ export interface SinglePage {
html: string;
}
parent: {
html: string;
parent: {
relativePath: string;
gitRemote: {