mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 06:31:49 +00:00
CLI: Replace contentlayer with content-collections
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'create-fumadocs-app': patch
|
||||
---
|
||||
|
||||
Replace `contentlayer` with `content-collections`
|
||||
@@ -1,4 +0,0 @@
|
||||
module.exports = {
|
||||
extends: ['custom/library'],
|
||||
ignorePatterns: ['*.test.ts'],
|
||||
};
|
||||
@@ -1,299 +0,0 @@
|
||||
# fumadocs-contentlayer
|
||||
|
||||
## 1.1.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2eb68c8: Force a release of content sources
|
||||
- fumadocs-core@12.0.7
|
||||
|
||||
## 1.1.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 310e0ab: Move `fumadocs-core` to peer dependency
|
||||
- Updated dependencies [053609d]
|
||||
- fumadocs-core@12.0.3
|
||||
|
||||
## 1.1.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@12.0.2
|
||||
|
||||
## 1.1.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@12.0.1
|
||||
|
||||
## 1.1.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [98430e9]
|
||||
- Updated dependencies [d88dfa6]
|
||||
- Updated dependencies [ba20694]
|
||||
- Updated dependencies [57eb762]
|
||||
- fumadocs-core@12.0.0
|
||||
|
||||
## 1.1.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [1b8e12b]
|
||||
- fumadocs-core@11.3.2
|
||||
|
||||
## 1.1.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.3.1
|
||||
|
||||
## 1.1.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [917d87f]
|
||||
- fumadocs-core@11.3.0
|
||||
|
||||
## 1.1.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.2.2
|
||||
|
||||
## 1.1.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.2.1
|
||||
|
||||
## 1.1.24
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.2.0
|
||||
|
||||
## 1.1.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [88008b1]
|
||||
- Updated dependencies [944541a]
|
||||
- Updated dependencies [07a9312]
|
||||
- fumadocs-core@11.1.3
|
||||
|
||||
## 1.1.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.1.2
|
||||
|
||||
## 1.1.21
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [8ef2b68]
|
||||
- Updated dependencies [26f464d]
|
||||
- Updated dependencies [26f464d]
|
||||
- fumadocs-core@11.1.1
|
||||
|
||||
## 1.1.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.1.0
|
||||
|
||||
## 1.1.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [98258b5]
|
||||
- fumadocs-core@11.0.8
|
||||
|
||||
## 1.1.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f7c2c5c]
|
||||
- fumadocs-core@11.0.7
|
||||
|
||||
## 1.1.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5653d5d]
|
||||
- Updated dependencies [5653d5d]
|
||||
- fumadocs-core@11.0.6
|
||||
|
||||
## 1.1.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.0.5
|
||||
|
||||
## 1.1.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [7b61b2f]
|
||||
- fumadocs-core@11.0.4
|
||||
|
||||
## 1.1.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.0.3
|
||||
|
||||
## 1.1.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.0.2
|
||||
|
||||
## 1.1.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@11.0.1
|
||||
|
||||
## 1.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2d8df75]
|
||||
- Updated dependencies [92cb12f]
|
||||
- Updated dependencies [f75287d]
|
||||
- Updated dependencies [2d8df75]
|
||||
- fumadocs-core@11.0.0
|
||||
|
||||
## 1.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bbad52f]
|
||||
- fumadocs-core@10.1.3
|
||||
|
||||
## 1.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@10.1.2
|
||||
|
||||
## 1.1.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [779c599]
|
||||
- Updated dependencies [0c01300]
|
||||
- Updated dependencies [779c599]
|
||||
- fumadocs-core@10.1.1
|
||||
|
||||
## 1.1.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@10.1.0
|
||||
|
||||
## 1.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [e47c62f]
|
||||
- fumadocs-core@10.0.5
|
||||
|
||||
## 1.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@10.0.4
|
||||
|
||||
## 1.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6f321e5]
|
||||
- fumadocs-core@10.0.3
|
||||
|
||||
## 1.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [10e099a]
|
||||
- fumadocs-core@10.0.2
|
||||
|
||||
## 1.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [c9b7763]
|
||||
- Updated dependencies [0e78dc8]
|
||||
- Updated dependencies [d8483a8]
|
||||
- fumadocs-core@10.0.1
|
||||
|
||||
## 1.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b5d16938]
|
||||
- Updated dependencies [321d1e1f]
|
||||
- fumadocs-core@10.0.0
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1c388ca5: Support `defaultOpen` for folder nodes
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [909b0e35]
|
||||
- Updated dependencies [691f12aa]
|
||||
- Updated dependencies [1c388ca5]
|
||||
- fumadocs-core@9.1.0
|
||||
|
||||
## 1.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@9.0.0
|
||||
|
||||
## 1.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@8.3.0
|
||||
|
||||
## 1.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [5c24659]
|
||||
- fumadocs-core@8.2.0
|
||||
|
||||
## 1.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- fumadocs-core@8.1.1
|
||||
|
||||
## 1.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6c5a39a: Rename Git repository to `fumadocs`
|
||||
- Updated dependencies [6c5a39a]
|
||||
- Updated dependencies [eb028b4]
|
||||
- Updated dependencies [054ec60]
|
||||
- fumadocs-core@8.1.0
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2ea9437]
|
||||
- Updated dependencies [cdff313]
|
||||
- Updated dependencies [1a346a1]
|
||||
- Updated dependencies [2b11c20]
|
||||
- fumadocs-core@8.0.0
|
||||
@@ -1,5 +0,0 @@
|
||||
# Fumadocs Contentlayer
|
||||
|
||||
The Contentlayer adapter for Fumadocs.
|
||||
|
||||
📘 Learn More: [Documentation](https://fumadocs.vercel.app)
|
||||
@@ -1,62 +0,0 @@
|
||||
{
|
||||
"name": "fumadocs-contentlayer",
|
||||
"version": "1.1.34",
|
||||
"description": "The Contentlayer adapter for Fumadocs",
|
||||
"keywords": [
|
||||
"NextJs",
|
||||
"Docs"
|
||||
],
|
||||
"homepage": "https://fumadocs.vercel.app",
|
||||
"repository": "github:fuma-nama/fumadocs",
|
||||
"license": "MIT",
|
||||
"author": "Fuma Nama",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./configuration": {
|
||||
"import": "./dist/configuration.js",
|
||||
"types": "./dist/configuration.d.ts"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
".": [
|
||||
"./dist/index.d.ts"
|
||||
],
|
||||
"configuration": [
|
||||
"./dist/configuration.d.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup",
|
||||
"clean": "rimraf dist",
|
||||
"dev": "tsup --watch",
|
||||
"lint": "eslint .",
|
||||
"types:check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"rehype-img-size": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"contentlayer": "^0.3.4",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"fumadocs-core": "workspace:*",
|
||||
"tsconfig": "workspace:*",
|
||||
"unified": "^11.0.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"fumadocs-core": "12.x.x"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
/**
|
||||
* Default configuration generator
|
||||
*
|
||||
* Feel free to copy and modify the code
|
||||
*
|
||||
* Warning: Shouldn't be imported in Next.js, this can cause problem. Put it in contentlayer.config.ts only
|
||||
*/
|
||||
import type {
|
||||
Args,
|
||||
ComputedFields,
|
||||
DocumentType,
|
||||
FieldDef,
|
||||
} from 'contentlayer/source-files';
|
||||
import { defineDocumentType } from 'contentlayer/source-files';
|
||||
import type { MDXOptions } from 'contentlayer/core';
|
||||
import type { PluggableList, Plugin } from 'unified';
|
||||
import rehypeImgSize, {
|
||||
type Options as RehypeImgSizeOptions,
|
||||
} from 'rehype-img-size';
|
||||
import {
|
||||
rehypeCode,
|
||||
remarkGfm,
|
||||
structure,
|
||||
type RehypeCodeOptions,
|
||||
} from 'fumadocs-core/mdx-plugins';
|
||||
import { getTableOfContents } from 'fumadocs-core/server';
|
||||
import type { DocsPageBase } from './types';
|
||||
|
||||
export interface Config {
|
||||
contentDirPath: string;
|
||||
Meta: DocumentType;
|
||||
Docs: DocumentType;
|
||||
mdx: MDXOptions;
|
||||
}
|
||||
|
||||
export type Options = Partial<{
|
||||
/**
|
||||
* Where the docs files located
|
||||
* @defaultValue "docs"
|
||||
*/
|
||||
docsPattern: string;
|
||||
|
||||
/**
|
||||
* @defaultValue "content"
|
||||
*/
|
||||
contentDirPath: string;
|
||||
|
||||
/**
|
||||
* The directory path for images
|
||||
* @defaultValue "./public"
|
||||
*/
|
||||
imgDirPath: string;
|
||||
|
||||
mdx: MDXOptions;
|
||||
|
||||
codeOptions: RehypeCodeOptions;
|
||||
|
||||
docFields: Record<string, FieldDef>;
|
||||
docsComputedFields: ComputedFields<'Docs'>;
|
||||
metaFields: Record<string, FieldDef>;
|
||||
metaComputedFields: ComputedFields<'Meta'>;
|
||||
}>;
|
||||
|
||||
export function create(options: Options = {}): Config {
|
||||
const {
|
||||
docsPattern = 'docs',
|
||||
contentDirPath = 'content',
|
||||
imgDirPath = './public',
|
||||
docFields,
|
||||
metaFields,
|
||||
docsComputedFields,
|
||||
codeOptions,
|
||||
metaComputedFields,
|
||||
mdx = {},
|
||||
} = options;
|
||||
|
||||
const remarkPlugins: PluggableList = [
|
||||
remarkGfm,
|
||||
...(mdx.remarkPlugins ?? []),
|
||||
];
|
||||
const rehypePlugins: PluggableList = [
|
||||
[rehypeCode, codeOptions],
|
||||
[
|
||||
rehypeImgSize as Plugin<[RehypeImgSizeOptions]>,
|
||||
{
|
||||
dir: imgDirPath,
|
||||
},
|
||||
],
|
||||
...(mdx.rehypePlugins ?? []),
|
||||
];
|
||||
|
||||
const Docs = defineDocumentType(() => ({
|
||||
name: 'Docs',
|
||||
filePathPattern: `${docsPattern}/**/*.mdx`,
|
||||
contentType: 'mdx',
|
||||
fields: {
|
||||
title: {
|
||||
type: 'string',
|
||||
description: 'The title of the document',
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
description: 'The description of the document',
|
||||
required: false,
|
||||
},
|
||||
icon: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
},
|
||||
...docFields,
|
||||
},
|
||||
computedFields: {
|
||||
structuredData: {
|
||||
type: 'json',
|
||||
resolve(_docs) {
|
||||
const docs = _docs as DocsPageBase;
|
||||
return structure(docs.body.raw, remarkPlugins);
|
||||
},
|
||||
},
|
||||
toc: {
|
||||
type: 'json',
|
||||
resolve(_docs) {
|
||||
const docs = _docs as DocsPageBase;
|
||||
return getTableOfContents(docs.body.raw);
|
||||
},
|
||||
},
|
||||
...docsComputedFields,
|
||||
},
|
||||
}));
|
||||
|
||||
const Meta = defineDocumentType(() => ({
|
||||
name: 'Meta',
|
||||
filePathPattern: `${docsPattern}/**/*.json`,
|
||||
contentType: 'data',
|
||||
fields: {
|
||||
root: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
description: 'The title of the folder',
|
||||
required: false,
|
||||
},
|
||||
pages: {
|
||||
type: 'list',
|
||||
of: {
|
||||
type: 'string',
|
||||
},
|
||||
description: 'Pages of the folder',
|
||||
required: false,
|
||||
},
|
||||
icon: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
},
|
||||
defaultOpen: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
},
|
||||
...metaFields,
|
||||
},
|
||||
computedFields: {
|
||||
...metaComputedFields,
|
||||
},
|
||||
}));
|
||||
|
||||
return {
|
||||
contentDirPath,
|
||||
Docs,
|
||||
Meta,
|
||||
mdx: {
|
||||
...mdx,
|
||||
rehypePlugins,
|
||||
remarkPlugins,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function createConfig(options?: Options): Args {
|
||||
const config = create(options);
|
||||
|
||||
return {
|
||||
contentDirPath: config.contentDirPath,
|
||||
documentTypes: [config.Docs, config.Meta],
|
||||
mdx: config.mdx,
|
||||
};
|
||||
}
|
||||
|
||||
export const defaultConfig: Args = createConfig();
|
||||
@@ -1,22 +0,0 @@
|
||||
import type { VirtualFile, Source } from 'fumadocs-core/source';
|
||||
import type { DocsPageBase, MetaPageBase } from './types';
|
||||
|
||||
export function createContentlayerSource<
|
||||
Meta extends MetaPageBase,
|
||||
Docs extends DocsPageBase,
|
||||
>(metas: Meta[], pages: Docs[]): Source<{ metaData: Meta; pageData: Docs }> {
|
||||
return {
|
||||
files: [
|
||||
...metas.map<VirtualFile>((meta) => ({
|
||||
type: 'meta',
|
||||
path: meta._raw.sourceFilePath,
|
||||
data: meta,
|
||||
})),
|
||||
...pages.map<VirtualFile>((page) => ({
|
||||
type: 'page',
|
||||
path: page._raw.sourceFilePath,
|
||||
data: page,
|
||||
})),
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export { createContentlayerSource } from './create-contentlayer';
|
||||
|
||||
export type * from './types';
|
||||
@@ -1,22 +0,0 @@
|
||||
import type { RawDocumentData } from 'contentlayer/source-files';
|
||||
import type { MDX } from 'contentlayer/core';
|
||||
|
||||
export interface MetaPageBase {
|
||||
_id: string;
|
||||
_raw: RawDocumentData;
|
||||
type: 'Meta';
|
||||
title?: string | undefined;
|
||||
pages?: string[];
|
||||
icon?: string;
|
||||
root?: boolean;
|
||||
}
|
||||
|
||||
export interface DocsPageBase {
|
||||
_id: string;
|
||||
_raw: RawDocumentData;
|
||||
type: 'Docs';
|
||||
title: string;
|
||||
description?: string | undefined;
|
||||
icon?: string;
|
||||
body: MDX;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "tsconfig/react-library.json",
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
const sharedConfig = {
|
||||
external: ['contentlayer', 'unified'],
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
...sharedConfig,
|
||||
dts: true,
|
||||
target: 'es6',
|
||||
format: 'esm',
|
||||
entry: ['src/{index,configuration}.ts'],
|
||||
});
|
||||
@@ -5,21 +5,18 @@
|
||||
"description": "Used to track dependency versions in create-fumadocs-app",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@content-collections/core": "^0.6.0",
|
||||
"@content-collections/mdx": "^0.1.3",
|
||||
"@content-collections/next": "^0.2.0",
|
||||
"@types/mdx": "^2.0.13",
|
||||
"@types/react": "^18.3.3",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"contentlayer": "^0.3.4",
|
||||
"next": "^14.2.4",
|
||||
"next-contentlayer": "^0.3.4",
|
||||
"postcss": "^8.4.38",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"tailwindcss": "^3.4.4",
|
||||
"typescript": "^5.5.2"
|
||||
},
|
||||
"overrides": {
|
||||
"unified": "^11.0.4",
|
||||
"mdx-bundler": "^10.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { PackageManager } from './auto-install';
|
||||
import { autoInstall } from './auto-install';
|
||||
import { sourceDir, cwd } from './constants';
|
||||
|
||||
export type Template = 'contentlayer' | 'fuma-docs-mdx';
|
||||
export type Template = 'content-collections' | 'fuma-docs-mdx';
|
||||
|
||||
export interface Options {
|
||||
outputDir: string;
|
||||
@@ -101,16 +101,16 @@ function createPackageJson(
|
||||
},
|
||||
};
|
||||
|
||||
if (template === 'contentlayer') {
|
||||
if (template === 'content-collections') {
|
||||
Object.assign(packageJson.dependencies, {
|
||||
'fumadocs-contentlayer': localVersions['fumadocs-contentlayer'],
|
||||
contentlayer: versionPkg.dependencies.contentlayer,
|
||||
'next-contentlayer': versionPkg.dependencies['next-contentlayer'],
|
||||
});
|
||||
|
||||
// TODO: Remove this after Contentlayer supports unified 11
|
||||
Object.assign(packageJson, {
|
||||
overrides: versionPkg.overrides,
|
||||
'@fumadocs/content-collections':
|
||||
localVersions['@fumadocs/content-collections'],
|
||||
'@content-collections/core':
|
||||
versionPkg.dependencies['@content-collections/core'],
|
||||
'@content-collections/mdx':
|
||||
versionPkg.dependencies['@content-collections/mdx'],
|
||||
'@content-collections/next':
|
||||
versionPkg.dependencies['@content-collections/next'],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ async function main(): Promise<void> {
|
||||
initialValue: 'fuma-docs-mdx' as Template,
|
||||
options: [
|
||||
{ value: 'fuma-docs-mdx', label: 'Fumadocs MDX' },
|
||||
{ value: 'contentlayer', label: 'Contentlayer' },
|
||||
{ value: 'content-collections', label: 'Content Collections' },
|
||||
],
|
||||
}),
|
||||
tailwindcss: () => confirm({ message: 'Use Tailwind CSS for styling?' }),
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# generated content
|
||||
.map.ts
|
||||
.contentlayer
|
||||
.content-collections
|
||||
|
||||
# test & build
|
||||
/coverage
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@ import { createSearchAPI } from 'fumadocs-core/search/server';
|
||||
|
||||
export const { GET } = createSearchAPI('advanced', {
|
||||
indexes: getPages().map((page) => ({
|
||||
id: page.data._id,
|
||||
title: page.data.title,
|
||||
url: page.url,
|
||||
structuredData: page.data.structuredData,
|
||||
id: page.url,
|
||||
url: page.url,
|
||||
})),
|
||||
});
|
||||
+11
-13
@@ -1,31 +1,29 @@
|
||||
import { Content } from './content';
|
||||
import { getPage, getPages } from '@/app/source';
|
||||
import type { Metadata } from 'next';
|
||||
import { DocsPage, DocsBody } from 'fumadocs-ui/page';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { MDXContent } from '@content-collections/mdx/react';
|
||||
import defaultMdxComponents from 'fumadocs-ui/mdx';
|
||||
|
||||
export default async function Page({
|
||||
params,
|
||||
}: {
|
||||
params: { slug?: string[] };
|
||||
}) {
|
||||
export default function Page({ params }: { params: { slug?: string[] } }) {
|
||||
const page = getPage(params.slug);
|
||||
|
||||
if (page == null) {
|
||||
notFound();
|
||||
}
|
||||
if (!page) notFound();
|
||||
|
||||
return (
|
||||
<DocsPage toc={page.data.toc}>
|
||||
<DocsPage toc={page.data.toc} full={page.data.full}>
|
||||
<DocsBody>
|
||||
<h1>{page.data.title}</h1>
|
||||
<Content code={page.data.body.code} />
|
||||
<MDXContent
|
||||
code={page.data.body}
|
||||
components={{ ...defaultMdxComponents }}
|
||||
/>
|
||||
</DocsBody>
|
||||
</DocsPage>
|
||||
);
|
||||
}
|
||||
|
||||
export async function generateStaticParams(): Promise<{ slug: string[] }[]> {
|
||||
export function generateStaticParams() {
|
||||
return getPages().map((page) => ({
|
||||
slug: page.slugs,
|
||||
}));
|
||||
@@ -34,7 +32,7 @@ export async function generateStaticParams(): Promise<{ slug: string[] }[]> {
|
||||
export function generateMetadata({ params }: { params: { slug?: string[] } }) {
|
||||
const page = getPage(params.slug);
|
||||
|
||||
if (page == null) notFound();
|
||||
if (!page) notFound();
|
||||
|
||||
return {
|
||||
title: page.data.title,
|
||||
@@ -0,0 +1,8 @@
|
||||
import { allDocs, allMetas } from 'content-collections';
|
||||
import { loader } from 'fumadocs-core/source';
|
||||
import { createMDXSource } from '@fumadocs/content-collections';
|
||||
|
||||
export const { getPage, getPages, pageTree } = loader({
|
||||
baseUrl: '/docs',
|
||||
source: createMDXSource(allDocs, allMetas),
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineCollection, defineConfig } from '@content-collections/core';
|
||||
import {
|
||||
createMetaSchema,
|
||||
createDocSchema,
|
||||
transformMDX,
|
||||
} from '@fumadocs/content-collections/configuration';
|
||||
|
||||
const docs = defineCollection({
|
||||
name: 'docs',
|
||||
directory: 'content/docs',
|
||||
include: '**/*.mdx',
|
||||
schema: createDocSchema,
|
||||
transform: transformMDX,
|
||||
});
|
||||
|
||||
const metas = defineCollection({
|
||||
name: 'meta',
|
||||
directory: 'content/docs',
|
||||
include: '**/meta.json',
|
||||
schema: createMetaSchema,
|
||||
});
|
||||
|
||||
export default defineConfig({
|
||||
collections: [docs, metas],
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
import { withContentCollections } from '@content-collections/next';
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const config = {
|
||||
reactStrictMode: true,
|
||||
};
|
||||
|
||||
export default withContentCollections(config);
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
"incremental": true,
|
||||
"paths": {
|
||||
"@/*": ["./*"],
|
||||
"contentlayer/generated": ["./.contentlayer/generated"]
|
||||
"content-collections": ["./.content-collections/generated"]
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
@@ -1,14 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useMDXComponent } from 'next-contentlayer/hooks';
|
||||
import defaultComponents from 'fumadocs-ui/mdx';
|
||||
|
||||
const components = {
|
||||
...defaultComponents,
|
||||
};
|
||||
|
||||
export function Content({ code }: { code: string }) {
|
||||
const MDX = useMDXComponent(code);
|
||||
|
||||
return <MDX components={components} />;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { allDocs, allMeta } from 'contentlayer/generated';
|
||||
import { createContentlayerSource } from 'fumadocs-contentlayer';
|
||||
import { loader } from 'fumadocs-core/source';
|
||||
|
||||
export const { getPage, pageTree, getPages } = loader({
|
||||
baseUrl: '/docs',
|
||||
rootDir: 'docs',
|
||||
source: createContentlayerSource(allMeta, allDocs),
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
import { makeSource } from 'contentlayer/source-files';
|
||||
import { defaultConfig } from 'fumadocs-contentlayer/configuration';
|
||||
|
||||
export default makeSource(defaultConfig);
|
||||
@@ -1,8 +0,0 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const config = {
|
||||
reactStrictMode: true,
|
||||
};
|
||||
|
||||
const { withContentlayer } = require('next-contentlayer');
|
||||
|
||||
module.exports = withContentlayer(config);
|
||||
@@ -3,7 +3,7 @@ import { defineConfig } from 'tsup';
|
||||
import corePkg from '../core/package.json';
|
||||
import uiPkg from '../ui/package.json';
|
||||
import mdxPkg from '../mdx/package.json';
|
||||
import contentlayerPkg from '../contentlayer/package.json';
|
||||
import contentCollectionsPkg from '../content-collections/package.json';
|
||||
|
||||
writeFileSync(
|
||||
'./versions.json',
|
||||
@@ -11,7 +11,7 @@ writeFileSync(
|
||||
'fumadocs-core': corePkg.version,
|
||||
'fumadocs-ui': uiPkg.version,
|
||||
'fumadocs-mdx': mdxPkg.version,
|
||||
'fumadocs-contentlayer': contentlayerPkg.version,
|
||||
'@fumadocs/content-collections': contentCollectionsPkg.version,
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"fumadocs-core":"12.2.0","fumadocs-ui":"12.2.0","fumadocs-mdx":"8.2.32","fumadocs-contentlayer":"1.1.34"}
|
||||
{"fumadocs-core":"12.3.4","fumadocs-ui":"12.3.4","fumadocs-mdx":"8.2.33","@fumadocs/content-collections":"0.0.0"}
|
||||
Generated
+11
-1006
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user