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: support path and relative-path prop #25

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hairyf
Copy link

@hairyf hairyf commented May 25, 2023

close #24


Review PR in StackBlitz Codeflow Submitted with StackBlitz Codeflow.

@flingyp
Copy link
Owner

flingyp commented May 26, 2023

Jump to github demo. @vitepress-demo-preview/component package should achieve for the function. Right?

@hairyf
Copy link
Author

hairyf commented May 26, 2023

It's actually not very suitable for @vitepress-demo-preview/component. It is useful when customizing the demo-preview, and we need to customize the GitHub blob address.

Reference: https://github.com/tusen-ai/naive-ui/blob/HEAD/demo/utils/EditOnGithubHeader.vue#LL11C22-L11C22

I don't think it should be added to the default component. This is just a simple use case and would add unnecessary complexity.

@hairyf
Copy link
Author

hairyf commented May 26, 2023

Additionally, I haven't found any test cases to verify this functionality. The dependencies in the example are linked to remote addresses. How should I proceed with testing?

@flingyp
Copy link
Owner

flingyp commented May 26, 2023

OK, but the codes you modified doesn't do the function. relativePath should is a online link url but you get the absolute path of the local component.

@flingyp
Copy link
Owner

flingyp commented May 26, 2023

We should make sure that a relativePath prop is resolvable by the plugin. Right?
Maybe you can do it in the @vitepress-demo-preview/component package and provide the function to jump the link.

@hairyf
Copy link
Author

hairyf commented May 26, 2023

It shouldn't be a remote path unless githubPath is exported; otherwise, it should be a relative path provided to demo-preview.

<script lang="ts" setup>
const props = defineProps<{
  relativePath: string
}>()

const githubPath = `https://www.github.com/.../tree/main${props.relativePath}`
</script>

<template>
  <!-- .... -->
  <a :href="githubPath">to github edit</a>
</template>

@hairyf
Copy link
Author

hairyf commented May 26, 2023

I added support for that feature in markdown-it-vitepress-demo#metadata and implemented other features as well. It has indeed been helpful to me. Additionally, I would like to thank the project for providing me with great inspiration!

@flingyp
Copy link
Owner

flingyp commented May 27, 2023

Thanks, your attention and contribution!

I can test the feature at example and this is the result I saw. You only need to custom a demo-preview component and the usage remains unchanged.
image

If this meets your expectations, I will merge this PR.

@hairyf
Copy link
Author

hairyf commented May 27, 2023

yes, however, it should replace \ with/

@flingyp
Copy link
Owner

flingyp commented May 27, 2023

yes, however, it should replace \ with/

Yeah, well, you can change the code and submit it. I will merge the pr. Then you just need to customize your own preview component. Thanks!

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.

support path prop
2 participants