Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const PostLayout = ({params}: Props) => {
<TableOfContents
headings={post.headings}
rawMarkdown={post.body.raw}
editPath={post._id}
/>
</>
);
Expand Down
68 changes: 0 additions & 68 deletions src/components/ContentTabs.jsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/MdxComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import AWSOneClickLaunchForm from './AWSOneClickLaunchForm';
import {ContentTab, ContentTabs} from './ContentTabs';
import FeatureParity from './FeatureParity';
import Accordion from './mdx/Accordion';
import {Callout} from './mdx/Callout';
Expand All @@ -23,8 +22,6 @@ const MdxComponents = (version?: string) => {
ResourceEstimator,
AWSOneClickLaunchForm,
Accordion,
ContentTabs: (props: any) => <ContentTabs {...props} />,
ContentTab: (props: any) => <ContentTab {...props} />,
Tabs: (props: any) => <Tabs {...props} />,
Tab: (props: any) => <Tab {...props} />,
QuickLinks,
Expand Down
25 changes: 4 additions & 21 deletions src/components/Toc.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';

import clsx from 'clsx';
import {allPosts} from 'contentlayer/generated';
import Link from 'next/link';
import {useParams} from 'next/navigation';
import {useCallback, useEffect, useState} from 'react';
Expand All @@ -18,16 +17,16 @@ interface Heading {
interface Props {
headings: Heading[];
rawMarkdown?: string;
/** Source file path under docs/, for the "Edit this page" link. */
editPath: string;
}

type ParamsType = {
version?: string;
slug: string[];
};

export function TableOfContents({headings, rawMarkdown}: Props) {
export function TableOfContents({headings, rawMarkdown, editPath}: Props) {
let [currentSection, setCurrentSection] = useState(headings[0]?.id);
const [path, setPath] = useState('');
const [copied, setCopied] = useState(false);
const params: ParamsType = useParams();
const basePath = process.env.NEXT_PUBLIC_DOCS_BASE_PATH || '';
Expand Down Expand Up @@ -63,22 +62,6 @@ export function TableOfContents({headings, rawMarkdown}: Props) {
.filter((x): x is {id: string; top: number} => x !== null);
}, []);

useEffect(() => {
const path = params.slug.join('/');

if (allPosts) {
const post = allPosts.find(
post => post._raw.flattenedPath === path
);
if (post) {
let currentPath = post._id;
if (params?.version)
currentPath = `versioned/${params.version}/${currentPath}`;
setPath(currentPath);
}
}
}, [params]);

useEffect(() => {
if (headings.length === 0) return;

Expand Down Expand Up @@ -165,7 +148,7 @@ export function TableOfContents({headings, rawMarkdown}: Props) {
<hr className="mt-4" />
<div className="mt-4 flex items-center text-sm">
<a
href={`https://github.com/sourcegraph/docs/edit/main/docs/${path}`}
href={`https://github.com/sourcegraph/docs/edit/main/docs/${editPath}`}
target="_blank"
rel="noopener noreferrer"
className="flex items-center text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300"
Expand Down
Loading