Improve slug retrieval

This commit is contained in:
Elio Struyf
2023-09-25 10:29:57 +02:00
parent 03a0260b46
commit 43eb5a78e7
2 changed files with 9 additions and 2 deletions

View File

@@ -48,6 +48,7 @@
- [#645](https://github.com/estruyf/vscode-front-matter/issues/645): French localization added (thanks to [Clément Barbaza](https://github.com/cba85))
- [#649](https://github.com/estruyf/vscode-front-matter/issues/649): Parse optional variables from snippets
- [#652](https://github.com/estruyf/vscode-front-matter/issues/652): Show the start/stop server buttons depending on the local terminal session
- [#654](https://github.com/estruyf/vscode-front-matter/issues/654): Added a new action to open the content in the browser
### 🐞 Fixes

View File

@@ -258,10 +258,16 @@ export class Preview {
if (!selectedFolder && article?.data && contentType && !contentType.previewPath) {
// Try to find the folder by content type
const crntFolders = folders.filter((folder) =>
folder.contentTypes?.includes((contentType as ContentType).name)
let crntFolders = folders.filter(
(folder) =>
folder.contentTypes?.includes((contentType as ContentType).name) && folder.previewPath
);
// Use file path to find the folder
if (crntFolders.length > 0) {
crntFolders = crntFolders.filter((folder) => filePath?.startsWith(folder.path));
}
if (crntFolders && crntFolders.length === 1) {
selectedFolder = crntFolders[0];
} else if (crntFolders && crntFolders.length > 1) {