Skip to content

Commit

Permalink
fix: external link condition
Browse files Browse the repository at this point in the history
  • Loading branch information
cptchloroplast committed Aug 26, 2024
1 parent 6724969 commit 4a9fb98
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function renderMarkdown(markdown: string) {
const matches = Array.from(html.matchAll(regex))
if (matches.length) {
for (const [link, href, _, content] of matches) {
if (href != "/") {
if (!href.startsWith("/")) {
const external = link.replace(content, `${content}<span style="margin-left: 4px;"><i class="i-external"></i></span>`)
.replace(href, `${href}" target="_blank`)
html = html.replace(link, external)
Expand Down

0 comments on commit 4a9fb98

Please sign in to comment.