Skip to content

Filters inside a frontmatter #962

Answered by cossssmin
eshlox asked this question in Q&A
Discussion options

You must be logged in to vote

PostHTML tags don't work inside Front Matter, but you can use a function instead:

// config.js
module.exports = {
  // ...
  uppercase: string => string.toUpperCase()
}
---
title: "{{{ page.uppercase('Some title') }}}"
---

Notice how the variable must be wrapped in double quotes "".

You can also nest the uppercase function in a locals object if you don't like to call if off the page object:

// config.js
module.exports = {
  // ...
  locals: {
    uppercase: string => string.toUpperCase(),
  },
}
---
- title: "{{{ page.uppercase('Some title') }}}"
+ title: "{{{ uppercase('Some title') }}}"
---

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eshlox
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