Skip to content

Commit 813072d

Browse files
ENG-1590 Migrate existing docs content into Nextra content directories (#930)
* Add documentation routing and layout for Roam and Obsidian (#928) - Introduced a new `docsRouteMap.ts` file to manage documentation sections and redirects for Roam and Obsidian platforms. - Updated `next.config.ts` to include dynamic redirects based on the new route map. - Refactored the layout components for documentation pages to utilize a consistent theme layout. - Removed outdated `page.tsx` files for Roam and Obsidian, replacing them with new landing pages that leverage Nextra for content rendering. - Added new metadata and content files for various documentation sections, enhancing the overall documentation structure and accessibility. * Update ESLint configuration, package scripts, and add documentation indexing script - Modified ESLint configuration to include new file patterns and global variables. - Updated package.json to change the postbuild script to a new documentation indexing script. - Added a new script for building a search index from documentation markdown files. - Introduced tests for the new indexing script to ensure correct functionality. * Refactor Logo component to use SVG instead of Image component - Replaced the Image component with a span that utilizes an SVG mask for the logo rendering. - Added a new SVG file for the logo to enhance scalability and styling flexibility. * Add Nextra CSS reset class for content width - Introduced a new `.nextra-reset` class in `nextra-css.css` to set the content width to 90rem, enhancing layout consistency across the website. * separate search * docs landing page * Add DocsPageTemplate component and refactor documentation page rendering - Introduced a new `DocsPageTemplate` component to standardize the layout for documentation pages. - Updated the Obsidian and Roam documentation page files to utilize the new `DocsPageTemplate`, improving code consistency and maintainability. - Removed direct usage of `useMDXComponents` in favor of the new template for better structure. * format * Update documentation by removing redundant overview sections and enhancing clarity in node and relation descriptions - Removed the "Overview" section from multiple documentation files to streamline content. - Improved formatting and clarity in the node and relation documentation across various files. - Ensured consistency in the presentation of tag rules and examples in the node-tags documentation. * exploring your discourse graph * Refactor and update documentation for relations and grammar - Renamed "Relations and patterns" to "Legacy relations patterns" for clarity. - Removed outdated sections and improved links to the new stored relations documentation. - Added new files for grammar components, including base grammar, nodes, and operators-relations. - Introduced a migration guide for transitioning to stored relations, enhancing user experience and clarity. * Enhance documentation routing and redirects - Added new custom redirects for Roam documentation to improve navigation. - Simplified the fundamentals section by removing outdated entries. - Introduced a utility function for creating redirects, enhancing code maintainability. * Remove outdated installation instructions for Roam Depot and update related documentation for clarity. The "Installation from Roam Depot" entry has been deleted, and the main installation page has been revised for improved readability. * Refactor documentation for consistency and clarity - Removed unnecessary sections and improved formatting across multiple files. - Standardized headings and titles for better readability. - Updated related links and streamlined content to enhance user navigation. * Refactor navigation links and update global styles for marketing site - Replaced Next.js Link components with anchor tags for hard navigation to prevent CSS conflicts between marketing and documentation sections. - Updated global styles to apply marketing-specific styles, enhancing the overall design consistency across the site. - Removed unused CSS variables related to theming for a cleaner stylesheet. * eslint-disable @typescript-eslint/naming-convention * Add search result link styles for light mode - Updated CSS to ensure search result links and highlighted text have consistent color in light mode. - Applied !important to maintain visibility against the background. * Update package.json Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> * Update apps/website/docsRouteMap.ts Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 7956200 commit 813072d

96 files changed

Lines changed: 2949 additions & 214 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import "~/globals.css";
2+
3+
type DocsLandingLayoutProps = {
4+
children: React.ReactNode;
5+
};
6+
7+
const DocsLandingLayout = ({
8+
children,
9+
}: DocsLandingLayoutProps): React.ReactElement => <>{children}</>;
10+
11+
export default DocsLandingLayout;
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import type { Metadata } from "next";
2+
import { ArrowRight } from "lucide-react";
3+
import { Card, CardContent } from "@repo/ui/components/ui/card";
4+
import { PlatformBadge } from "~/components/PlatformBadge";
5+
import { Logo } from "~/components/Logo";
6+
7+
export const metadata: Metadata = {
8+
title: "Documentation",
9+
description:
10+
"Choose the Discourse Graphs documentation for Roam Research or Obsidian.",
11+
};
12+
13+
const DOCS_DESTINATIONS = [
14+
{
15+
description:
16+
"Installation, graph building, querying, and advanced workflows for the Roam Research plugin.",
17+
href: "/docs/roam",
18+
platform: "roam",
19+
title: "Roam docs",
20+
},
21+
{
22+
description:
23+
"Setup, node and relation authoring, sync, and workspace configuration for the Obsidian plugin.",
24+
href: "/docs/obsidian",
25+
platform: "obsidian",
26+
title: "Obsidian docs",
27+
},
28+
] as const;
29+
30+
const DocsLandingPage = (): React.ReactElement => {
31+
return (
32+
<div className="marketing-site font-[family:var(--font-inter)] min-h-screen bg-neutral-light text-neutral-dark">
33+
<header className="border-b border-black/5 bg-white/80 backdrop-blur">
34+
<div className="mx-auto flex max-w-6xl items-center justify-between gap-6 px-6 py-4">
35+
<Logo />
36+
{/* Use hard navigations across the marketing/docs boundary because Next client transitions can leave the wrong route CSS active. */}
37+
{/* eslint-disable-next-line @next/next/no-html-link-for-pages */}
38+
<a
39+
href="/"
40+
className="text-sm font-medium text-neutral-dark/70 hover:text-neutral-dark"
41+
>
42+
Back to site
43+
</a>
44+
</div>
45+
</header>
46+
47+
<main className="px-6 py-16 sm:py-24">
48+
<div className="mx-auto max-w-6xl">
49+
<section className="max-w-3xl">
50+
<p className="text-sm font-semibold uppercase tracking-[0.18em] text-secondary">
51+
Documentation
52+
</p>
53+
<h1 className="mt-4 text-4xl font-semibold tracking-tight text-primary sm:text-5xl">
54+
Choose your docs
55+
</h1>
56+
<p className="mt-6 text-lg leading-8 text-neutral-dark/80">
57+
Discourse Graphs has separate documentation for each client. Pick
58+
the one you are using to get the right setup instructions,
59+
workflows, and reference pages.
60+
</p>
61+
</section>
62+
63+
<section className="mt-12 grid gap-6 md:grid-cols-2">
64+
{DOCS_DESTINATIONS.map(({ description, href, platform, title }) => (
65+
// Use a document navigation here so Nextra and marketing CSS do not coexist during client-side route transitions.
66+
/* eslint-disable-next-line @next/next/no-html-link-for-pages */
67+
<a key={href} href={href} className="group block h-full">
68+
<Card className="h-full rounded-2xl border border-black/5 bg-white shadow-sm transition-transform duration-200 group-hover:-translate-y-1 group-hover:shadow-lg">
69+
<CardContent className="flex h-full flex-col gap-8 p-8">
70+
<div className="flex items-start justify-between gap-4">
71+
<PlatformBadge platform={platform} />
72+
<ArrowRight className="h-5 w-5 shrink-0 text-neutral-dark/40 transition-transform duration-200 group-hover:translate-x-1 group-hover:text-secondary" />
73+
</div>
74+
75+
<div className="space-y-4">
76+
<h2 className="text-2xl font-semibold tracking-tight text-primary">
77+
{title}
78+
</h2>
79+
<p className="text-base leading-7 text-neutral-dark/75">
80+
{description}
81+
</p>
82+
</div>
83+
84+
<p className="mt-auto text-sm font-semibold text-secondary">
85+
Open documentation
86+
</p>
87+
</CardContent>
88+
</Card>
89+
</a>
90+
))}
91+
</section>
92+
</div>
93+
</main>
94+
</div>
95+
);
96+
};
97+
98+
export default DocsLandingPage;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { EvaluateResult } from "nextra";
2+
import { useMDXComponents } from "mdx-components";
3+
4+
type DocsPageTemplateProps = Omit<EvaluateResult, "default"> & {
5+
children: React.ReactNode;
6+
};
7+
8+
const hasPrimaryHeading = (sourceCode: string): boolean =>
9+
/(^|\n)#\s+\S/m.test(sourceCode);
10+
11+
const DocsPageTemplate = ({
12+
children,
13+
metadata,
14+
sourceCode,
15+
...wrapperProps
16+
}: DocsPageTemplateProps): React.ReactElement => {
17+
const { h1, wrapper } = useMDXComponents();
18+
// eslint-disable-next-line @typescript-eslint/naming-convention
19+
const Wrapper = wrapper as React.ComponentType<DocsPageTemplateProps>;
20+
const H1 = h1 as React.ComponentType<
21+
React.HTMLAttributes<HTMLHeadingElement> & {
22+
children: React.ReactNode;
23+
}
24+
>;
25+
26+
return (
27+
<Wrapper metadata={metadata} sourceCode={sourceCode} {...wrapperProps}>
28+
{!hasPrimaryHeading(sourceCode) && <H1>{metadata.title}</H1>}
29+
{children}
30+
</Wrapper>
31+
);
32+
};
33+
34+
export default DocsPageTemplate;
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import type { PageMapItem } from "nextra";
2+
import { Search } from "nextra/components";
3+
import { Footer, Layout, Navbar } from "nextra-theme-docs";
4+
import { Logo } from "~/components/Logo";
5+
6+
type DocsSearchScope = "roam" | "obsidian";
7+
8+
type DocsThemeLayoutProps = {
9+
children: React.ReactNode;
10+
hideSearch?: boolean;
11+
pageMap: PageMapItem[];
12+
searchScope?: DocsSearchScope;
13+
};
14+
15+
const SEARCH_PLACEHOLDERS: Record<DocsSearchScope, string> = {
16+
obsidian: "Search Obsidian docs...",
17+
roam: "Search Roam docs...",
18+
};
19+
20+
const renderSearch = ({
21+
hideSearch,
22+
searchScope,
23+
}: Pick<DocsThemeLayoutProps, "hideSearch" | "searchScope">):
24+
| React.ReactElement
25+
| null
26+
| undefined => {
27+
if (hideSearch) {
28+
return null;
29+
}
30+
31+
if (!searchScope) {
32+
return undefined;
33+
}
34+
35+
return (
36+
<Search
37+
placeholder={SEARCH_PLACEHOLDERS[searchScope]}
38+
searchOptions={{
39+
filters: {
40+
platform: [searchScope],
41+
},
42+
}}
43+
/>
44+
);
45+
};
46+
47+
const DocsThemeLayout = ({
48+
children,
49+
hideSearch,
50+
pageMap,
51+
searchScope,
52+
}: DocsThemeLayoutProps): React.ReactElement => {
53+
const search = renderSearch({ hideSearch, searchScope });
54+
55+
return (
56+
<div className="nextra-reset">
57+
<Layout
58+
editLink={null}
59+
feedback={{ content: null }}
60+
footer={
61+
<Footer>
62+
Apache 2.0 {new Date().getFullYear()} (c) Discourse Graphs.
63+
</Footer>
64+
}
65+
navbar={
66+
<Navbar
67+
logo={<Logo linked={false} textClassName="text-inherit" />}
68+
projectLink="https://github.com/DiscourseGraphs/discourse-graph"
69+
/>
70+
}
71+
pageMap={pageMap}
72+
search={search}
73+
sidebar={{
74+
defaultMenuCollapseLevel: 1,
75+
}}
76+
toc={{
77+
backToTop: "Back to top",
78+
}}
79+
>
80+
{children}
81+
</Layout>
82+
</div>
83+
);
84+
};
85+
86+
export default DocsThemeLayout;
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import type { Metadata } from "next";
2+
import { notFound } from "next/navigation";
3+
import { generateStaticParamsFor, importPage } from "nextra/pages";
4+
import DocsPageTemplate from "../../_components/DocsPageTemplate";
5+
6+
type DocsPageProps = {
7+
params: Promise<{
8+
mdxPath?: string[];
9+
}>;
10+
};
11+
12+
type ImportedPage = Awaited<ReturnType<typeof importPage>>;
13+
14+
const generateAllStaticParams = generateStaticParamsFor("mdxPath");
15+
16+
const loadPage = async (mdxPath?: string[]): Promise<ImportedPage> =>
17+
importPage(["obsidian", ...(mdxPath ?? [])]);
18+
19+
export const generateStaticParams = async (): Promise<
20+
Array<{ mdxPath?: string[] }>
21+
> => {
22+
const staticParams = await generateAllStaticParams();
23+
24+
return staticParams.flatMap(({ mdxPath }) => {
25+
if (!Array.isArray(mdxPath) || mdxPath[0] !== "obsidian") {
26+
return [];
27+
}
28+
29+
const platformPath = mdxPath.slice(1);
30+
31+
return platformPath.length ? [{ mdxPath: platformPath }] : [{}];
32+
});
33+
};
34+
35+
const Page = async ({ params }: DocsPageProps): Promise<React.ReactElement> => {
36+
try {
37+
const { mdxPath } = await params;
38+
const result = await loadPage(mdxPath);
39+
const { default: MDXContent, ...wrapperProps } = result;
40+
41+
return (
42+
<DocsPageTemplate {...wrapperProps}>
43+
<MDXContent params={{ mdxPath: mdxPath ?? [] }} />
44+
</DocsPageTemplate>
45+
);
46+
} catch (error) {
47+
console.error("Error rendering Obsidian docs page:", error);
48+
notFound();
49+
}
50+
};
51+
52+
export const generateMetadata = async ({
53+
params,
54+
}: DocsPageProps): Promise<Metadata> => {
55+
try {
56+
const { mdxPath } = await params;
57+
const { metadata } = await loadPage(mdxPath);
58+
59+
return metadata;
60+
} catch (error) {
61+
console.error("Error generating Obsidian docs metadata:", error);
62+
63+
return {
64+
title: "Obsidian docs",
65+
};
66+
}
67+
};
68+
69+
export default Page;

apps/website/app/(docs)/docs/obsidian/[slug]/page.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
import { navigation } from "./navigation";
2-
import { Layout } from "~/components/DocsLayout";
1+
import { getPageMap } from "nextra/page-map";
2+
import DocsThemeLayout from "../_components/DocsThemeLayout";
3+
import "../../../(nextra)/nextra-css.css";
4+
import "nextra-theme-docs/style-prefixed.css";
35

4-
export default function RootLayout({
5-
children,
6-
}: {
6+
type ObsidianDocsLayoutProps = {
77
children: React.ReactNode;
8-
}) {
9-
return <Layout navigationList={navigation}>{children}</Layout>;
10-
}
8+
};
9+
10+
const ObsidianDocsLayout = async ({
11+
children,
12+
}: ObsidianDocsLayoutProps): Promise<React.ReactElement> => {
13+
const pageMap = await getPageMap("/docs/obsidian");
14+
15+
return (
16+
<DocsThemeLayout pageMap={pageMap} searchScope="obsidian">
17+
{children}
18+
</DocsThemeLayout>
19+
);
20+
};
21+
22+
export default ObsidianDocsLayout;

apps/website/app/(docs)/docs/obsidian/page.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)