Skip to content

Commit

Permalink
fix: 卡片图片无法点击
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Jun 2, 2024
1 parent 4a730af commit 1024168
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions scripts/tag/externalLinkCard.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/**
* {% externalLinkCard title link [background]|"auto" %}
* {% externalLinkCard title link [cover]|"auto" %}
*/
hexo.extend.tag.register("externalLinkCard", (args) => {
let title = args.shift();
let link = args.shift();
let background = args.shift();
let cover = args.shift();
if (!title || !link) {
throw new Error(
`External link not found: "${title}" doesn't exist for {% externalLinkCard %}`
);
}
const coverDom = background
? background === "auto"
const coverDom = cover
? cover === "auto"
? `<div class="post-link-card-cover-wrap auto"><div class="icon-globe"></div></div>`
: `<div class="post-link-card-cover-wrap"><img src=${background} class="no-fancybox" title=${title} /></div>`
: `<div class="post-link-card-cover-wrap"><img src=${cover} class="no-fancybox" title=${title} /></div>`
: "";
return `<div class="post-link-card-wrap">
<div class="post-link-card">
Expand Down
14 changes: 7 additions & 7 deletions scripts/tag/postLinkCard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { url_for, escapeHTML, stripHTML } = require("hexo-util");

/**
* {% postLinkCard slug|title [background]|"auto" [escape] %}
* {% postLinkCard slug [cover]|"auto" [escape] %}
*/
hexo.extend.tag.register("postLinkCard", (args) => {
let slug = args.shift();
Expand All @@ -20,16 +20,16 @@ hexo.extend.tag.register("postLinkCard", (args) => {
}

let escape = "true";
let background = "";
let cover = "";
if (args.length == 2) {
escape = args.pop();
background = args.pop();
cover = args.pop();
} else {
const last = args[args.length - 1];
if (last === "true" || last === "false") {
escape = args.pop();
} else {
background = last ?? "";
cover = last ?? "";
}
}

Expand All @@ -46,9 +46,9 @@ hexo.extend.tag.register("postLinkCard", (args) => {
if (escape === "true") title = escapeHTML(title);

const link = url_for.call(hexo, post.path + (hash ? `#${hash}` : ""));
if(background === "auto") background = hexo.theme.config.banner;
const coverDom = background
? `<div class="post-link-card-cover-wrap"><img src=${background} class="no-fancybox" title=${title} /></div>`
if(cover === "auto") cover = hexo.theme.config.banner;
const coverDom = cover
? `<div class="post-link-card-cover-wrap"><img src=${cover} class="no-fancybox" title=${title} /></div>`
: "";
return `<div class="post-link-card-wrap">
<div class="post-link-card">
Expand Down
1 change: 1 addition & 0 deletions source/css/_partial/card.styl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
width: 68px
padding-right: 20px
flex-shrink: 0
pointer-events: none

img
width: 100%
Expand Down

0 comments on commit 1024168

Please sign in to comment.