@@ -9,7 +9,7 @@ image: https://nextra.site/og?title=Nextra%204%0AApp%20Router%20/%20Turbopack
9
9
tags : [react, nextjs, nextra, react-compiler, rsc, app-router, turbopack, pagefind, i18n]
10
10
---
11
11
12
- import { Button , FileTree , Steps } from ' nextra/components'
12
+ import { Button , FileTree , Steps , Tabs } from ' nextra/components'
13
13
import BlogV3BundleSize from ' public/blog-assets/nextra-4/blog-v3-bundle-size.mdx'
14
14
import BlogV4BundleSize from ' public/blog-assets/nextra-4/blog-v4-bundle-size.mdx'
15
15
import DocsV3BundleSize from ' public/blog-assets/nextra-4/docs-v3-bundle-size.mdx'
@@ -267,13 +267,13 @@ Previously theme config options now should be passed as `props` for `<Layout>`,
267
267
268
268
## New Search Engine – Pagefind
269
269
270
- Search engine was migrated from [ FlexSearch] ( https://github.com/nextapps-de/flexsearch ) written in
271
- JavaScript to Rust-powered [ Pagefind] ( https://pagefind.app ) .
270
+ The search engine has been migrated from [ FlexSearch] ( https://github.com/nextapps-de/flexsearch ) ,
271
+ which is written in JavaScript to the Rust-powered [ Pagefind] ( https://pagefind.app ) .
272
272
273
273
### Benefits
274
274
275
275
Pagefind is ** significantly** faster and delivers ** far superior** search results compared to
276
- FlexSearch. Here are some examples that previously didn' t work in earlier versions of Nextra:
276
+ FlexSearch. Here are some examples that didn’ t work in earlier versions of Nextra:
277
277
278
278
1 . Indexing remote MDX.
279
279
@@ -365,23 +365,30 @@ FlexSearch. Here are some examples that previously didn't work in earlier versio
365
365
New search engine requires few steps to setup:
366
366
367
367
<Steps >
368
- <h4 >Instal ` pagefind ` as ` devDependency ` </h4 >
368
+ <h4 >Install ` pagefind ` as a dev dependency </h4 >
369
369
``` sh npm2yarn
370
370
npm i -D pagefind
371
371
```
372
- <h4 >Add ` postbuild ` script</h4 >
372
+ <h4 >Add a ` postbuild ` script</h4 >
373
373
374
374
Pagefind indexes ` .html ` pages and search indexing should be done after building your application:
375
375
376
- ``` json filename="package.json" {4}
376
+ <Tabs items = { [' Server builds' , ' Static exports' ]} >
377
+ <Tabs.Tab >
378
+ ``` json filename="package.json" {2}
379
+ "scripts" : {
380
+ "postbuild" : " pagefind --site .next/server/app --output-path public/_pagefind"
381
+ }
382
+ ```
383
+ </Tabs.Tab >
384
+ <Tabs.Tab >
385
+ ``` json filename="package.json" {2}
377
386
"scripts" : {
378
- "dev" : " next --turbopack" ,
379
- "build" : " next build" ,
380
- "postbuild" : " pagefind --site .next/server/app --output-path public/_pagefind" ,
381
- // Or if you use Next.js' Static Exports
382
387
"postbuild" : " pagefind --site .next/server/app --output-path out/_pagefind"
383
388
}
384
389
```
390
+ </Tabs.Tab >
391
+ </Tabs >
385
392
386
393
<h4 >Enable ` pre ` /` post ` scripts (_ optional_ )</h4 >
387
394
@@ -402,7 +409,7 @@ enable-pre-post-scripts=true
402
409
403
410
<h4 >Add ` _pagefind/ ` directory to ` .gitignore ` file</h4 >
404
411
405
- You don' t need to commit ` _pagefind/ ` directory to your git repository, he should be always newly
412
+ You don’ t need to commit ` _pagefind/ ` directory to your Git repository, as it is always newly
406
413
generated.
407
414
408
415
``` text filename=".gitignore" {3}
@@ -414,8 +421,8 @@ _pagefind/
414
421
<h4 >Use ` <Search> ` component in your custom theme</h4 >
415
422
416
423
Search from ` nextra-theme-docs ` was exported in ` nextra/components ` . With this change
417
- ` nextra-theme-blog ` received search feature too. And you can benefit from it as well in your custom
418
- themes.
424
+ ` nextra-theme-blog ` now also supports search. You can take advantage of this feature as well in your
425
+ custom themes.
419
426
420
427
``` jsx filename="app/layout.jsx" {1,8}
421
428
import { Search } from ' nextra/components'
@@ -443,10 +450,8 @@ Thanks to server components, we no longer need to ship to client translation dic
443
450
according translation as ` props ` to ` <Layout> ` , ` <Banner> ` , ` <Footer> ` , etc. components in
444
451
` app/[lang]/layout.jsx ` .
445
452
446
- ### Example
447
-
448
- Below an example of server components i18n using ` nextra-theme-docs ` , but the same approach should
449
- be applied for your custom theme:
453
+ Below is an example of server components i18n using ` nextra-theme-docs ` , but the same approach
454
+ should be applied to your custom theme:
450
455
451
456
<ExampleLayoutForI18nDocsTheme />
452
457
0 commit comments