Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terms pages #7487

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
[[redirects]]
from = "/get-cody"
to = "/cody"

[[redirects]]
from = "/terms/cloud"
to = "/terms"

# ========== END SOURCEGRAPH REDIRECTS ==========

# ========== HANDBOOK REDIRECTS ==========
Expand Down
66 changes: 62 additions & 4 deletions src/pages/terms/index.tsx
Original file line number Diff line number Diff line change
@@ -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<PageProps> = 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<PageProps> = ({ 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 (
<Layout meta={meta}>
<section className="bg-gray-200 py-8 text-center">{page && <h1>{title}</h1>}</section>
<section className="mx-auto my-12 max-w-3xl">
{content && <MDXRemote {...content} components={components as Components} />}
</section>
</Layout>
)
}

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,
},
}
}
8 changes: 8 additions & 0 deletions src/pages/terms/index/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { GetStaticProps } from 'next'

import TermPage, { PageProps, getStaticProps as getStaticPropsForSlug } from '../[...slug]'

export const getStaticProps: GetStaticProps<PageProps> = async context =>
getStaticPropsForSlug({ ...context, params: { slug: ['index'] } })

export default TermPage
Loading