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

Relative images in YAML front matter handling in custom layout #165

Closed
imfing opened this issue Apr 20, 2018 · 1 comment
Closed

Relative images in YAML front matter handling in custom layout #165

imfing opened this issue Apr 20, 2018 · 1 comment

Comments

@imfing
Copy link

imfing commented Apr 20, 2018

Simply, I want to load images from paths relative to the README.md directory in a custom layout.

Beause in some cases (customized layouts), image resouces couldn't always be placed under the .vuepress/public directory or loaded with markdown.

For example, the title/background image for a blog post.
So I'm wondering what's the best practice to achieve so with vuepress.

In my case, the yaml front matter of the README.md would expected to be something like:

# README.md
---
avatar: ./path1/image.png  # relative to README.md
background: ./path2/image.png
layout: Post
---

And the Post.vue would be like:

<template>
  <div>
    <img :src="data.avatar">
    <Content/>
  <div>
</template>

However, the image isn't being parsed and loaded correctly since vuepress only injected its .vuepress/public path and copied them with copy-plugin. Also, webpack didn't handle the resources in yaml front matter.

Node.js v8.7.0
VuePress 1.7.0

@imfing imfing changed the title Relative images in YAML front matter not loaded within custom layout Relative images in YAML front matter handling in custom layout Apr 20, 2018
@imfing
Copy link
Author

imfing commented Apr 20, 2018

Sorry, duplicate of issue #79

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

1 participant