优化link标签

This commit is contained in:
xaoxuu 2021-11-19 22:59:46 +08:00
parent 90b31903ef
commit 700e0cc136
2 changed files with 15 additions and 7 deletions

View File

@ -7,6 +7,9 @@
'use strict';
var util = require('hexo-util');
const full_url_for = require('hexo-util').full_url_for.bind(hexo);
hexo.extend.tag.register('link', function(args) {
args = hexo.args.map(args, ['icon'], ['url', 'title', 'description']);
@ -28,7 +31,7 @@ hexo.extend.tag.register('link', function(args) {
return el;
}
function loadTitle() {
return '<span class="title fs14">' + args.title + '</span>';
return '<span class="title">' + args.title + '</span>';
}
function loadDesc() {
return '<span class="url fs12">' + (args.description || args.url) + '</span>';
@ -38,7 +41,7 @@ hexo.extend.tag.register('link', function(args) {
// top
el += '<div class="top">';
el += loadIcon();
el += '<span class="url fs12">' + args.url + '</span>';
el += '<span class="url fs12">' + full_url_for(args.url) + '</span>';
el += '</div>';
// bottom
el += '<div class="bottom">';

View File

@ -26,13 +26,15 @@
.md .link-card.plain
flex-direction: row
align-items: center
.md .link-card.rich
flex-direction: column
align-items: flex-start
align-items: stretch
width: 400px
.md .link-card
line-height: 1.2
> div
pointer-events: none
>.top
@ -51,11 +53,15 @@
background-position: left center
.url
opacity: .75
line-height: 1.5
span
txt-ellipsis()
max-width: 100%
>.bottom
margin: 0 1rem .75rem 1rem
.title
font-size: $fs-15
margin: 4px 0 8px 0
>.right
width: 2.5rem
height: 2.5rem
@ -65,6 +71,9 @@
>.left
overflow: hidden
margin: .5rem 0 .5rem 1rem
.title
font-size: $fs-14
margin: 4px 0
.url
flex-shrink: 0
txt-ellipsis()
@ -74,9 +83,5 @@
span.title
font-weight: 500
color: var(--text-p1)
line-height: 1.2
margin: 4px 0
span.url
color: var(--text-p3)
line-height: 1.4
margin: 2px 0