2019-12-18 23:54:23 +01:00
|
|
|
import React, { StatelessComponent, ReactElement } from 'react';
|
2019-11-08 03:40:20 +01:00
|
|
|
import { graphql } from 'gatsby';
|
2019-12-18 23:54:23 +01:00
|
|
|
import DocsPage from '../components/DocsPage';
|
2019-11-08 03:40:20 +01:00
|
|
|
import { SingleFileQuery } from '../types';
|
|
|
|
|
|
|
|
const Template: StatelessComponent<SingleFileQuery> = (result): ReactElement => {
|
2019-12-18 23:54:23 +01:00
|
|
|
const currentNode = result.data.silverstripeDocument;
|
|
|
|
const { title } = currentNode;
|
|
|
|
const { html } = currentNode.watchFile;
|
|
|
|
const { relativePath, gitRemote } = currentNode.parent.parent;
|
|
|
|
const { ref, href } = gitRemote;
|
|
|
|
|
2019-11-08 03:40:20 +01:00
|
|
|
return (
|
2019-12-18 23:54:23 +01:00
|
|
|
<DocsPage
|
|
|
|
title={title}
|
|
|
|
html={html}
|
|
|
|
relPath={relativePath}
|
|
|
|
branch={ref}
|
|
|
|
gitURL={href}
|
|
|
|
/>
|
2019-11-08 03:40:20 +01:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Template;
|
|
|
|
|
|
|
|
export const pageQuery = graphql`
|
|
|
|
query DocsBySlug($slug: String!) {
|
|
|
|
silverstripeDocument(slug: { eq: $slug }) {
|
2019-11-19 01:55:33 +01:00
|
|
|
title
|
|
|
|
slug
|
|
|
|
id
|
|
|
|
watchFile {
|
|
|
|
html
|
|
|
|
}
|
2019-11-08 03:40:20 +01:00
|
|
|
parent {
|
|
|
|
... on MarkdownRemark {
|
2019-11-20 01:56:11 +01:00
|
|
|
html
|
2019-11-08 03:40:20 +01:00
|
|
|
parent {
|
|
|
|
... on File {
|
|
|
|
relativePath
|
|
|
|
gitRemote {
|
2019-12-18 23:54:23 +01:00
|
|
|
href
|
2019-11-08 03:40:20 +01:00
|
|
|
ref
|
2019-11-12 04:09:29 +01:00
|
|
|
sourceInstanceName
|
2019-11-08 03:40:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
;
|