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

Is there a way to include variables from front-matter in a Markdown link #965

Closed
johnrengelman opened this issue Oct 28, 2018 · 6 comments
Closed

Comments

@johnrengelman
Copy link

Sorry if this is not the correct place to get this info. I'm very new Vue and Vuepress.
I'm trying to write documentation for a software project and I'm using Vuepress with markdown files.
I have lots of links that point out to an external site and I was wondering if there was a way for me including the base path in the front matter and then use that in the markdown link.

---
api: http://domain.com/api
---

This is the [link]({{ $page.api }}/path/to/a/file.html)
@fen89
Copy link

fen89 commented Oct 29, 2018

@johnrengelman you could write a custom component and embed it in your markdown, e.g. something like this:

This is the <ApiLink :to="/path/to/a/file.html">link</ApiLink>

Please see https://vuepress.vuejs.org/guide/using-vue.html#using-components for details

@ulivz
Copy link
Member

ulivz commented Oct 29, 2018

$page.api is Vue runtime syntax but all markdown links are resovled at build time. so what you tried
above doesn't work.

Just using HTML:

---
api: http://domain.com/api
---

This is the <a :href=" $page.frontmatter.api + '/path/to/a/file.html' ">App</a>

@ulivz ulivz closed this as completed Oct 29, 2018
@songololo
Copy link

Just to clarify, I assume actionLink is a typo and should refer to api?

@ulivz
Copy link
Member

ulivz commented Oct 30, 2018

@Shongololo Updated. thanks

@rafi
Copy link

rafi commented Nov 24, 2018

Using <a href=""></a> will cause a full refresh, I found that <router-link to=""></router-link> doesn't.

@f-w
Copy link

f-w commented Dec 10, 2020

<a> doesn't show outbound icon for outbound link.

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

6 participants