mirror of https://github.com/twbs/bootstrap.git
Docs: fix local assets path handling for Windows compatibility (#41485)
Co-authored-by: Julien Déramond <juderamond@gmail.com>
This commit is contained in:
parent
374c8a1e1f
commit
d6ca5ba35b
|
@ -58,13 +58,13 @@ function getExamplesAssetsRecursively(source: string, assets: string[] = []) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeAssetPath(assetPath: string) {
|
function sanitizeAssetPath(assetPath: string) {
|
||||||
const matches = assetPath.match(/([^\/]+\/[^\/]+\.\w+)$/)
|
const matches = assetPath.match(/([^\/\\]+[\/\\][^\/\\]+\.\w+)$/)
|
||||||
|
|
||||||
if (!matches || !matches[1]) {
|
if (!matches || !matches[1]) {
|
||||||
throw new Error(`Failed to get example asset path from path: '${assetPath}'.`)
|
throw new Error(`Failed to get example asset path from path: '${assetPath}'.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches[1]
|
return matches[1].replaceAll('\\', '/')
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAliasedAstroInstance(page: AstroInstance): page is AliasedAstroInstance {
|
function isAliasedAstroInstance(page: AstroInstance): page is AliasedAstroInstance {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import { getConfig } from './config'
|
import { getConfig } from './config'
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
// The docs directory path relative to the root of the project.
|
// The docs directory path relative to the root of the project.
|
||||||
export const docsDirectory = getConfig().docsDir
|
export const docsDirectory = getConfig().docsDir
|
||||||
|
@ -32,7 +33,7 @@ export function validateVersionedDocsPaths(distUrl: URL) {
|
||||||
|
|
||||||
for (const docsPath of generatedVersionedDocsPaths) {
|
for (const docsPath of generatedVersionedDocsPaths) {
|
||||||
const sanitizedDocsPath = sanitizeVersionedDocsPathForValidation(docsPath)
|
const sanitizedDocsPath = sanitizeVersionedDocsPathForValidation(docsPath)
|
||||||
const absoluteDocsPath = path.join(distUrl.pathname, 'docs', docs_version, sanitizedDocsPath)
|
const absoluteDocsPath = fileURLToPath(new URL(path.join( './docs', docs_version, sanitizedDocsPath), distUrl));
|
||||||
|
|
||||||
const docsPathExists = fs.existsSync(absoluteDocsPath)
|
const docsPathExists = fs.existsSync(absoluteDocsPath)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue