fix(theme): local search showDetailedList not working in windows (#2248)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/2253/head
烽宁 2 years ago committed by GitHub
parent e91e0f91b2
commit 8354f8fb86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,7 @@ import {
} from 'vue' } from 'vue'
import type { ModalTranslations } from '../../../../types/local-search' import type { ModalTranslations } from '../../../../types/local-search'
import { pathToFile } from '../../app/utils' import { pathToFile } from '../../app/utils'
import { slash } from '../../shared'
import { useData } from '../composables/data' import { useData } from '../composables/data'
import { createTranslate } from '../support/translation' import { createTranslate } from '../support/translation'
@ -199,7 +200,7 @@ debouncedWatch(
) )
async function fetchExcerpt(id: string) { async function fetchExcerpt(id: string) {
const file = pathToFile(id.slice(0, id.indexOf('#'))) const file = slash(pathToFile(id.slice(0, id.indexOf('#'))))
try { try {
return { id, mod: await import(/*@vite-ignore*/ file) } return { id, mod: await import(/*@vite-ignore*/ file) }
} catch (e) { } catch (e) {

@ -7,11 +7,10 @@ import {
type UserConfig as ViteUserConfig type UserConfig as ViteUserConfig
} from 'vite' } from 'vite'
import type { GetModuleInfo, RollupOutput } from 'rollup' import type { GetModuleInfo, RollupOutput } from 'rollup'
import { slash } from '../utils/slash'
import type { SiteConfig } from '../config' import type { SiteConfig } from '../config'
import { APP_PATH } from '../alias' import { APP_PATH } from '../alias'
import { createVitePressPlugin } from '../plugin' import { createVitePressPlugin } from '../plugin'
import { sanitizeFileName } from '../shared' import { sanitizeFileName, slash } from '../shared'
import { buildMPAClient } from './buildMPAClient' import { buildMPAClient } from './buildMPAClient'
import { fileURLToPath } from 'url' import { fileURLToPath } from 'url'
import { normalizePath } from 'vite' import { normalizePath } from 'vite'

@ -12,11 +12,11 @@ import {
notFoundPageData, notFoundPageData,
resolveSiteDataByRoute, resolveSiteDataByRoute,
sanitizeFileName, sanitizeFileName,
slash,
type HeadConfig, type HeadConfig,
type PageData, type PageData,
type SSGContext type SSGContext
} from '../shared' } from '../shared'
import { slash } from '../utils/slash'
import { deserializeFunctions } from '../utils/fnSerialize' import { deserializeFunctions } from '../utils/fnSerialize'
export async function renderPage( export async function renderPage(

@ -11,9 +11,13 @@ import {
type MarkdownOptions, type MarkdownOptions,
type MarkdownRenderer type MarkdownRenderer
} from './markdown' } from './markdown'
import { EXTERNAL_URL_RE, type HeadConfig, type PageData } from './shared' import {
EXTERNAL_URL_RE,
slash,
type HeadConfig,
type PageData
} from './shared'
import { getGitTimestamp } from './utils/getGitTimestamp' import { getGitTimestamp } from './utils/getGitTimestamp'
import { slash } from './utils/slash'
const debug = _debug('vitepress:md') const debug = _debug('vitepress:md')
const cache = new LRUCache<string, MarkdownCompileResult>({ max: 1024 }) const cache = new LRUCache<string, MarkdownCompileResult>({ max: 1024 })

@ -1,6 +1,5 @@
import path from 'path' import path from 'path'
import c from 'picocolors' import c from 'picocolors'
import { slash } from './utils/slash'
import type { OutputAsset, OutputChunk } from 'rollup' import type { OutputAsset, OutputChunk } from 'rollup'
import { import {
mergeConfig, mergeConfig,
@ -17,7 +16,7 @@ import {
} from './alias' } from './alias'
import { resolveUserConfig, resolvePages, type SiteConfig } from './config' import { resolveUserConfig, resolvePages, type SiteConfig } from './config'
import { clearCache, createMarkdownToVueRenderFn } from './markdownToVue' import { clearCache, createMarkdownToVueRenderFn } from './markdownToVue'
import type { PageDataPayload } from './shared' import { slash, type PageDataPayload } from './shared'
import { staticDataPlugin } from './plugins/staticDataPlugin' import { staticDataPlugin } from './plugins/staticDataPlugin'
import { webFontsPlugin } from './plugins/webFontsPlugin' import { webFontsPlugin } from './plugins/webFontsPlugin'
import { dynamicRoutesPlugin } from './plugins/dynamicRoutesPlugin' import { dynamicRoutesPlugin } from './plugins/dynamicRoutesPlugin'

@ -1,3 +0,0 @@
export function slash(p: string): string {
return p.replace(/\\/g, '/')
}

@ -165,3 +165,7 @@ export function sanitizeFileName(name: string): string {
.replace(/(^|\/)_+(?=[^/]*$)/, '$1') .replace(/(^|\/)_+(?=[^/]*$)/, '$1')
) )
} }
export function slash(p: string): string {
return p.replace(/\\/g, '/')
}

Loading…
Cancel
Save