refactor: use a custom Link component to be able to use absolute URLs everywhere
...that supports any `base` property
This commit is contained in:
parent
bdf831b008
commit
ca6834d95f
21 changed files with 89 additions and 53 deletions
11
docs/src/components/Link.astro
Normal file
11
docs/src/components/Link.astro
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
interface Props {
|
||||
href: string;
|
||||
}
|
||||
|
||||
const base = import.meta.env.BASE_URL === '/' || !import.meta.env.BASE_URL ? '' : import.meta.env.BASE_URL;
|
||||
const site = import.meta.env.SITE ?? '';
|
||||
const { href } = Astro.props;
|
||||
---
|
||||
|
||||
<a href={`${site}${base}${href}`}><slot /></a>
|
||||
Loading…
Add table
Add a link
Reference in a new issue