#664 - Draft status parsing fix

This commit is contained in:
Elio Struyf
2023-09-14 10:32:53 +02:00
parent fdb4a0892c
commit 73ce0d23ae
2 changed files with 14 additions and 8 deletions
+1
View File
@@ -17,6 +17,7 @@
- [#660](https://github.com/estruyf/vscode-front-matter/issues/660): Allow only to select unique content relationship values
- [#661](https://github.com/estruyf/vscode-front-matter/issues/661): Fixing the dropdowns when used at the bottom of a collapsible group
- [#664](https://github.com/estruyf/vscode-front-matter/issues/664): Fix for parsing draft status in Hexo and Jekyll
## [9.2.0] - 2023-09-11
+13 -8
View File
@@ -46,16 +46,21 @@ export default function usePages(pages: Page[]) {
// Framework specific actions
if (framework?.toLowerCase() === 'jekyll' || framework?.toLowerCase() === 'hexo') {
pagesToShow = pagesToShow.map((page) => {
// https://jekyllrb.com/docs/posts/#drafts
const filePath = parseWinPath(page.fmFilePath);
page.draft = filePath.indexOf(`/_drafts/`) > -1;
try {
const crntPage = Object.assign({}, page);
// https://jekyllrb.com/docs/posts/#drafts
const filePath = parseWinPath(page.fmFilePath);
crntPage.draft = filePath.indexOf(`/_drafts/`) > -1;
// Published field: https://jekyllrb.com/docs/front-matter/#predefined-global-variables
if (typeof page.published !== 'undefined') {
page.draft = !page.published;
// Published field: https://jekyllrb.com/docs/front-matter/#predefined-global-variables
if (typeof crntPage.published !== 'undefined') {
crntPage.draft = !crntPage.published;
}
return crntPage;
} catch (error) {
return page;
}
return page;
});
}