hugofy-vscode
hugofy-vscode copied to clipboard
Custom content/posts folder setting
How can I set a custom content/posts folder like /src/site/content ?
I see that this part of the code is responsible for it (src/extension.ts):
const newPost = () => {
vscode.window.showInputBox({ placeHolder: 'Enter filename' }).then((filename) => {
const newPostPath = path.join(vscode.workspace.rootPath, 'content', 'post', filename);
const postPath = 'post' + path.sep + filename;
const newPostCmd = spawn('hugo', ['new', postPath, `-s="${vscode.workspace.rootPath}"`], { shell: true });
newPostCmd.stdout.on('data', (data) => {
vscode.window.showInformationMessage(data);
});
newPostCmd.stderr.on('data', (data) => {
console.log(`stderr: ${data}`);
vscode.window.showInformationMessage(`Error creating new post.`);
});
newPostCmd.on('close', (code) => {
if (code === 0) {
let uripath = vscode.Uri.file(newPostPath);
vscode.workspace.openTextDocument(uripath).then((document) => {
vscode.window.showTextDocument(document);
}, err => {
console.log(err);
});
} else {
vscode.window.showErrorMessage(`Error creating new post.`);
}
});
});
};
The "post" word would need to be made a variable which can be set in the extension configuration. At the moment, the extension is not configurable. Unfortunately, I have never done TypeScript or VScode extensions. If you know how to, or know someone who knows how to, please create a PR.
Try this Extension: https://marketplace.visualstudio.com/items?itemName=phoenisx.gohugo