Skip to content

Commit

Permalink
fix: search index file not found when i18n is not set (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 authored Dec 31, 2023
1 parent f05e2cf commit 0f79348
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-apples-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rspress/core': patch
---

fix: search index file not found when i18n is not set
5 changes: 4 additions & 1 deletion packages/core/src/node/runtimeModule/siteData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export async function siteDataVMPlugin(context: FactoryContext) {
indexHashByLang[lang] = indexHash;
await fs.ensureDir(TEMP_DIR);
await fs.writeFile(
path.join(TEMP_DIR, `${SEARCH_INDEX_NAME}.${lang}.${indexHash}.json`),
path.join(
TEMP_DIR,
`${SEARCH_INDEX_NAME}${lang ? `.${lang}` : ''}.${indexHash}.json`,
),
stringfiedIndex,
);
}),
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/node/searchIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { UserConfig, isSCM, SEARCH_INDEX_NAME } from '@rspress/shared';
import { logger } from '@rspress/shared/logger';
import { isProduction, OUTPUT_DIR, TEMP_DIR } from './constants';

export function getSearchIndexFilename(indexHash: string) {
return `${SEARCH_INDEX_NAME}.${indexHash}.json`;
}

export async function writeSearchIndex(config: UserConfig) {
if (config?.search === false) {
return;
Expand Down

0 comments on commit 0f79348

Please sign in to comment.