mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 23:49:51 +00:00
Remove deprecated usages
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"fumadocs-core": major
|
||||
---
|
||||
|
||||
Remove `cwd` option from `remark-dynamic-content`
|
||||
|
||||
why: Use `cwd` from vfile
|
||||
|
||||
migrate: Pass the `cwd` option from remark instead
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
"fumadocs-core": major
|
||||
---
|
||||
|
||||
Remove support for `getTableOfContentsFromPortableText`
|
||||
|
||||
why: Sanity integration should be provided by 3rd party integrations
|
||||
|
||||
migrate: Use built-in sources, or write a custom implementation
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
"fumadocs-ui": major
|
||||
---
|
||||
|
||||
Replace `nav.links` option with secondary links
|
||||
|
||||
why: A more straightforward API design
|
||||
|
||||
migrate:
|
||||
|
||||
```diff
|
||||
<DocsLayout
|
||||
+ links={[
|
||||
+ {
|
||||
+ type: 'secondary',
|
||||
+ text: 'Github',
|
||||
+ url: 'https://github.com',
|
||||
+ icon: <GithubIcon />,
|
||||
+ external: true,
|
||||
+ },
|
||||
+ ]}
|
||||
- nav={{
|
||||
- links: [
|
||||
- {
|
||||
- icon: <GithubIcon />,
|
||||
- href: 'https://github.com',
|
||||
- label: 'Github',
|
||||
- external: true,
|
||||
- },
|
||||
- ],
|
||||
- }}
|
||||
>
|
||||
{children}
|
||||
</DocsLayout>
|
||||
```
|
||||
@@ -7,13 +7,6 @@ import { visit } from 'unist-util-visit';
|
||||
const regex = /^\|reference:(?<path>.+)\|/;
|
||||
|
||||
export interface RemarkDynamicContentOptions {
|
||||
// todo: Remove in next major
|
||||
/**
|
||||
* @defaultValue `vfile.cwd`
|
||||
* @deprecated use the `cwd` option from remark instead
|
||||
* */
|
||||
cwd?: string;
|
||||
|
||||
/** @defaultValue true */
|
||||
trim?: boolean;
|
||||
|
||||
@@ -46,7 +39,7 @@ export function remarkDynamicContent(
|
||||
} = options;
|
||||
|
||||
return (tree, file) => {
|
||||
const cwd = options.cwd ?? file.cwd;
|
||||
const cwd = file.cwd;
|
||||
|
||||
visit(tree, filter, (node) => {
|
||||
const canReplace = 'value' in node && typeof node.value === 'string';
|
||||
|
||||
@@ -18,7 +18,6 @@ export type RemarkInstallOptions = Partial<{
|
||||
packageManagers: PackageManager[];
|
||||
}>;
|
||||
|
||||
// todo: Extract to separate package
|
||||
/**
|
||||
* It generates the following structure from a code block with `package-install` as language
|
||||
*
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument -- no accurate type */
|
||||
import Slugger from 'github-slugger';
|
||||
import type { TableOfContents, TOCItemType } from './get-toc';
|
||||
|
||||
const slugger = new Slugger();
|
||||
|
||||
interface Block {
|
||||
_type: string;
|
||||
children?: Block[];
|
||||
style?: string;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
// todo: Remove in next major
|
||||
/**
|
||||
* Parse TOC from portable text (Sanity)
|
||||
*
|
||||
* @param value - Blocks
|
||||
* @param slugFn - A function that generates slug from title
|
||||
* @deprecated Sanity is no longer supported
|
||||
*/
|
||||
export function getTableOfContentsFromPortableText(
|
||||
value: any,
|
||||
): TableOfContents {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new Error('Invalid body type');
|
||||
}
|
||||
|
||||
slugger.reset();
|
||||
const result: TOCItemType[] = [];
|
||||
|
||||
for (const block of value) {
|
||||
dfs(block, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function dfs(block: Block, list: TOCItemType[]): void {
|
||||
if (block.style && block.style.length === 2 && block.style.startsWith('h')) {
|
||||
const depth = Number(block.style[1]);
|
||||
|
||||
if (Number.isNaN(depth)) return;
|
||||
const text = flattenNode(block);
|
||||
|
||||
list.push({
|
||||
title: text,
|
||||
url: slugger.slug(text),
|
||||
depth,
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
block.children?.forEach((child) => {
|
||||
dfs(child, list);
|
||||
});
|
||||
}
|
||||
|
||||
function flattenNode(block: Block): string {
|
||||
let text = '';
|
||||
|
||||
if (block._type === 'span') {
|
||||
return block.text ?? '';
|
||||
}
|
||||
|
||||
block.children?.forEach((child) => {
|
||||
text += flattenNode(child);
|
||||
});
|
||||
|
||||
return text;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
export * from './get-toc';
|
||||
export { getTableOfContentsFromPortableText } from './get-toc-sanity';
|
||||
export * from './page-tree-utils';
|
||||
export * as PageTree from './page-tree';
|
||||
export * from './git-api';
|
||||
|
||||
@@ -23,13 +23,6 @@ import { isActive } from '@/utils/shared';
|
||||
import { buttonVariants } from '@/theme/variants';
|
||||
import type { LinkItem } from '@/layout';
|
||||
|
||||
export interface NavLinkProps {
|
||||
icon: ReactNode;
|
||||
href: string;
|
||||
label: string;
|
||||
external?: boolean;
|
||||
}
|
||||
|
||||
export interface NavProps {
|
||||
title?: ReactNode;
|
||||
|
||||
@@ -41,12 +34,6 @@ export interface NavProps {
|
||||
|
||||
items: LinkItem[];
|
||||
|
||||
// todo: Remove in next major
|
||||
/**
|
||||
* @deprecated Use `LayoutOptions.links` option instead
|
||||
*/
|
||||
links?: NavLinkProps[];
|
||||
|
||||
enableSidebar: boolean;
|
||||
|
||||
/**
|
||||
@@ -140,7 +127,7 @@ export function Nav({
|
||||
}),
|
||||
)}
|
||||
>
|
||||
{item.icon}
|
||||
{item.icon ?? item.text}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { PageTree } from 'fumadocs-core/server';
|
||||
import type { ReactNode, HTMLAttributes } from 'react';
|
||||
import type { NavProps, NavLinkProps } from './components/nav';
|
||||
import type { NavProps } from './components/nav';
|
||||
import { replaceOrDefault } from './utils/shared';
|
||||
import { cn } from './utils/cn';
|
||||
import type { SidebarProps } from './components/sidebar';
|
||||
@@ -60,7 +60,7 @@ export function Layout({
|
||||
links = [],
|
||||
children,
|
||||
}: BaseLayoutProps): React.ReactElement {
|
||||
const finalLinks = getLinks(links, nav.links, nav.githubUrl);
|
||||
const finalLinks = getLinks(links, nav.githubUrl);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -85,7 +85,7 @@ export function DocsLayout({
|
||||
}: DocsLayoutProps): React.ReactElement {
|
||||
const sidebarEnabled = sidebar.enabled ?? true;
|
||||
const sidebarCollapsible = sidebarEnabled && (sidebar.collapsible ?? true);
|
||||
const finalLinks = getLinks(links, nav.links, nav.githubUrl);
|
||||
const finalLinks = getLinks(links, nav.githubUrl);
|
||||
|
||||
return (
|
||||
<TreeContextProvider tree={tree}>
|
||||
@@ -119,11 +119,7 @@ export function DocsLayout({
|
||||
);
|
||||
}
|
||||
|
||||
function getLinks(
|
||||
links?: LinkItem[],
|
||||
iconLinks?: NavLinkProps[],
|
||||
githubUrl?: string,
|
||||
): LinkItem[] {
|
||||
function getLinks(links?: LinkItem[], githubUrl?: string): LinkItem[] {
|
||||
let result = links ?? [];
|
||||
|
||||
if (githubUrl)
|
||||
@@ -142,17 +138,5 @@ function getLinks(
|
||||
},
|
||||
];
|
||||
|
||||
if (iconLinks)
|
||||
result = [
|
||||
...result,
|
||||
...iconLinks.map<LinkItem>((link) => ({
|
||||
type: 'secondary',
|
||||
text: link.label,
|
||||
url: link.href,
|
||||
icon: link.icon,
|
||||
external: link.external,
|
||||
})),
|
||||
];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user