mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-03-28 17:42:40 +01:00
Fix: improve media folder parsing on Windows and update path handling in various modules
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
### 🐞 Fixes
|
||||
|
||||
- Fix for media folder parsing on Windows
|
||||
- [#909](https://github.com/estruyf/vscode-front-matter/issues/909): Schema fix for the view modes
|
||||
- [#913](https://github.com/estruyf/vscode-front-matter/issues/913): Fix for relative media paths in page bundles
|
||||
- [#914](https://github.com/estruyf/vscode-front-matter/issues/914): Fix sanitizing of default filenames with an `_` in it
|
||||
|
||||
@@ -219,7 +219,9 @@ export class Folders {
|
||||
: Folders.getAbsFilePath(assetFolder);
|
||||
const wsFolder = Folders.getWorkspaceFolder();
|
||||
if (wsFolder) {
|
||||
const relativePath = relative(parseWinPath(wsFolder.fsPath), parseWinPath(assetFolder));
|
||||
const relativePath = parseWinPath(
|
||||
relative(parseWinPath(wsFolder.fsPath), parseWinPath(assetFolder))
|
||||
);
|
||||
return relativePath === '' ? '/' : relativePath;
|
||||
}
|
||||
}
|
||||
@@ -648,7 +650,7 @@ export class Folders {
|
||||
|
||||
const uniqueFolders = [...new Set(folders)];
|
||||
const relativeFolderPaths = uniqueFolders.map((folder) =>
|
||||
relative(parseWinPath(wsFolder.fsPath), folder)
|
||||
parseWinPath(relative(parseWinPath(wsFolder.fsPath), folder))
|
||||
);
|
||||
|
||||
Logger.verbose('Folders:getContentFolders:end');
|
||||
|
||||
@@ -137,7 +137,7 @@ export class FrameworkDetector {
|
||||
const assetDir = dirname(absAssetPath);
|
||||
const fileName = parse(absAssetPath);
|
||||
|
||||
relAssetPath = relative(fileDir, assetDir);
|
||||
relAssetPath = parseWinPath(relative(fileDir, assetDir));
|
||||
relAssetPath = join(relAssetPath, `${fileName.name}${fileName.ext}`);
|
||||
}
|
||||
// Support for HEXO image folder
|
||||
@@ -197,7 +197,7 @@ export class FrameworkDetector {
|
||||
const assetDir = dirname(absAssetPath);
|
||||
const fileName = parse(absAssetPath);
|
||||
|
||||
let relAssetPath = relative(fileDir, assetDir);
|
||||
let relAssetPath = parseWinPath(relative(fileDir, assetDir));
|
||||
relAssetPath = join(relAssetPath, `${fileName.name}${fileName.ext}`);
|
||||
return parseWinPath(relAssetPath);
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ export class MediaHelpers {
|
||||
|
||||
// If the image exists in a content folder, the relative path needs to be used
|
||||
if (existsInContent) {
|
||||
const relImgPath = relative(fileDir, imgDir);
|
||||
const relImgPath = parseWinPath(relative(fileDir, imgDir));
|
||||
|
||||
relPath = join(relImgPath, basename(relPath));
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { dirname, relative } from 'path';
|
||||
import { ContentFolder } from '../models';
|
||||
import { parseWinPath } from './parseWinPath';
|
||||
|
||||
export const processPathPlaceholders = (
|
||||
value: string,
|
||||
@@ -11,7 +12,7 @@ export const processPathPlaceholders = (
|
||||
const relPathToken = '{{pathToken.relPath}}';
|
||||
if (value.includes(relPathToken) && contentFolder?.path) {
|
||||
const dirName = dirname(filePath);
|
||||
const relPath = relative(contentFolder.path, dirName);
|
||||
const relPath = parseWinPath(relative(contentFolder.path, dirName));
|
||||
value = value.replace(relPathToken, relPath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user