From 8e080e7e275487b06b66d1912f4af7c435a1026e Mon Sep 17 00:00:00 2001
From: Mimi <1119186082@qq.com>
Date: Sun, 7 Jun 2020 11:30:08 +0800
Subject: [PATCH] Optimize the style of label tag
---
scripts/tags/label.js | 2 +-
.../_common/components/pages/categories.styl | 2 --
.../css/_common/scaffolding/tags/label.styl | 27 +++----------------
source/css/_common/scaffolding/tags/note.styl | 1 -
source/css/_variables/base.styl | 1 +
5 files changed, 6 insertions(+), 27 deletions(-)
diff --git a/scripts/tags/label.js b/scripts/tags/label.js
index 5bd3f0e..bc3855a 100644
--- a/scripts/tags/label.js
+++ b/scripts/tags/label.js
@@ -13,7 +13,7 @@ function postLabel(args) {
!text && hexo.log.warn('Label text must be defined!');
- return `${text}`;
+ return `${text}`;
}
hexo.extend.tag.register('label', postLabel, {ends: false});
diff --git a/source/css/_common/components/pages/categories.styl b/source/css/_common/components/pages/categories.styl
index 504f41f..130c58f 100644
--- a/source/css/_common/components/pages/categories.styl
+++ b/source/css/_common/components/pages/categories.styl
@@ -22,12 +22,10 @@
&::before {
content: ' (';
- display: inline;
}
&::after {
content: ') ';
- display: inline;
}
}
diff --git a/source/css/_common/scaffolding/tags/label.styl b/source/css/_common/scaffolding/tags/label.styl
index 70c30c7..c07c034 100644
--- a/source/css/_common/scaffolding/tags/label.styl
+++ b/source/css/_common/scaffolding/tags/label.styl
@@ -1,29 +1,10 @@
.post-body .label {
color: $text-color;
- display: inline;
padding: 0 2px;
- &.default {
- background: $label-default;
- }
-
- &.primary {
- background: $label-primary;
- }
-
- &.info {
- background: $label-info;
- }
-
- &.success {
- background: $label-success;
- }
-
- &.warning {
- background: $label-warning;
- }
-
- &.danger {
- background: $label-danger;
+ for $type in $note-types {
+ &.{$type} {
+ background: lookup('$label-' + $type);
+ }
}
}
diff --git a/source/css/_common/scaffolding/tags/note.styl b/source/css/_common/scaffolding/tags/note.styl
index 1851204..ee60aa4 100644
--- a/source/css/_common/scaffolding/tags/note.styl
+++ b/source/css/_common/scaffolding/tags/note.styl
@@ -1,7 +1,6 @@
.post-body .note {
$note-icons = hexo-config('note.icons');
$note-style = hexo-config('note.style');
- $note-types = 'default' 'primary' 'info' 'success' 'warning' 'danger';
border-radius: $note-border-radius;
margin-bottom: 20px;
diff --git a/source/css/_variables/base.styl b/source/css/_variables/base.styl
index b2d7562..705342e 100644
--- a/source/css/_variables/base.styl
+++ b/source/css/_variables/base.styl
@@ -278,6 +278,7 @@ $post-eof-margin-bottom = 60px; // or 120px for less white space;
// --------------------------------------------------
// Read note light_bg_offset from NexT config and set in "$lbg%" to use it as string variable.
$lbg = hexo-config('note.light_bg_offset') is a 'unit' ? unit(hexo-config('note.light_bg_offset'), "%") : 0;
+$note-types = 'default' 'primary' 'info' 'success' 'warning' 'danger';
// Default
$note-border-radius = 3px;