Skip to content

Commit

Permalink
Improve slug retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Sep 25, 2023
1 parent 03a0260 commit 43eb5a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions src/commands/Preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 43eb5a7

Please sign in to comment.