Skip to content

Commit

Permalink
fix: ignore swup transitions for rss and sitemap-index links
Browse files Browse the repository at this point in the history
Closes lxchapu#16
  • Loading branch information
lxchapu committed Aug 25, 2024
1 parent 03830f3 commit 7261f40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/footer/Footer.astro
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const wordCountStr = (wordCount / 1000).toFixed(1) + 'k'
</div>
<div class="space-x-1">
<span>&copy;{copyDate} <Link href="/">{author.name}</Link>.</span>
<Link href="/rss.xml">
<Link href="/rss.xml" data-no-swup>
<i class="iconfont icon-rss"></i>
<span>RSS</span>
</Link>
<Link href="/sitemap-index.xml">
<Link href="/sitemap-index.xml" data-no-swup>
<i class="iconfont icon-map"></i>
<span>站点地图</span>
</Link>
Expand Down
9 changes: 6 additions & 3 deletions src/components/footer/Link.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
interface Props {
import type { HTMLAttributes } from 'astro/types'
interface Props extends HTMLAttributes<'a'> {
href: string
}
const { href } = Astro.props
const { href, ...attrs } = Astro.props
const isExternal = href.startsWith('http')
---
Expand All @@ -12,5 +14,6 @@ const isExternal = href.startsWith('http')
class="hover:text-accent"
href={href}
target={isExternal ? '_blank' : undefined}
rel={isExternal ? 'noopener noreferrer' : undefined}><slot /></a
rel={isExternal ? 'noopener noreferrer' : undefined}
{...attrs}><slot /></a
>

0 comments on commit 7261f40

Please sign in to comment.