Skip to content

How to have cover image in frontmatter? #82

Answered by ElMassimo
luminarious asked this question in Q&A
Discussion options

You must be logged in to vote

@luminarious There are different ways to achieve this, depending on what you need.

Direct References

The simplest way would be to put the images in public, and reference the full public path in the frontmatter. Example:

cover: /images/specific-project/project.jpg

Shorter References

Using extendFrontmatter (as in your example) you could modify cover to achieve the same result, but without specifying the full path:

cover: project.jpg

Dynamic References

You could use import.meta.globEager to obtain a fingerprinted path to all images, and then index that using the meta.filename or frontmatter information.

It has no runtime cost if you are using îles, but the code is not pretty. On the other h…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ElMassimo
Comment options

You must be logged in to vote
5 replies
@ElMassimo
Comment options

@luminarious
Comment options

@ElMassimo
Comment options

@luminarious
Comment options

@ElMassimo
Comment options

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