#How to use astro config baes in hero link

1 messages · Page 1 of 1 (latest)

pale hollow
#

In my astro.config.mjs, I use a dynamic base so that it can change based on how it is built:

// astro.config.mjs
export default defineConfig({
  site: ...,
  base: process.env.WEBSITE_BASE
})

In the index.mdx, I have a "Getting Started" action link:

// index.mdx
---
title: Welcome
hero:
  actions:
    - text: Getting Started
      link: <base>/introduction/getting-started

I couldn't find a way to insert that <base> value.
Is it possible?

royal zodiac
#

Hmm, there isn't a built-in way to support this scenario but I think it's possible with route middleware to do something like this.

#

You could have a placeholder like your <base> in the file and then substitute the base in the middleware.