Skip to content

Commit fa97936

Browse files
authored
Update Docusaurus to v3 (#4774)
* Update Docusaurus packages * Rename DS config file * Update DS config file to TS syntax * Add DS faster package * Only transpile codeblocks in CI * Enable "faster" build tools * Fix broken anchor links * Update DS + TS config to speed up TS compilation * Build RTK so types are available * Fix more broken anchors * Fix revert of remark-ts-tools * Convert sidebars file to TS * Use remark-ts-tools 2.0
1 parent 4f3bc9f commit fa97936

19 files changed

+2280
-1901
lines changed

docs/api/createAsyncThunk.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ An object with the following optional fields:
108108

109109
- `condition(arg, { getState, extra } ): boolean | Promise<boolean>`: a callback that can be used to skip execution of the payload creator and all action dispatches, if desired. See [Canceling Before Execution](#canceling-before-execution) for a complete description.
110110
- `dispatchConditionRejection`: if `condition()` returns `false`, the default behavior is that no actions will be dispatched at all. If you still want a "rejected" action to be dispatched when the thunk was canceled, set this flag to `true`.
111-
- `idGenerator(arg): string`: a function to use when generating the `requestId` for the request sequence. Defaults to use [nanoid](./otherExports.mdx/#nanoid), but you can implement your own ID generation logic.
111+
- `idGenerator(arg): string`: a function to use when generating the `requestId` for the request sequence. Defaults to use [nanoid](./otherExports.mdx#nanoid), but you can implement your own ID generation logic.
112112
- `serializeError(error: unknown) => any` to replace the internal `miniSerializeError` method with your own serialization logic.
113113
- `getPendingMeta({ arg, requestId }, { getState, extra }): any`: a function to create an object that will be merged into the `pendingAction.meta` field.
114114

docs/api/createEntityAdapter.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ const globalizedSelectors = booksAdapter.getSelectors((state) => state.books, {
341341
})
342342
```
343343

344-
If no instance is passed, it will default to [`createDraftSafeSelector`](./createSelector#createDraftSafeSelector).
344+
If no instance is passed, it will default to [`createDraftSafeSelector`](./createSelector.mdx#createdraftsafeselector).
345345

346346
:::
347347

docs/api/createSlice.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ As a result, there are two ways of getting final selectors:
498498

499499
#### `selectors`
500500

501-
Most commonly, the slice is reliably mounted under its [`reducerPath`](#reducerPath).
501+
Most commonly, the slice is reliably mounted under its [`reducerPath`](#reducerpath).
502502

503503
Following this, the slice has a `selectSlice` selector attached, which assumes that the slice is located under `rootState[slice.reducerPath]`.
504504

docs/rtk-query/api/createApi.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export type QueryReturnValue<T = unknown, E = unknown, M = unknown> =
144144
145145
[summary](docblock://query/createApi.ts?token=CreateApiOptions.endpoints)
146146
147-
See [Anatomy of an endpoint](#anatomy-of-an-endpoint) for details on individual properties.
147+
See [Endpoint Definition Parameters](#endpoint-definition-parameters) for details on individual properties.
148148
149149
#### Query endpoint definition
150150

docs/rtk-query/internal/buildMiddleware/invalidationByTags.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const handler: ApiMiddlewareInternalHandler = (action, mwApi) => {
6363
1. `invalidateTags()` initiates:
6464
1. invalidateTags function is called with a list of tags generated from the action metadata
6565
2. in the case of a [queryThunk] resolution an empty set of tags is always provided
66-
2. The tags calculated are added to the list of pending tags to invalidate (see [delayed](#Delayed))
66+
2. The tags calculated are added to the list of pending tags to invalidate (see [delayed](#delayed))
6767
3. (optional: 'Delayed') the invalidateTags function is ended if the `apiSlice.invalidationBehavior` is set to "delayed" and there are any pending thunks/queries running in that `apiSlice`
6868
4. Pending tags are reset to an empty list, if there are no tags the function ends here
6969
5. Selects all `{ endpointName, originalArgs, queryCacheKey }` combinations that would be invalidated by a specific set of tags.

docs/rtk-query/overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default function App() {
179179

180180
## Further Information
181181

182-
See the [**RTK Query Quick Start tutorial**](../tutorials/rtk-query.mdx/) for examples of how to add RTK Query to a project that uses Redux Toolkit, set up an "API slice" with endpoint definitions, and how to use the auto-generated React hooks in your components.
182+
See the [**RTK Query Quick Start tutorial**](../tutorials/rtk-query.mdx) for examples of how to add RTK Query to a project that uses Redux Toolkit, set up an "API slice" with endpoint definitions, and how to use the auto-generated React hooks in your components.
183183

184184
The [**RTK Query usage guide section**](./usage/queries.mdx) has information on topics like [querying data](./usage/queries.mdx), [using mutations to send updates to the server](./usage/mutations.mdx), [streaming cache updates](./usage/streaming-updates.mdx), and much more.
185185

docs/rtk-query/usage-with-typescript.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ function MaybePost({ id }: { id?: number }) {
527527

528528
## Type safe error handling
529529

530-
When an error is gracefully provided from a [`base query`](./api/createApi.mdx#baseQuery), RTK query will provide the error
530+
When an error is gracefully provided from a [`base query`](./api/createApi.mdx#basequery), RTK query will provide the error
531531
directly. If an unexpected error is thrown by user code rather than a handled error,
532532
that error will be transformed into a `SerializedError` shape. Users should make sure that they are checking which kind of error they are dealing with before attempting to access its properties. This can be done in a type safe manner either
533533
by using a type guard, e.g. by checking for [discriminated properties](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#the-in-operator-narrowing),
@@ -613,7 +613,7 @@ function PostDetail() {
613613
<div>{errMsg}</div>
614614
</div>
615615
)
616-
}
616+
}
617617
// you can access all properties of `SerializedError` here
618618
return <div>{error.message}</div>
619619
}

docs/rtk-query/usage/cache-behavior.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ The Redux docs have always recommended [keeping data in a normalized lookup tabl
403403
404404
There are a couple additional points that can help here:
405405
406-
- The generated query hooks have [a `selectFromResult` option](../api/created-api/hooks.mdx#selectfromresult) that allow components to read individual pieces of data from a query result. As an example, a `<TodoList>` component might call `useTodosQuery()`, and each individual `<TodoListItem>` could use the same query hook but select from the result to get the right todo object.
406+
- The generated query hooks have [a `selectFromResult` option](../api/created-api/hooks.mdx#usequery) that allow components to read individual pieces of data from a query result. As an example, a `<TodoList>` component might call `useTodosQuery()`, and each individual `<TodoListItem>` could use the same query hook but select from the result to get the right todo object.
407407
- You can use the [`transformResponse` endpoint option](../api/createApi.mdx#transformresponse) to modify the fetched data so that it's [stored in a different shape](./customizing-queries.mdx#customizing-query-responses-with-transformresponse), such as using `createEntityAdapter` to normalize the data _for this one response_ before it's inserted into the cache.
408408
409409
### Further information

docs/rtk-query/usage/customizing-queries.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ import type {
690690
FetchArgs,
691691
FetchBaseQueryError,
692692
} from '@reduxjs/toolkit/query'
693-
import type { FetchBaseQueryMeta } from '@reduxjs/toolkit/dist/query/fetchBaseQuery'
693+
import type { FetchBaseQueryMeta } from '@reduxjs/toolkit/query'
694694
import { uuid } from './idGenerator'
695695

696696
// highlight-start
@@ -980,7 +980,7 @@ You could also try creating a custom base query that uses the SDK, and define en
980980

981981
In certain scenarios, you may wish to have a `query` or `mutation` where sending a request or returning data is not relevant for the situation. Such a scenario would be to leverage the `invalidatesTags` property to force re-fetch specific `tags` that have been provided to the cache.
982982

983-
See also [`providing errors to the cache`](./automated-refetching.mdx#providing-data-to-the-cache) to see additional detail and an example for such a scenario to 'refetch errored queries'.
983+
See also ["providing errors to the cache"](./automated-refetching.mdx#providing-errors-to-the-cache) to see additional detail and an example for such a scenario to 'refetch errored queries'.
984984

985985
```ts title="Using a no-op queryFn"
986986
// file: types.ts noEmit

docs/rtk-query/usage/error-handling.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ There are quite a few ways that you can manage your errors, and in some cases, y
7676

7777
:::tip
7878

79-
Redux Toolkit has [action matching utilities](../../api/matching-utilities.mdx#matching-utilities) that we can leverage for additional custom behaviors.
79+
Redux Toolkit has [action matching utilities](../../api/matching-utilities.mdx) that we can leverage for additional custom behaviors.
8080

8181
:::
8282

docs/tsconfig.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,23 @@
1010
"noEmitOnError": false,
1111
"strict": true,
1212
"removeComments": false,
13-
"module": "ESNext",
14-
"target": "ESNext",
13+
"module": "ES2020",
14+
"target": "ES2020",
1515
"allowJs": true,
1616
"checkJs": true,
1717
"alwaysStrict": false,
1818
"baseUrl": "..",
1919
"jsx": "preserve",
20+
"traceResolution": false,
21+
"explainFiles": false,
2022
"paths": {
21-
"react": ["../node_modules/@types/react"],
22-
"react-dom": ["../node_modules/@types/react-dom"],
23-
"@reduxjs/toolkit": ["packages/toolkit/src/index.ts"],
24-
"@reduxjs/toolkit/query": ["packages/toolkit/src/query/index.ts"],
23+
"react": ["docs/node_modules/@types/react"],
24+
"react-dom": ["docs/node_modules/@types/react-dom"],
25+
"@reduxjs/toolkit": ["packages/toolkit/dist/index.d.ts"],
26+
"@reduxjs/toolkit/query": ["packages/toolkit/dist/query/index.d.ts"],
2527
"@reduxjs/toolkit/query/react": [
26-
"packages/toolkit/src/query/react/index.ts"
28+
"packages/toolkit/dist/query/react/index.d.ts"
2729
],
28-
"@reduxjs/toolkit/dist/query/*": ["packages/toolkit/src/query/*"],
2930
"@virtual/*": ["docs/virtual/*"],
3031
"your-cool-library": ["docs/virtual/your-cool-library/index.ts"],
3132
"redux-logger": ["docs/virtual/redux-logger/index.ts"],

docs/usage/migrating-rtk-2.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ yield takeEvery(todoAdded.type, saga)
897897

898898
### Custom slice reducer creators
899899

900-
With the addition of the [callback syntax for createSlice](#callback-syntax-for-createslicereducers), the [suggestion](https://github.com/reduxjs/redux-toolkit/issues/3837) was made to enable custom slice reducer creators. These creators would be able to:
900+
With the addition of the [callback syntax for createSlice](#createslicereducers-callback-syntax-and-thunk-support), the [suggestion](https://github.com/reduxjs/redux-toolkit/issues/3837) was made to enable custom slice reducer creators. These creators would be able to:
901901

902902
- Modify reducer behavior by adding case or matcher reducers
903903
- Attach actions (or any other useful functions) to `slice.actions`

docs/usage/usage-with-typescript.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ type AtLeastOneUserField = AtLeastOne<User>
413413
414414
### Typing Async Thunks Inside `createSlice`
415415
416-
As of 2.0, `createSlice` allows [defining thunks inside of `reducers` using a callback syntax](../api/createSlice.mdx/#the-reducers-creator-callback-notation).
416+
As of 2.0, `createSlice` allows [defining thunks inside of `reducers` using a callback syntax](../api/createSlice.mdx#the-reducers-creator-callback-notation).
417417
418418
Typing for the `create.asyncThunk` method works in the same way as [`createAsyncThunk`](#createasyncthunk), with one key difference.
419419

netlify.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build]
22
base = "website"
33
publish = "build"
4-
command = "yarn run netlify-build && ls && cp _redirects ./build"
4+
command = "pushd ../packages/toolkit && yarn build && popd && yarn run netlify-build && ls && cp _redirects ./build"
55
ignore = "git diff --quiet HEAD^ HEAD docs website"
66

77
[build.environment]

website/docusaurus.config.js website/docusaurus.config.ts

+31-23
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
// site configuration options.
2-
const { resolve } = require('path')
3-
const {
4-
linkDocblocks,
5-
transpileCodeblocks,
6-
} = require('remark-typescript-tools')
2+
import { resolve } from 'path'
3+
import { linkDocblocks, transpileCodeblocks } from 'remark-typescript-tools'
4+
import type { Options, ThemeConfig } from '@docusaurus/preset-classic'
5+
import type { Config } from '@docusaurus/types'
6+
import type { Options as UmamiOptions } from '@dipakparmar/docusaurus-plugin-umami'
7+
import type { Options as RSDoctorOptions } from '@docusaurus/plugin-rsdoctor'
78

8-
module.exports = {
9+
const config: Config = {
10+
future: {
11+
experimental_faster: true,
12+
},
913
presets: [
1014
[
1115
'@docusaurus/preset-classic',
1216
{
1317
docs: {
1418
path: '../docs',
15-
sidebarPath: require.resolve('./sidebars.json'),
19+
sidebarPath: require.resolve('./sidebars'),
1620
showLastUpdateTime: true,
1721
routeBasePath: '/',
1822
include: [
@@ -35,21 +39,24 @@ module.exports = {
3539
},
3640
},
3741
],
38-
[
39-
transpileCodeblocks,
40-
{
41-
compilerSettings: {
42-
tsconfig: resolve(__dirname, '../docs/tsconfig.json'),
43-
externalResolutions: {},
44-
},
45-
},
46-
],
47-
],
42+
// Only transpile codeblocks in CI, as it's slow
43+
process.env.CI
44+
? [
45+
transpileCodeblocks,
46+
{
47+
compilerSettings: {
48+
tsconfig: resolve(__dirname, '../docs/tsconfig.json'),
49+
externalResolutions: {},
50+
},
51+
},
52+
]
53+
: null,
54+
].filter(Boolean),
4855
},
4956
theme: {
5057
customCss: require.resolve('./src/css/custom.css'),
5158
},
52-
},
59+
} satisfies Options,
5360
],
5461
],
5562
projectName: 'redux-toolkit',
@@ -177,21 +184,22 @@ module.exports = {
177184
appId: 'CK59DFV0FC',
178185
apiKey: '98e886dfbcde7f7e8ec8d7ff1c2c34c8',
179186
indexName: 'redux-starter-kit',
180-
algoliaOptions: {},
181187
},
182-
},
188+
} satisfies ThemeConfig,
183189
plugins: [
184190
[
185191
'@dipakparmar/docusaurus-plugin-umami',
186-
/** @type {import('@dipakparmar/docusaurus-plugin-umami').Options} */
187-
({
192+
{
188193
websiteID: '616c102e-05dd-4a74-b63e-01bb52f1bc6c',
189194
analyticsDomain: 'redux-docs-umami.up.railway.app',
190195
scriptName: 'script.js',
191196
dataAutoTrack: true,
192197
dataDoNotTrack: true,
193198
dataCache: true,
194-
}),
199+
} satisfies UmamiOptions,
195200
],
201+
process.env.RSDOCTOR === 'true' && ['rsdoctor', {}],
196202
],
197203
}
204+
205+
export default config

website/package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "website",
33
"scripts": {
4+
"dev": "docusaurus start",
45
"start": "docusaurus start",
56
"build": "docusaurus build",
67
"netlify-build": "yarn install && yarn build",
@@ -10,13 +11,12 @@
1011
},
1112
"dependencies": {
1213
"@dipakparmar/docusaurus-plugin-umami": "^2.0.6",
13-
"@docusaurus/core": "2.1.0",
14-
"@docusaurus/preset-classic": "2.1.0",
14+
"@docusaurus/core": "3.6.3",
15+
"@docusaurus/preset-classic": "3.6.3",
1516
"classnames": "^2.2.6",
1617
"react": "^19.0.0",
1718
"react-dom": "^19.0.0",
1819
"react-lite-youtube-embed": "^2.0.3",
19-
"remark-typescript-tools": "^1.1.0",
2020
"typescript": "^5.5.4"
2121
},
2222
"browserslist": {
@@ -32,7 +32,9 @@
3232
]
3333
},
3434
"devDependencies": {
35+
"@docusaurus/faster": "^3.6.3",
3536
"netlify-plugin-cache": "^1.0.3",
36-
"prettier": "^3.2.5"
37+
"prettier": "^3.2.5",
38+
"remark-typescript-tools": "2.0.0-alpha.1"
3739
}
3840
}

0 commit comments

Comments
 (0)