-
-
Notifications
You must be signed in to change notification settings - Fork 87
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(devtools): allow user to change frontmatter in multiple posts #392
Conversation
deal with date type
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
My suggestion is to do this in a plugin or terminal, which can be developed and maintained independently without affecting existing development tools, rather than adding it to devtools. Adding too many non-core functions might make devtools bloated. |
Without adding additional dependencies, the added code is manageable. Maybe we can design a plug-in system for devtools in the future and get it up and running before we do that. |
cc @WRXinYue @qtqz @guowei-gong Are anyone interested in verifying and refining this feature? |
import fs from 'fs-extra' | ||
|
||
const prefix = '/valaxy-devtools-api' | ||
export const userroot: { root: string } = { root: '' } |
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.
All userroot
should be userRoot
packages/devtools/src/node/index.ts
Outdated
|
||
const NAME = 'valaxy:devtools' | ||
|
||
// import.meta.env.VITE_DEV_VALAXY_DEVTOOLS = 'true' | ||
|
||
export default function ValaxyDevtools(options: ValaxyDevtoolsOptions = {}): Plugin { | ||
userroot.root = options.userroot! |
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.
Why redefine?
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.
@@ -16,7 +40,7 @@ export function registerApi(server: ViteDevServer, _viteConfig: ResolvedConfig) | |||
if (req.method === 'POST') { | |||
const { pageData, frontmatter: newFm } = await (req as any).body | |||
// filePath | |||
const path = pageData.path | |||
const path = `${userroot.root}/pages${pageData.path}.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.
pageData.path
is a full path. You can not use it like this.
packages/valaxy/node/server.ts
Outdated
@@ -26,7 +27,7 @@ export async function createServer( | |||
// only enable when dev | |||
vitePlugins.push( | |||
(await import('vite-plugin-vue-devtools')).default(), | |||
(await import('@valaxyjs/devtools')).default(), | |||
(await import('@valaxyjs/devtools')).default({ userroot: userRoot }), |
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.
useRoot can got from options
. You should not pass it.
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.
That's because I dont know how to access userRoot in options.
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.
Get it from options.userRoot
directly.
// filePath | ||
const worker: Promise<void>[] = [] | ||
|
||
for (const item of pageData) |
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.
The meaning of pagedata here does not correspond to its meaning.
Just merge it for later work. |
Description
Enable user to change frontmatter in multiple posts.
Linked Issues
#174
Copilot Descriptions
copilot:all