easyops-cn/docusaurus-search-local

Error: ENOENT: no such file or directory, open 'xxx\build\docs\v1\search-index-docs.json

Opened this issue · 3 comments

config

// @ts-check
// `@type` JSDoc annotations allow editor autocompletion and type checking
// (when paired with `@ts-check`).
// There are various equivalent ways to declare your Docusaurus config.
// See: https://docusaurus.io/docs/api/docusaurus-config

// Themes Config
import navbar from "./src/config/navbar.config";
import footer from "./src/config/footer.config";
import docs_config from "./src/config/docs.config";
import {themes} from "prism-react-renderer";

const theme = themes.vsDark;
const darkTheme = themes.jettwaveDark;

/** @type {import('@docusaurus/types').Config} */
const config = {
    title: "PowerNukkitX Docs",
    tagline: "Official Docs for PowerNukkitX Server Software",
    favicon: "img/logo/PNX_LOGO_sm.png",
    url: "https://docs.powernukkitx.com",
    baseUrl: "/",
    onBrokenLinks: 'throw',
    onBrokenMarkdownLinks: 'warn',
    organizationName: "PowerNukkitX",
    projectName: "Docs",
    trailingSlash: false,
    staticDirectories: ['static'],
    themes: [
        '@saucelabs/theme-github-codeblock',
        [
            require.resolve("@easyops-cn/docusaurus-search-local"),
            /** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */
            {
                hashed: true,
                docsRouteBasePath: ["/docs"],
                docsDir: ["docs"],
                searchContextByPaths: [
                    {
                        label: {
                            en: "PNX2.0 Document",
                            zh: "PNX2.0 文档",
                        },
                        path: "docs",
                    },
                ],
                hideSearchBarWithNoSearchContext: true,
            },
        ],
    ],
    i18n: {
        defaultLocale: "en",
        locales: ["en", "fr", "zh-CN"],
        localeConfigs: {
            en: {
                htmlLang: "en-US",
                label: 'English',
            },
            fr: {
                htmlLang: "fr-FR",
                label: 'Français',
            },
            "zh-CN": {
                htmlLang: "zh-CN",
                label: '简体中文',
            },
        },
    },
    plugins: [
        [
            '@docusaurus/plugin-client-redirects',
            {
                toExtensions: ['html']
            }
        ],
        'docusaurus-plugin-sass',
    ],
    scripts: [
        {
            src: "./src/js/wiki-version.js",
        },
    ],
    presets: [
        /** @type {import('@docusaurus/preset-classic').Options} */
        [
            '@docusaurus/preset-classic',
            ({
                docs: {
                    routeBasePath: '/docs',
                    sidebarPath: require.resolve('./sidebar.ts'),
                    editUrl: 'https://github.com/PowerNukkitX/PNX-Wiki/tree/master/',
                    showLastUpdateAuthor: true,
                    showLastUpdateTime: true,
                    editLocalizedFiles: true,
                    editCurrentVersion: true,
                    versions: {
                        current: {
                            label: 'v2',
                        },
                    },
                    lastVersion: 'current',
                },
                blog: {
                    showReadingTime: true,
                },
                theme: {
                    customCss: require.resolve('./src/css/custom.scss'),
                },
            }),
        ],
    ],
    /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
    themeConfig: {
        metadata: [{
            name: 'keywords',
            content: 'powernukkitx, documentation, pnx, docs, minecraft, server, software, bedrock, pe, be'
        }],
        colorMode: {
            defaultMode: 'dark',
            disableSwitch: false,
            respectPrefersColorScheme: true,
        },
        navbar: navbar,
        footer: footer,
        docs: docs_config,
        prism: {
            theme: theme,
            darkTheme: darkTheme,
            additionalLanguages: [
                "batch",
                "bash",
                "git",
                "java",
                "javastacktrace",
                "kotlin",
                "groovy",
                "log",
                "toml",
                "yaml",
                "properties",
            ],
        },
    },
};

export default config;

Referring to #212, it solved my problem by setting trailingSlash: true. whether is the bug reappeared?
I am using docusaurus version 3.3.2
docusaurus-search-local 0.41.0

We fixed this by returning trailingSlash to default (undefined). Luckily it looks like we don't need it to be true any more, but for others that use deployment methods that need that, this will be annoying.

This may have been related to this: facebook/docusaurus#10139
If you are having this issue, try upgrading to 3.4.0 and see if that resolves.