Skip to content

Asset links in components #1510

Answered by pragdave
pragdave asked this question in Q&A
Feb 28, 2022 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

In case anyone else comes across this, I ended up solving it with

    ['@vuepress/plugin-container', { 
      type: 'caption', 
      before: (src: string) => {
        return `<figure class="with-caption">\n<img src="${src}"/>\n<figcaption>`
      },
        after: (_: any) => '</figcaption></figure>',
    }],

So you'd use it like this:

::: caption @source/posts/images/Rubber_duck_assisting_with_debugging.jpg
By Tom Morris (Own work)
[CC-BY-SA-3.0](http://creativecommons.org/licenses/by-sa/3.0) or [GFDL](http://www.gnu.org/copyleft/fdl.html), via Wikimedia Commons
:::

(I couldn't get it work with relative paths...)

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Mister-Hope
Comment options

Answer selected by Mister-Hope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants