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

[Feature request] Support vue js ts file as pages #1607

Open
Mister-Hope opened this issue Sep 11, 2024 · 1 comment
Open

[Feature request] Support vue js ts file as pages #1607

Mister-Hope opened this issue Sep 11, 2024 · 1 comment
Labels
discussion Discussion

Comments

@Mister-Hope
Copy link
Member

Mister-Hope commented Sep 11, 2024

Clear and concise description of the problem

Generally, .vue and component with .js .ts could all be pages, so we can make vuepress support them out of box, while remaining the default pagesPattern to be only markdown.

Suggested solution

A vue component:

<script setup>
// ...
</script>

<frontmatter lang="yaml">
title: asd
description: asd
</frontmatter>

<template>
  <!-- content -->
</template>

The lang="yaml" is the default behavior, so we can make it optional, but declaring it provides volar with correct highlighting and formatting, we can also support lang='json'

For js and ts component, a frontmatter named export is preferred:

export const frontmatter = {
 // ...
}

export default defineComponent({
 // ...
})
@meteorlxy
Copy link
Member

meteorlxy commented Sep 12, 2024

The page creation is based on markdown, and we extract page data by the markdown parser. If we want to support vue / ts pages, we need to parse the vue file / ts file when creating the page to keep the current process.

That means:

  • Extra overhead. The same script would be parse by createPage and bundler twice.
  • Some fields like data.headers would be unavailable for sure.

It might be ok if we skip the normal page creation process for vue / ts pages. However, I think this feature makes little sense for common users. Only some advance users might need this. IMO, no exceptions should be made for these rare cases.

In addition, for advanced users, they could already add pages via vue / ts by adding a custom Layout & node API.

Thus, I'm not in favor of adding extra complexity to this kind of feature that already has a way of being implemented.

If it's really a common use case, we can consider providing some method / utils to help adding pages programmatically

@meteorlxy meteorlxy added the discussion Discussion label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion
Projects
None yet
Development

No branches or pull requests

2 participants