-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update deps and add BASE_URL before action link in hero
- Loading branch information
Showing
4 changed files
with
84 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
--- | ||
import type { Props } from "@astrojs/starlight/props"; | ||
import Default from "@astrojs/starlight/components/Hero.astro"; | ||
import { removeDuplicateSlash } from "@/utils/index.ts"; | ||
const frontmatter = Astro.props.entry.data; | ||
const actions = frontmatter.hero.actions; | ||
const actions = frontmatter.hero?.actions ?? []; | ||
// add BASE_URL before action link | ||
for (const action of actions) { | ||
if (action.link) { | ||
action.link = removeDuplicateSlash(import.meta.env.BASE_URL + action.link); | ||
} | ||
} | ||
--- | ||
|
||
<pre>{JSON.stringify(actions)}</pre> | ||
<Default {...Astro.props}><slot /></Default> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// 将多个 / 替换为一个 / | ||
export const removeDuplicateSlash = (str: string) => { | ||
return str.replace(/\/+/g, "/"); | ||
}; |