docs: update documentation websites (#5882)

* docs: update next.js to 14.0.4

* update docusaurus to v3.0.1

* update packages dependencies

* added engines

* update lock
This commit is contained in:
Shahed Nasser
2023-12-14 20:43:16 +02:00
committed by GitHub
parent 2d127a4c67
commit 761d2e7a69
10 changed files with 394 additions and 847 deletions

View File

@@ -3,9 +3,6 @@ import bundleAnalyzer from "@next/bundle-analyzer"
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
experimental: {
serverActions: true,
},
async rewrites() { async rewrites() {
return { return {
fallback: [ fallback: [

View File

@@ -30,7 +30,7 @@
"jsdom": "^22.1.0", "jsdom": "^22.1.0",
"json-schema": "^0.4.0", "json-schema": "^0.4.0",
"json-stringify-pretty-compact": "^4.0.0", "json-stringify-pretty-compact": "^4.0.0",
"next": "13.4.19", "next": "^14",
"next-mdx-remote": "^4.4.1", "next-mdx-remote": "^4.4.1",
"openapi-sampler": "^1.3.1", "openapi-sampler": "^1.3.1",
"openapi-types": "^12.1.3", "openapi-types": "^12.1.3",
@@ -39,7 +39,7 @@
"react": "latest", "react": "latest",
"react-dom": "latest", "react-dom": "latest",
"react-instantsearch": "^7.0.1", "react-instantsearch": "^7.0.1",
"react-intersection-observer": "^9.5.2", "react-intersection-observer": "^9.5.3",
"react-tooltip": "^5.19.0", "react-tooltip": "^5.19.0",
"react-transition-group": "^4.4.5", "react-transition-group": "^4.4.5",
"slugify": "^1.6.6", "slugify": "^1.6.6",
@@ -52,5 +52,8 @@
"devDependencies": { "devDependencies": {
"@next/bundle-analyzer": "^13.4.19", "@next/bundle-analyzer": "^13.4.19",
"@types/jsdom": "^21.1.1" "@types/jsdom": "^21.1.1"
},
"engines": {
"node": ">=18.17.0"
} }
} }

View File

@@ -22,10 +22,11 @@
"@babel/preset-react": "^7.18.6", "@babel/preset-react": "^7.18.6",
"@cloudinary/react": "^1.11.2", "@cloudinary/react": "^1.11.2",
"@cloudinary/url-gen": "^1.9.2", "@cloudinary/url-gen": "^1.9.2",
"@docusaurus/core": "3.0.0", "@docusaurus/core": "3.0.1",
"@docusaurus/preset-classic": "3.0.0", "@docusaurus/preset-classic": "3.0.1",
"@docusaurus/remark-plugin-npm2yarn": "3.0.0", "@docusaurus/remark-plugin-npm2yarn": "3.0.1",
"@docusaurus/theme-mermaid": "^3.0.0", "@docusaurus/theme-mermaid": "3.0.1",
"@mdx-js/mdx": "3.0.0",
"@mdx-js/react": "3", "@mdx-js/react": "3",
"@medusajs/icons": "^1.0.0", "@medusajs/icons": "^1.0.0",
"@svgr/webpack": "6.2.1", "@svgr/webpack": "6.2.1",
@@ -64,9 +65,9 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-proposal-decorators": "^7.22.15", "@babel/plugin-proposal-decorators": "^7.22.15",
"@docusaurus/module-type-aliases": "3.0.0", "@docusaurus/module-type-aliases": "3.0.1",
"@docusaurus/tsconfig": "3.0.0", "@docusaurus/tsconfig": "3.0.1",
"@docusaurus/types": "3.0.0", "@docusaurus/types": "3.0.1",
"@types/react": "^18.2.0", "@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0", "@types/react-dom": "^18.2.0",
"@types/react-transition-group": "^4.4.6", "@types/react-transition-group": "^4.4.6",

View File

@@ -1,54 +0,0 @@
import React, { memo, useMemo } from "react"
import {
DocSidebarItemsExpandedStateProvider,
isActiveSidebarItem,
} from "@docusaurus/theme-common/internal"
import DocSidebarItem from "@theme/DocSidebarItem"
import type { PropSidebarItem } from "@docusaurus/plugin-content-docs"
import type { Props } from "@theme/DocSidebarItems"
function DocSidebarItems({ items, ...props }: Props): JSX.Element {
// This acts as a fix to a bug in docusaurus which should be part
// of an upcoming release.
function isVisibleSidebarItem(
item: PropSidebarItem,
activePath: string
): boolean {
switch (item.type) {
case "category":
return (
isActiveSidebarItem(item, activePath) ||
item.items.some((subItem) =>
isVisibleSidebarItem(subItem, activePath)
)
)
case "link":
// An unlisted item remains visible if it is active
return !item.unlisted || isActiveSidebarItem(item, activePath)
default:
return true
}
}
function useVisibleSidebarItems(
items: readonly PropSidebarItem[],
activePath: string
): PropSidebarItem[] {
return useMemo(
() => items.filter((item) => isVisibleSidebarItem(item, activePath)),
[items, activePath]
)
}
const visibleItems = useVisibleSidebarItems(items, props.activePath)
return (
<DocSidebarItemsExpandedStateProvider>
{visibleItems.map((item, index) => (
<DocSidebarItem key={index} item={item} index={index} {...props} />
))}
</DocSidebarItemsExpandedStateProvider>
)
}
// Optimize sidebar at each "level"
export default memo(DocSidebarItems)

View File

@@ -30,7 +30,7 @@
"docs-ui": "*", "docs-ui": "*",
"eslint-config-docs": "*", "eslint-config-docs": "*",
"mdast-util-toc": "^7.0.0", "mdast-util-toc": "^7.0.0",
"next": "13.4.13", "next": "^14",
"next-contentlayer": "^0.3.4", "next-contentlayer": "^0.3.4",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"postcss": "8.4.27", "postcss": "8.4.27",
@@ -47,5 +47,8 @@
"eslint": "^8.49.0", "eslint": "^8.49.0",
"react-docgen": "^7.0.1", "react-docgen": "^7.0.1",
"ts-node": "^10.9.1" "ts-node": "^10.9.1"
},
"engines": {
"node": ">=18.17.0"
} }
} }

View File

@@ -23,5 +23,8 @@
"tailwindcss": "3.3.3", "tailwindcss": "3.3.3",
"tsconfig": "*", "tsconfig": "*",
"turbo": "latest" "turbo": "latest"
},
"engines": {
"node": ">=18.17.0"
} }
} }

View File

@@ -80,6 +80,23 @@ export type ActionType = {
options?: ActionOptionsType options?: ActionOptionsType
} }
const findItem = (
section: SidebarItemType[],
item: Partial<SidebarItemType>,
checkChildren = true
): SidebarItemType | undefined => {
return section.find((i) => {
if (!item.path) {
return !i.path && i.title === item.title
} else {
return (
i.path === item.path ||
(checkChildren && i.children && findItem(i.children, item))
)
}
})
}
export const reducer = ( export const reducer = (
state: SidebarSectionItemsType, state: SidebarSectionItemsType,
{ type, items, options }: ActionType { type, items, options }: ActionType
@@ -87,9 +104,20 @@ export const reducer = (
const { const {
section = SidebarItemSections.TOP, section = SidebarItemSections.TOP,
parent, parent,
ignoreExisting = false,
indexPosition, indexPosition,
} = options || {} } = options || {}
if (!ignoreExisting) {
const selectedSection =
section === SidebarItemSections.BOTTOM ? state.bottom : state.top
items = items.filter((item) => !findItem(selectedSection, item))
}
if (!items.length) {
return state
}
switch (type) { switch (type) {
case "add": case "add":
return { return {
@@ -155,25 +183,7 @@ export const SidebarProvider = ({
return scrollableElement || window return scrollableElement || window
}, [scrollableElement]) }, [scrollableElement])
const findItemInSection = useCallback( const findItemInSection = useCallback(findItem, [])
(
section: SidebarItemType[],
item: Partial<SidebarItemType>,
checkChildren = true
): SidebarItemType | undefined => {
return section.find((i) => {
if (!item.path) {
return !i.path && i.title === item.title
} else {
return (
i.path === item.path ||
(checkChildren && i.children && findItemInSection(i.children, item))
)
}
})
},
[]
)
const getActiveItem = useCallback(() => { const getActiveItem = useCallback(() => {
if (activePath === null) { if (activePath === null) {
@@ -199,26 +209,8 @@ export const SidebarProvider = ({
ignoreExisting?: boolean ignoreExisting?: boolean
} }
) => { ) => {
const {
section = SidebarItemSections.TOP,
parent,
ignoreExisting = false,
} = options || {}
if (!ignoreExisting) {
const selectedSection =
section === SidebarItemSections.BOTTOM ? items.bottom : items.top
newItems = newItems.filter(
(item) => !findItemInSection(selectedSection, item)
)
}
if (!newItems.length) {
return
}
dispatch({ dispatch({
type: parent ? "update" : "add", type: options?.parent ? "update" : "add",
items: newItems, items: newItems,
options, options,
}) })

View File

@@ -6,7 +6,7 @@
"main": "base.js", "main": "base.js",
"dependencies": { "dependencies": {
"@babel/eslint-parser": "^7.22.15", "@babel/eslint-parser": "^7.22.15",
"@docusaurus/eslint-plugin": "latest", "@docusaurus/eslint-plugin": "3.0.1",
"@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0", "@typescript-eslint/parser": "^5.55.0",
"eslint-config-google": "^0.14.0", "eslint-config-google": "^0.14.0",

View File

@@ -7,6 +7,6 @@
"access": "public" "access": "public"
}, },
"dependencies": { "dependencies": {
"@docusaurus/tsconfig": "3.0.0" "@docusaurus/tsconfig": "3.0.1"
} }
} }

File diff suppressed because it is too large Load Diff