Skip to content

Commit

Permalink
fix website after fumadocs upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Sep 8, 2024
1 parent 373456b commit b5d2c92
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ tmp/
.pnpm-store
.turbo
.env
.source

# Custom
*.min.js
Expand Down
1 change: 1 addition & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"files": {
"ignore": [
".turbo",
".source",
"examples/**/prisma/**/*",
"packages/**/prisma/**/*",
"packages/plugin-prisma/**/client/**/*",
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions website/.map.ts

This file was deleted.

6 changes: 3 additions & 3 deletions website/app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getPages } from '@/app/source';
import { source } from '@/app/source';
import { createSearchAPI } from 'fumadocs-core/search/server';

export const { GET } = createSearchAPI('advanced', {
indexes: getPages().map((page) => ({
indexes: source.getPages().map((page) => ({
title: page.data.title,
structuredData: page.data.exports.structuredData,
structuredData: page.data.structuredData,
id: page.url,
url: page.url,
})),
Expand Down
15 changes: 8 additions & 7 deletions website/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import { getPage, getPages } from '@/app/source';
import { source } from '@/app/source';
import { useMDXComponents } from '@/mdx-components';
import { DocsBody, DocsPage } from 'fumadocs-ui/page';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';

// biome-ignore lint/suspicious/useAwait: <explanation>
export default async function Page({ params }: { params: { slug?: string[] } }) {
const page = getPage(params.slug);
const page = source.getPage(params.slug);

if (page == null) {
notFound();
}

const MDX = page.data.exports.default;
const MDX = page.data.body;

return (
<DocsPage toc={page.data.exports.toc} full={page.data.full}>
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsBody>
<h1>{page.data.title}</h1>
<MDX />
<MDX components={useMDXComponents({})} />
</DocsBody>
</DocsPage>
);
}

export async function generateStaticParams() {
return getPages().map((page) => ({
return source.getPages().map((page) => ({
slug: page.slugs,
}));
}

export function generateMetadata({ params }: { params: { slug?: string[] } }): Metadata {
const page = getPage(params.slug);
const page = source.getPage(params.slug);

if (page == null) {
notFound();
Expand Down
6 changes: 4 additions & 2 deletions website/app/layout.config.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { pageTree } from '@/app/source';
import { source } from '@/app/source';
import type { DocsLayoutProps } from 'fumadocs-ui/layout';
import Image from 'next/image';

source.pageTree;

// shared configuration
export const baseOptions = {
githubUrl: 'https://github.com/hayes/pothos',
Expand All @@ -25,5 +27,5 @@ export const baseOptions = {
// docs layout configuration
export const docsOptions: DocsLayoutProps = {
...baseOptions,
tree: pageTree,
tree: source.pageTree,
};
20 changes: 10 additions & 10 deletions website/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
import { getPage, getPages } from '@/app/source';
import { source } from '@/app/source';
import defaultMdxComponents from 'fumadocs-ui/mdx';
import { DocsBody, DocsPage } from 'fumadocs-ui/page';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';

// biome-ignore lint/suspicious/useAwait: <explanation>
export default async function HomePage(_props: { params: { slug?: string[] } }) {
const page = getPage([]);

if (page == null) {
export default async function HomePage(props: { params: { slug?: string[] } }) {
const page = source.getPage(props.params.slug);
if (!page) {
notFound();
}

const MDX = page.data.exports.default;
const MDX = page.data.body;

return (
<DocsPage toc={page.data.exports.toc} full={page.data.full}>
<DocsPage toc={page.data.toc}>
<DocsBody>
<h1>{page.data.title}</h1>
<MDX />
<MDX components={{ ...defaultMdxComponents }} />
</DocsBody>
</DocsPage>
);
}

export async function generateStaticParams() {
return getPages().map((page) => ({
return source.getPages().map((page) => ({
slug: page.slugs,
}));
}

export function generateMetadata(): Metadata {
const page = getPage([]);
const page = source.getPage([]);

if (page == null) {
notFound();
Expand Down
7 changes: 3 additions & 4 deletions website/app/source.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { map } from '@/.map';
import { docs, meta } from '@/.source';
import { loader } from 'fumadocs-core/source';
import { createMDXSource } from 'fumadocs-mdx';

export const { getPage, getPages, pageTree } = loader({
export const source = loader({
baseUrl: '/docs',
rootDir: 'docs',
source: createMDXSource(map),
source: createMDXSource(docs, meta),
});
2 changes: 1 addition & 1 deletion website/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
9 changes: 2 additions & 7 deletions website/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { remarkInstall } from 'fumadocs-docgen';
import createMDX from 'fumadocs-mdx/config';
import { createMDX } from 'fumadocs-mdx/next';

const withMDX = createMDX({
mdxOptions: {
remarkPlugins: [remarkInstall],
},
});
const withMDX = createMDX();

/** @type {import('next').NextConfig} */
const config = {
Expand Down
3 changes: 2 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"dev": "next dev",
"next-build": "next build",
"build-ci": "next build",
"start": "next start"
"start": "next start",
"postinstall": "fumadocs-mdx"
},
"engines": {
"pnpm": ">=9.0.0"
Expand Down
10 changes: 10 additions & 0 deletions website/source.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { remarkInstall } from 'fumadocs-docgen';
import { defineConfig, defineDocs } from 'fumadocs-mdx/config';

export const { docs, meta } = defineDocs();

export default defineConfig({
mdxOptions: {
remarkPlugins: [remarkInstall],
},
});

0 comments on commit b5d2c92

Please sign in to comment.