Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit 9b36ddf

Browse files
committed
terms pages
1 parent 436fd76 commit 9b36ddf

File tree

3 files changed

+75
-4
lines changed

3 files changed

+75
-4
lines changed

netlify.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
[[redirects]]
5252
from = "/get-cody"
5353
to = "/cody"
54+
55+
[[redirects]]
56+
from = "/terms/cloud"
57+
to = "/terms"
58+
5459
# ========== END SOURCEGRAPH REDIRECTS ==========
5560

5661
# ========== HANDBOOK REDIRECTS ==========

src/pages/terms/index.tsx

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,66 @@
1-
import { GetStaticProps } from 'next'
1+
import path from 'path'
22

3-
import TermPage, { PageProps, getStaticProps as getStaticPropsForSlug } from './[...slug]'
3+
import { GetStaticProps, NextPage } from 'next'
4+
import { MDXRemote, MDXRemoteSerializeResult } from 'next-mdx-remote'
45

5-
export const getStaticProps: GetStaticProps<PageProps> = async context =>
6-
getStaticPropsForSlug({ ...context, params: { slug: ['index'] } })
6+
import { Layout, Badge, HubSpotForm, TableWrapper } from '../../components'
7+
import { Page } from '../../interfaces/posts'
8+
import { loadMarkdownFile, serializeMdxSource } from '../../lib'
9+
10+
export type Components = import('mdx/types').MDXComponents
11+
12+
export interface PageProps {
13+
page?: Page
14+
content?: MDXRemoteSerializeResult
15+
}
16+
17+
const CONTENT_PARENT_DIRECTORY = './content/'
18+
19+
const components = { Badge, HubSpotForm, TableWrapper }
20+
21+
const TermPage: NextPage<PageProps> = ({ page, content }) => {
22+
const title = page?.frontmatter.title
23+
const description = page?.frontmatter.description
24+
const image = page?.frontmatter.socialImage
25+
const videoID = page?.frontmatter.videoID
26+
const canonical = page?.frontmatter.canonical
27+
const externalTitle = page?.frontmatter.externalTitle
28+
const externalDescription = page?.frontmatter.externalDescription
29+
const meta = {
30+
title,
31+
image,
32+
videoID,
33+
description,
34+
externalTitle,
35+
externalDescription,
36+
canonical,
37+
}
38+
39+
if (title) {
40+
meta.title = `Sourcegraph - ${title}`
41+
}
42+
43+
return (
44+
<Layout meta={meta}>
45+
<section className="bg-gray-200 py-8 text-center">{page && <h1>{title}</h1>}</section>
46+
<section className="mx-auto my-12 max-w-3xl">
47+
{content && <MDXRemote {...content} components={components as Components} />}
48+
</section>
49+
</Layout>
50+
)
51+
}
752

853
export default TermPage
54+
55+
export const getStaticProps: GetStaticProps = async () => {
56+
const filePath = 'terms/cloud.md'
57+
const page = (await loadMarkdownFile(path.resolve(CONTENT_PARENT_DIRECTORY, filePath))) as Page
58+
const content = await serializeMdxSource(page.content)
59+
60+
return {
61+
props: {
62+
page,
63+
content,
64+
},
65+
}
66+
}

src/pages/terms/index/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { GetStaticProps } from 'next'
2+
3+
import TermPage, { PageProps, getStaticProps as getStaticPropsForSlug } from '../[...slug]'
4+
5+
export const getStaticProps: GetStaticProps<PageProps> = async context =>
6+
getStaticPropsForSlug({ ...context, params: { slug: ['index'] } })
7+
8+
export default TermPage

0 commit comments

Comments
 (0)