From e32813847f67d8170a0b13d3aad10e7102e38a00 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 12 Jul 2023 09:22:57 +0200 Subject: [PATCH] Issue: Can't previe index.md of hugo reaf bundle with "previewPath": "/{{pathToken.relPath}}" #603 --- CHANGELOG.md | 1 + src/commands/Preview.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 359bb4ce..36536706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ - [#590](https://github.com/estruyf/vscode-front-matter/issues/590): Fix for image fields inside a sub-block - [#595](https://github.com/estruyf/vscode-front-matter/issues/595): Fix for media metadata now showing up - [#596](https://github.com/estruyf/vscode-front-matter/issues/596): Fix for number field in block data +- [#603](https://github.com/estruyf/vscode-front-matter/issues/603): Fix problem with page bundles and path placeholders ## [8.4.0] - 2023-04-03 - [Release notes](https://beta.frontmatter.codes/updates/v8.4.0) diff --git a/src/commands/Preview.ts b/src/commands/Preview.ts index ec492cd9..59053fa7 100644 --- a/src/commands/Preview.ts +++ b/src/commands/Preview.ts @@ -11,7 +11,7 @@ import { SETTING_DATE_FORMAT } from './../constants'; import { ArticleHelper } from './../helpers/ArticleHelper'; -import { join } from 'path'; +import { join, parse } from 'path'; import { commands, env, Uri, ViewColumn, window, WebviewPanel } from 'vscode'; import { Extension, parseWinPath, processKnownPlaceholders, Settings } from '../helpers'; import { ContentFolder, ContentType, PreviewSettings } from '../models'; @@ -290,6 +290,11 @@ export class Preview { const folderPath = wsFolder ? parseWinPath(wsFolder.fsPath) : ''; const relativePath = filePath.replace(folderPath, ''); pathname = processPathPlaceholders(pathname, relativePath, filePath, selectedFolder); + + const file = parse(filePath); + if (file.name.toLowerCase() === 'index' && pathname.endsWith(slug)) { + slug = ''; + } } // Support front matter placeholders - {{fm.}}