-
-
Notifications
You must be signed in to change notification settings - Fork 28
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: improve markdown component name #16
Comments
Yeah, I think it makes sense to have a better default and a custom function for users to customize the naming convention. PR welcome :) |
Based on https://github.com/vuejs/core/blob/623ba514ec0f5adc897db90c0f986b1b6905e014/packages/compiler-sfc/src/compileScript.ts#L959, the only way to change the name seems to be adding: <script>
export default { name: 'replace name' }
</script> |
I had done something like this in VitePress: https://github.com/vuejs/vitepress/blob/1f4ae02138820f2ee78ce6ce39847cdfd0ba19ca/src/node/markdownToVue.ts#L314-L339 Similar stuff can be added here: https://github.com/mdit-vue/unplugin-vue-markdown/blob/f1ccc5f8751ce4020059b654219f9e55d17eec55/src/core/markdown.ts#L211-L232 |
Problem
When using this plugin in conjunction with
vite-plugin-pages
, creating a markdown page with a specific name can cause component resolution issues withunplugin-vue-components
.For example, if I create a
projects.md
, behind the scenes, this plugin transforms it a component named "Projects". So when trying to auto-import the~/components/Projects.vue
component via<Projects />
usingunplugin-vue-components
, it doesn't work because Vue.js thinks I'm self-referencing the current page-component.Feature request
To avoid this problem, I suggest implementing one of the following solutions:
Add a "Md" or "Markdown" suffix to the component name to differentiate it from other components. For example, the component generated from projects.md would be named "ProjectsMd" or "ProjectsMarkdown".
Add an option to configure the component name during transformation, so that users can customize the component name to suit their needs.
I believe that implementing one of these solutions would resolve the issue and improve the user experience for those using these plugins together.
The text was updated successfully, but these errors were encountered: