diff --git a/netlify.toml b/netlify.toml index d1d97faee18..50dd5579d67 100644 --- a/netlify.toml +++ b/netlify.toml @@ -51,6 +51,11 @@ [[redirects]] from = "/get-cody" to = "/cody" + +[[redirects]] + from = "/terms/cloud" + to = "/terms" + # ========== END SOURCEGRAPH REDIRECTS ========== # ========== HANDBOOK REDIRECTS ========== diff --git a/src/pages/terms/index.tsx b/src/pages/terms/index.tsx index b4654bdd581..edb2c73cda9 100644 --- a/src/pages/terms/index.tsx +++ b/src/pages/terms/index.tsx @@ -1,8 +1,66 @@ -import { GetStaticProps } from 'next' +import path from 'path' -import TermPage, { PageProps, getStaticProps as getStaticPropsForSlug } from './[...slug]' +import { GetStaticProps, NextPage } from 'next' +import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote' -export const getStaticProps: GetStaticProps = async context => - getStaticPropsForSlug({ ...context, params: { slug: ['index'] } }) +import { Layout, Badge, HubSpotForm, TableWrapper } from '../../components' +import { Page } from '../../interfaces/posts' +import { loadMarkdownFile, serializeMdxSource } from '../../lib' + +export type Components = import('mdx/types').MDXComponents + +export interface PageProps { + page?: Page + content?: MDXRemoteSerializeResult +} + +const CONTENT_PARENT_DIRECTORY = './content/' + +const components = { Badge, HubSpotForm, TableWrapper } + +const TermPage: NextPage = ({ page, content }) => { + const title = page?.frontmatter.title + const description = page?.frontmatter.description + const image = page?.frontmatter.socialImage + const videoID = page?.frontmatter.videoID + const canonical = page?.frontmatter.canonical + const externalTitle = page?.frontmatter.externalTitle + const externalDescription = page?.frontmatter.externalDescription + const meta = { + title, + image, + videoID, + description, + externalTitle, + externalDescription, + canonical, + } + + if (title) { + meta.title = `Sourcegraph - ${title}` + } + + return ( + +
{page &&

{title}

}
+
+ {content && } +
+
+ ) +} export default TermPage + +export const getStaticProps: GetStaticProps = async () => { + const filePath = 'terms/cloud.md' + const page = (await loadMarkdownFile(path.resolve(CONTENT_PARENT_DIRECTORY, filePath))) as Page + const content = await serializeMdxSource(page.content) + + return { + props: { + page, + content, + }, + } +} diff --git a/src/pages/terms/index/index.tsx b/src/pages/terms/index/index.tsx new file mode 100644 index 00000000000..6d45493b443 --- /dev/null +++ b/src/pages/terms/index/index.tsx @@ -0,0 +1,8 @@ +import { GetStaticProps } from 'next' + +import TermPage, { PageProps, getStaticProps as getStaticPropsForSlug } from '../[...slug]' + +export const getStaticProps: GetStaticProps = async context => + getStaticPropsForSlug({ ...context, params: { slug: ['index'] } }) + +export default TermPage