-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add post #2
base: main
Are you sure you want to change the base?
Conversation
// ...
await workspace.fs.writeFile(filePath, Buffer.from(`---
title:
date: ${now}
updated: ${now}
tags:
-
categories:
---\n`))
// ... However, I'm not sure where to put these lines of code for the template of the new posts, and I feel like it would be abrupt if I just put them in directly. |
Thanks for your contribution, this is exactly the kind of feature I want to add later! Regarding the issue you mentioned, I think we should put it in the |
The basic functionality has been implemented, but I feel that the logic in my code is not very clear. I hope YunYouJun can provide some guidance. |
res/md/template.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/view/ValaxyProvider.ts
Outdated
async add(): Promise<void> { | ||
const EXIST_NOTICE_MSG = 'A post with the same name already exists' | ||
|
||
const input1 = await window.showInputBox({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a clearer name: postName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember to use trim()
src/view/ValaxyProvider.ts
Outdated
return | ||
|
||
try { | ||
await workspace.fs.stat(Uri.joinPath(uri, '/scaffolds', `${input1}.md`)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default is post.md
, I think we should use it directly, and only need one input for postName
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or a select (query option form scaffolds)
Is there any progress? |
const second = date.getSeconds() | ||
|
||
const pad = (n: number) => n.toString().padStart(2, '0') | ||
return `${year}-${pad(month)}-${pad(day)} ${pad(hour)}:${pad(minute)}:${pad(second)}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use dayjs to format it.
I have added a feature to the extension which you can add post by clicking the bottom 'Add a Post' on the navigator. It works like this: