From 4781134518828c2be1cc1155e4923460727dd0d6 Mon Sep 17 00:00:00 2001 From: Hyouka Date: Fri, 23 Feb 2024 17:53:07 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96card=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vitepress/theme/components/Card.ts | 1 + .vitepress/theme/index.ts | 2 +- .vitepress/theme/markdown/card.ts | 2 +- .vitepress/theme/styles/card.scss | 10 ++++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.vitepress/theme/components/Card.ts b/.vitepress/theme/components/Card.ts index 4ec94b8cd..87b09b2fd 100644 --- a/.vitepress/theme/components/Card.ts +++ b/.vitepress/theme/components/Card.ts @@ -191,6 +191,7 @@ const Card: FunctionalComponent = ({ { href: isLinkExternal(link) ? link : withBase(link), target: isLinkExternal(link) ? '_blank' : '_self', + isExternalLink: isLinkExternal(link) ? 'true' : 'false', ...props, }, children, diff --git a/.vitepress/theme/index.ts b/.vitepress/theme/index.ts index 370057fe6..8e45ac58a 100644 --- a/.vitepress/theme/index.ts +++ b/.vitepress/theme/index.ts @@ -39,7 +39,7 @@ export default { }) app.component('Link', Link) app.component('Coins', Coins) - app.component('VPCard', Card) + app.component('Card', Card) app.component('LinkGrid', LinkGrid) app.component('Badge', VPBadge) }, diff --git a/.vitepress/theme/markdown/card.ts b/.vitepress/theme/markdown/card.ts index f57062b57..253c00e35 100644 --- a/.vitepress/theme/markdown/card.ts +++ b/.vitepress/theme/markdown/card.ts @@ -82,7 +82,7 @@ const cardRender = ( const cardData = checkCardProps(config) - if (cardData) return `` + if (cardData) return `` console.error( `Invalid card config${relativePath ? ` found in ${relativePath}` : ''}: diff --git a/.vitepress/theme/styles/card.scss b/.vitepress/theme/styles/card.scss index d4316ec2f..65e82e04f 100644 --- a/.vitepress/theme/styles/card.scss +++ b/.vitepress/theme/styles/card.scss @@ -183,6 +183,16 @@ color: currentColor !important; } + &[isexternallink='true']::after { + margin-top: -16px !important; + transform: translateX(8px); + } + + &[isexternallink='false']::after { + margin-top: -16px !important; + transform: translateX(4px) rotate(45deg); + } + hr { display: none; }