doc.silverstripe.org/src/templates/docs-template.tsx

53 lines
1.2 KiB
TypeScript
Raw Normal View History

import React, { StatelessComponent, ReactElement } from 'react';
2019-11-08 03:40:20 +01:00
import { graphql } from 'gatsby';
import DocsPage from '../components/DocsPage';
2019-11-08 03:40:20 +01:00
import { SingleFileQuery } from '../types';
const Template: StatelessComponent<SingleFileQuery> = (result): ReactElement => {
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 (
<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 {
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
}
}
}
}
}
}
}
`
;