Skip to content

Commit

Permalink
Merge branch 'core' into 404-500
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri POSTOLOV committed Jul 28, 2022
2 parents 0e404e2 + cc1379c commit 443a23b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-panthers-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nextra': patch
---

fix `Hydration failed because the initial UI...` while modifying `meta.json` on dev env and react 18
5 changes: 5 additions & 0 deletions .changeset/silent-games-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nextra': patch
---

chore: remove redundant check for `MARKDOWN_EXTENSION_REGEX.test(filename)` in loader
32 changes: 9 additions & 23 deletions packages/nextra/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { parseFileName } from './utils'
import { compileMdx } from './compile'
import { getPageMap, findPagesDir } from './page-map'
import { collectFiles, collectMdx } from './plugin'
import {
MARKDOWN_EXTENSION_REGEX,
IS_PRODUCTION,
DEFAULT_LOCALE
} from './constants'
import { IS_PRODUCTION, DEFAULT_LOCALE } from './constants'

// TODO: create this as a webpack plugin.
const indexContentEmitted = new Set<string>()
Expand Down Expand Up @@ -86,23 +82,14 @@ async function loader(
defaultLocale
)

if (IS_PRODUCTION) {
// We only add meta files as dependencies for production build,
// so we can do incremental builds.
Object.entries(fileMap).forEach(([filePath, { name, meta, locale }]) => {
if (
name === 'meta.json' &&
meta &&
(!fileLocale || locale === fileLocale)
) {
context.addDependency(filePath)
}
})
} else {
// Add the entire directory `pages` as the dependency,
// so we can generate the correct page map.
context.addContextDependency(pagesDir)
for (const [filePath, { name, locale }] of Object.entries(fileMap)) {
if (name === 'meta.json' && (!fileLocale || locale === fileLocale)) {
context.addDependency(filePath)
}
}
// Add the entire directory `pages` as the dependency,
// so we can generate the correct page map.
context.addContextDependency(pagesDir)

// Extract frontMatter information if it exists
const { data, content } = grayMatter(source)
Expand Down Expand Up @@ -133,8 +120,7 @@ async function loader(
)

if (unstable_flexsearch) {
// We only add .MD and .MDX contents
if (MARKDOWN_EXTENSION_REGEX.test(filename) && data.searchable !== false) {
if (data.searchable !== false) {
addPage({
fileLocale: fileLocale || DEFAULT_LOCALE,
route,
Expand Down

0 comments on commit 443a23b

Please sign in to comment.