-
{news.map((node) => {
const title = node.frontmatter.title;
const date = new Date(node.frontmatter.date);
@@ -34,6 +32,8 @@ const NewsIndex = ({ data, location }) => {
export default NewsIndex;
+export const Head = () =>
News;
+
export const pageQuery = graphql`
query {
site {
diff --git a/site/src/templates/documentation.js b/site/src/templates/documentation.js
index ff86a24..381c9ef 100644
--- a/site/src/templates/documentation.js
+++ b/site/src/templates/documentation.js
@@ -1,24 +1,51 @@
-import React from 'react';
-import { Link, graphql } from 'gatsby';
+import React, { useCallback, useMemo, useState } from 'react';
+import { Link, navigate, graphql } from 'gatsby';
+import { Box } from '@mui/material';
import Layout from '../components/layout';
-import Seo from '../components/seo';
+import VersionSelect from '../components/version-select';
+import { getCurrentVersion, getDocsVersion } from '../utils/version-docs';
const DocumentationTemplate = ({ children, data, pageContext, location }) => {
- const docs = data.allMdx.nodes;
+ const allDocs = data.allMdx.nodes;
const toc = data.mdx.tableOfContents.items;
const pageTitle = pageContext.frontmatter.title;
+ const slug = data.mdx.fields.slug;
const siteTitle = data.site?.siteMetadata?.title;
+ const versions = useMemo(
+ () => data.allDirectory.nodes.map((node) => node.base),
+ [data.allDirectory.nodes]
+ );
+
+ const [selectedVersion, setSelectedVersion] = useState(
+ getCurrentVersion(slug, versions)
+ );
+ const docs = getDocsVersion(allDocs, getCurrentVersion(slug, versions));
+
+ const handleVersionChange = useCallback(
+ (event) => {
+ const newPath = slug.replace(selectedVersion, event.target.value);
+ setSelectedVersion(event.target.value);
+ navigate(newPath);
+ },
+ [selectedVersion, slug]
+ );
return (
-
{siteTitle}