Skip to content
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

Merged
merged 7 commits into from
Aug 1, 2024

Conversation

smallp
Copy link
Contributor

@smallp smallp commented May 16, 2024

Description

Enable user to change frontmatter in multiple posts.

Linked Issues

#174

Copilot Descriptions

copilot:all

Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
valaxy-docs-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 4:16pm

@WRXinYue
Copy link
Collaborator

WRXinYue commented Jul 5, 2024

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.

@YunYouJun
Copy link
Owner

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.

@YunYouJun YunYouJun changed the title finish migration feat(devtools): allow user to change frontmatter in multiple posts Jul 5, 2024
@YunYouJun
Copy link
Owner

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: '' }
Copy link
Owner

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


const NAME = 'valaxy:devtools'

// import.meta.env.VITE_DEV_VALAXY_DEVTOOLS = 'true'

export default function ValaxyDevtools(options: ValaxyDevtoolsOptions = {}): Plugin {
userroot.root = options.userroot!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why redefine?

Copy link
Owner

@YunYouJun YunYouJun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This pr contains the wrong type build (js-yaml) so that it cannot pass CI. For new features, and there is no style, no comments.
Before waiting for a merge, you should make sure it passes all CIS and resolves conflicts.

@@ -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`
Copy link
Owner

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.

@@ -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 }),
Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

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)
Copy link
Owner

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.

@YunYouJun YunYouJun merged commit 7d39b7f into YunYouJun:main Aug 1, 2024
10 checks passed
@YunYouJun
Copy link
Owner

Just merge it for later work.

Copy link

github-actions bot commented Aug 1, 2024

Yun Good!

@smallp smallp deleted the dev branch August 2, 2024 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants