Merge branch 'dev' into localization

This commit is contained in:
Elio Struyf
2023-11-05 08:55:13 +01:00
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -10,6 +10,7 @@
- [#686](https://github.com/estruyf/vscode-front-matter/issues/686): Allow script authors to ask questions during script execution
- [#688](https://github.com/estruyf/vscode-front-matter/issues/688): Allow to show the scheduled articles in the content dashboard (filter and group)
- [#690](https://github.com/estruyf/vscode-front-matter/issues/690): Added the ability to filter values in the `contentRelationship` field
- [#700](https://github.com/estruyf/vscode-front-matter/issues/700): Added the `{{pathToken.relPath}}` placeholder for the `previewPath` property
### ⚡️ Optimizations
+8
View File
@@ -1,3 +1,4 @@
import { dirname, relative } from 'path';
import { ContentFolder } from '../models';
export const processPathPlaceholders = (
@@ -7,6 +8,13 @@ export const processPathPlaceholders = (
contentFolder: ContentFolder | null | undefined
) => {
if (value && value.includes('{{pathToken.')) {
const relPathToken = '{{pathToken.relPath}}';
if (value.includes(relPathToken) && contentFolder?.path) {
const dirName = dirname(filePath);
let relPath = relative(contentFolder.path, dirName);
value = value.replace(relPathToken, relPath);
}
const regex = /{{pathToken.(\d+|relPath)}}/g;
const matches = value.match(regex);
if (matches) {