diff --git a/package.json b/package.json index 636f019..0edbd9c 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,14 @@ "version": "1.1.0", "private": true, "hexo": { - "version": "4.2.0" + "version": "4.2.1" }, "scripts": { "dev": "hexo server", "build": "gulp" }, "dependencies": { - "hexo": "^4.2.0", + "hexo": "^4.2.1", "hexo-generator-archive": "^1.0.0", "hexo-generator-baidu-sitemap": "^0.1.6", "hexo-generator-category": "^1.0.0", @@ -33,4 +33,4 @@ "nunjucks": "^3.2.0", "optimist": "^0.6.1" } -} +} \ No newline at end of file diff --git a/scaffolds/draft.md b/scaffolds/draft.md deleted file mode 100644 index 498e95b..0000000 --- a/scaffolds/draft.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: {{ title }} -tags: ---- diff --git a/scaffolds/page.md b/scaffolds/page.md deleted file mode 100644 index f01ba3c..0000000 --- a/scaffolds/page.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: {{ title }} -date: {{ date }} ---- diff --git a/scaffolds/post.md b/scaffolds/post.md deleted file mode 100644 index 1f9b9a4..0000000 --- a/scaffolds/post.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: {{ title }} -date: {{ date }} -tags: ---- diff --git a/scripts/generator.js b/scripts/generator.js index aab7165..b70494a 100644 --- a/scripts/generator.js +++ b/scripts/generator.js @@ -11,7 +11,18 @@ const searchTmplSrc = path.join(__dirname, '../templates/articles.xml') hexo.extend.generator.register('xml', function(locals){ const searchTmpl = nunjucks.compile(fs.readFileSync(searchTmplSrc, 'utf8'), env) - const posts = locals.posts.sort('-date').toArray().slice(0, 10) + const descCompare = function(value1, value2) { + if(value1 > value2) { + return -1 + } else if(value1 < value2) { + return 1 + } else { + return 0 + } + } + const posts = locals.posts.toArray().sort(function(item1, item2){ + return descCompare(item1.updateDate || item1.date, item2.updateDate || item2.date) + }).slice(0, 10) const xmlData = searchTmpl.render({ posts, root: this.config.root diff --git a/source/_posts/前端杂烩/原生CSS变量.md b/source/_posts/前端杂烩/原生CSS变量.md index f0f500f..bd24027 100644 --- a/source/_posts/前端杂烩/原生CSS变量.md +++ b/source/_posts/前端杂烩/原生CSS变量.md @@ -1,6 +1,7 @@ --- title: 原生CSS变量 date: 2020-10-23 15:10:46 +updateDate: 2021-04-26 11:51:23 tags: - 前端 - css @@ -86,4 +87,39 @@ let value2 = getComputedStyle(box).getPropertyValue('--text-color') --box-width: 300; width: calc(var(--box-width) * 1px); } -``` \ No newline at end of file +``` + + + +### 区分于编程语言中的变量 +原生CSS的变量,将其称为**自定义属性**更为合理 +因为它和编程语言中的变量有很大不同 +比如 + +#### important +```css +.box1 { + --text-color: red !important; + color: var(--text-color); + color: blue; +} +.box2 { + --text-color: red !important; + --text-color: blue; + color: var(--text-color); +} +``` +如果在变量上加`!important`,是作用在这个变量(自定义属性)上,而不属于变量的值 +所以上述代码实际效果是box1是blue,box2是red + +#### 属性的覆盖 +```css +.box { + --s: 10px; + margin: var(--s); + --s: 20px; + padding: var(--s); +} +``` +上述代码的实际效果,margin和padding都会是20px +因为后一次自定义属性的定义覆盖了第一次,与常规编程语言中的变量先定义后使用的逻辑不同 \ No newline at end of file diff --git a/themes/yilia/layout/_partial/post/category.ejs b/themes/yilia/layout/_partial/post/category.ejs index 8930601..1f723e6 100644 --- a/themes/yilia/layout/_partial/post/category.ejs +++ b/themes/yilia/layout/_partial/post/category.ejs @@ -1,12 +1,12 @@ <% if (post.categories && post.categories.length){ %> -