mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-06 17:02:54 +02:00
#638 - Hexo draft folder support
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
### 🎨 Enhancements
|
||||
|
||||
- [#638](https://github.com/estruyf/vscode-front-matter/issues/638): Add Hexo support for the `_drafts` folder
|
||||
- [#659](https://github.com/estruyf/vscode-front-matter/issues/659): Implement a filter for the taxonomy dashboard
|
||||
- [#662](https://github.com/estruyf/vscode-front-matter/issues/662): Always show the `all articles` tab with the page counter
|
||||
- [#663](https://github.com/estruyf/vscode-front-matter/issues/663): Make card tags clickable to filter the view
|
||||
|
||||
@@ -44,7 +44,7 @@ export default function usePages(pages: Page[]) {
|
||||
let pagesToShow: Page[] = Object.assign([], searchedPages);
|
||||
|
||||
// Framework specific actions
|
||||
if (framework?.toLowerCase() === 'jekyll') {
|
||||
if (framework?.toLowerCase() === 'jekyll' || framework?.toLowerCase() === 'hexo') {
|
||||
pagesToShow = pagesToShow.map((page) => {
|
||||
// https://jekyllrb.com/docs/posts/#drafts
|
||||
const filePath = parseWinPath(page.fmFilePath);
|
||||
|
||||
@@ -163,7 +163,7 @@ export class FrameworkDetector {
|
||||
if (await existsAsync(hexoConfig)) {
|
||||
const content = await readFileAsync(hexoConfig, 'utf8');
|
||||
// Convert YAML to JSON
|
||||
const config = jsyaml.safeLoad(content);
|
||||
const config = jsyaml.load(content);
|
||||
|
||||
// Check if post assets are used: https://hexo.io/docs/asset-folders.html#Post-Asset-Folder
|
||||
if (config.post_asset_folder) {
|
||||
@@ -171,6 +171,25 @@ export class FrameworkDetector {
|
||||
}
|
||||
}
|
||||
|
||||
const draftsPath = join(wsFolder?.fsPath || '', 'source', '_drafts');
|
||||
const postsPath = join(wsFolder?.fsPath || '', 'source', '_posts');
|
||||
|
||||
if (await existsAsync(draftsPath)) {
|
||||
const folderUri = Uri.file(draftsPath);
|
||||
await commands.executeCommand(COMMAND_NAME.registerFolder, {
|
||||
title: 'drafts',
|
||||
path: folderUri
|
||||
});
|
||||
}
|
||||
|
||||
if (await existsAsync(postsPath)) {
|
||||
const folderUri = Uri.file(postsPath);
|
||||
await commands.executeCommand(COMMAND_NAME.registerFolder, {
|
||||
title: 'posts',
|
||||
path: folderUri
|
||||
});
|
||||
}
|
||||
|
||||
await Settings.update(SETTING_CONTENT_STATIC_FOLDER, assetFoler, true);
|
||||
} catch (e) {
|
||||
Logger.error(
|
||||
@@ -191,7 +210,7 @@ export class FrameworkDetector {
|
||||
if (await existsAsync(jekyllConfig)) {
|
||||
const content = await readFileAsync(jekyllConfig, 'utf8');
|
||||
// Convert YAML to JSON
|
||||
const config = jsyaml.safeLoad(content);
|
||||
const config = jsyaml.load(content);
|
||||
|
||||
if (config.collections_dir) {
|
||||
collectionDir = config.collections_dir;
|
||||
@@ -203,7 +222,7 @@ export class FrameworkDetector {
|
||||
|
||||
if (await existsAsync(draftsPath)) {
|
||||
const folderUri = Uri.file(draftsPath);
|
||||
commands.executeCommand(COMMAND_NAME.registerFolder, {
|
||||
await commands.executeCommand(COMMAND_NAME.registerFolder, {
|
||||
title: 'drafts',
|
||||
path: folderUri
|
||||
});
|
||||
@@ -211,7 +230,7 @@ export class FrameworkDetector {
|
||||
|
||||
if (await existsAsync(postsPath)) {
|
||||
const folderUri = Uri.file(postsPath);
|
||||
commands.executeCommand(COMMAND_NAME.registerFolder, {
|
||||
await commands.executeCommand(COMMAND_NAME.registerFolder, {
|
||||
title: 'posts',
|
||||
path: folderUri
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user