Skip to content

Commit 3083603

Browse files
committed
clean up docs lib sprawl
1 parent 0fd858a commit 3083603

File tree

16 files changed

+254
-366
lines changed

16 files changed

+254
-366
lines changed

src/app/docs/DocsPageContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import NavTree, { type NavTreeNode } from "@/components/nav-tree";
33
import ScrollToTopButton from "@/components/scroll-to-top";
44
import Sidecar from "@/components/sidecar";
55
import { H1, P } from "@/components/text";
6-
import type { DocsPageData } from "@/lib/fetch-docs";
7-
import { DOCS_PAGES_ROOT_PATH, GITHUB_REPO_URL } from "@/lib/docs-config";
6+
import { DOCS_PAGES_ROOT_PATH, GITHUB_REPO_URL } from "@/lib/docs/config";
7+
import type { DocsPageData } from "@/lib/docs/page";
88
import { Pencil } from "lucide-react";
99
import s from "./DocsPage.module.css";
1010
import customMdxStyles from "@/components/custom-mdx/CustomMDX.module.css";

src/app/docs/[[...path]]/page.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ import type { Metadata } from "next";
22
import { notFound } from "next/navigation";
33
import type { Breadcrumb } from "@/components/breadcrumbs";
44
import type { NavTreeNode } from "@/components/nav-tree";
5-
import { DOCS_DIRECTORY, DOCS_PAGES_ROOT_PATH } from "@/lib/docs-config";
5+
import { DOCS_DIRECTORY, DOCS_PAGES_ROOT_PATH } from "@/lib/docs/config";
66
import {
77
type DocsPageData,
88
loadAllDocsPageSlugs,
99
loadDocsPage,
10-
} from "@/lib/fetch-docs";
11-
import { docsMetadataTitle } from "@/lib/docs-metadata-title";
12-
import { loadDocsNavTreeData } from "@/lib/fetch-nav";
13-
import { navTreeToBreadcrumbs } from "@/lib/nav-tree-to-breadcrumbs";
10+
} from "@/lib/docs/page";
11+
import {
12+
docsMetadataTitle,
13+
loadDocsNavTreeData,
14+
navTreeToBreadcrumbs,
15+
} from "@/lib/docs/navigation";
1416
import DocsPageContent from "../DocsPageContent";
1517

1618
interface DocsRouteProps {

src/app/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import type { SimpleLink } from "@/components/link";
44
import Navbar from "@/components/navbar";
55
import PreviewBanner from "@/components/preview-banner";
66
import { jetbrainsMono, pretendardStdVariable } from "@/components/text";
7-
import { DOCS_DIRECTORY } from "@/lib/docs-config";
8-
import { loadDocsNavTreeData } from "@/lib/fetch-nav";
7+
import { DOCS_DIRECTORY } from "@/lib/docs/config";
8+
import { loadDocsNavTreeData } from "@/lib/docs/navigation";
99
import "@/styles/globals.css";
1010
import classNames from "classnames";
1111
import type { Metadata } from "next";

src/components/custom-mdx/index.tsx

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

src/components/jumplink-header/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Text from "../text";
77
import s from "./JumplinkHeader.module.css";
88
import { useInView } from "react-intersection-observer";
99
import { isValidElement, useEffect } from "react";
10-
import { useStore } from "@/lib/use-store";
10+
import { useDocsStore } from "@/lib/docs/store";
1111

1212
interface JumplinkHeaderProps {
1313
as: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
@@ -32,7 +32,9 @@ export default function JumplinkHeader({
3232
rootMargin: "-72px",
3333
threshold: 1,
3434
});
35-
const updateHeaderIdInView = useStore((state) => state.updateHeaderIdInView);
35+
const updateHeaderIdInView = useDocsStore(
36+
(state) => state.updateHeaderIdInView,
37+
);
3638
useEffect(() => {
3739
updateHeaderIdInView(inView, id);
3840
}, [inView, id, updateHeaderIdInView]);

src/components/navbar/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ import NavTree, {
1212
type LinkNode,
1313
type NavTreeNode,
1414
} from "../nav-tree";
15+
import { DOCS_PAGES_ROOT_PATH } from "@/lib/docs/config";
1516
import GhosttyWordmark from "./ghostty-wordmark.svg";
1617
import s from "./Navbar.module.css";
1718

18-
const DOCS_PAGES_ROOT_PATH = "/docs";
19-
2019
export interface NavbarProps {
2120
className?: string;
2221
links?: SimpleLink[];

src/components/sidecar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
55
import classNames from "classnames";
66
import { P } from "../text";
77
import s from "./Sidecar.module.css";
8-
import { useStore } from "@/lib/use-store";
8+
import { useDocsStore } from "@/lib/docs/store";
99

1010
interface SidecarItem {
1111
id: string;
@@ -33,7 +33,7 @@ export default function Sidecar({
3333
}: SidecarProps) {
3434
const activeItemRef = useRef<HTMLLIElement>(null);
3535
const sidecarRef = useRef<HTMLDivElement>(null);
36-
const headerIdsInView = useStore((state) => state.headerIdsInView);
36+
const headerIdsInView = useDocsStore((state) => state.headerIdsInView);
3737
const shownItems = useMemo(() => {
3838
return items.filter((v) => v.depth <= MAX_SIDECAR_HEADER_DEPTH);
3939
}, [items]);

src/lib/docs-config.ts

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

src/lib/docs-metadata-title.ts

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

src/lib/docs/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// DOCS_DIRECTORY is the on-disk root directory that contains docs MDX and nav data.
2+
export const DOCS_DIRECTORY = "./docs";
3+
4+
// DOCS_PAGES_ROOT_PATH is the URL prefix under which docs pages are served.
5+
export const DOCS_PAGES_ROOT_PATH = "/docs";
6+
7+
// GITHUB_REPO_URL is the canonical repository URL used for edit links.
8+
export const GITHUB_REPO_URL = "https://github.com/ghostty-org/website";

0 commit comments

Comments
 (0)