Skip to content

possible to pass page variables into code block? #7

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

Closed
ssuess opened this issue Oct 8, 2021 · 2 comments
Closed

possible to pass page variables into code block? #7

ssuess opened this issue Oct 8, 2021 · 2 comments

Comments

@ssuess
Copy link

ssuess commented Oct 8, 2021

Hi is it possible to pass vuepress page variables into the code blocks? I have been trying unsuccessfully with variations of:

<CodeSwitcher>
<template v-slot:curl>

curl --location --request GET $page.relativePath.split('/')[1].split('.md')[0]

</template>
<CodeSwitcher>
@ssuess
Copy link
Author

ssuess commented Oct 8, 2021

well I figured it out partially, I can do this:

<pre><code>curl --location --request GET {{$page.relativePath.split('/')[1].split('.md')[0]}}</code></pre>

but then I lose my prism highlighting

@padarom
Copy link
Owner

padarom commented Oct 13, 2021

This seems related to vuejs/vuepress#413. The issue I see is that if the code can change, then so needs its highlighting. The highlighting does not seem to be reactive though.

That's why for interpolated <code> blocks the syntax highlighting is disabled.

Crafting a solution for this unfortunately is outside the scope of this plugin.

@padarom padarom closed this as completed Oct 26, 2021
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

No branches or pull requests

2 participants