diff --git a/layout/_partials/layout.pug b/layout/_partials/layout.pug index de3d196..0ef99d9 100644 --- a/layout/_partials/layout.pug +++ b/layout/_partials/layout.pug @@ -6,10 +6,19 @@ include ../_mixin/widgets.pug if (theme.quicklink.ignores) - ignores.push(theme.quicklink.ignores) +- var covers = _cover_index(page, 6) +- var enableFixedCover = theme.homeConfig?.fixedCover + doctype html html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'filter: grayscale(1);':'' ) head != partial('_partials/head/head.pug', {}, {cache: true}) + if enableFixedCover + link(rel="preload" href=theme.homeConfig.fixedCover as="image" fetchpriority="high") + else + each image in covers + link(rel="preload" href=image as="image" fetchpriority="high") + != partial('_partials/head/head_com.pug') != shokax_inject('head') title @@ -35,12 +44,11 @@ html(lang=page.language?page.language:config.language, style=theme.grayMode ? 'f != partial('_partials/header.pug', {}, {cache: true}) div(id="imgs" class="pjax") - if theme.homeConfig.gradient || theme.homeConfig.fixedCover + if theme.homeConfig.gradient || enableFixedCover //- cover不可用时用Bing随机图片代替 - - var coverImage = theme.homeConfig.fixedCover || "https://7ed.net/bing/api" + - var coverImage = theme.homeConfig?.fixedCover || "https://7ed.net/bing/api" img(src=coverImage loading="eager" decoding="async" fetchpriority="high") else - - var covers = _cover_index(page, 6) if covers.length === 6 ul each image in covers diff --git a/package.json b/package.json index 71eee18..9b11cec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-shokax", - "version": "0.4.0", + "version": "0.4.1", "description": "a hexo theme based on shoka", "main": "index.js", "repository": "https://github.com/theme-shoka-x/hexo-theme-shokaX", diff --git a/scripts/helpers/asset.ts b/scripts/helpers/asset.ts index 62bb5dd..72ae0f3 100644 --- a/scripts/helpers/asset.ts +++ b/scripts/helpers/asset.ts @@ -5,11 +5,6 @@ import theme_env from '../../package.json' import { htmlTag, url_for, stripHTML } from 'hexo-util' import { getVendorLink } from '../utils' -// TODO 弃用函数 -hexo.extend.helper.register('_new_comments', function (mode) { - return '' -}) - hexo.extend.helper.register('_safedump', (source) => { return JSON.stringify(source) }) @@ -50,7 +45,9 @@ hexo.extend.helper.register('_vendor_font', () => { return fontFamilies ? htmlTag('link', { rel: 'stylesheet', - href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}` + href: `${fontHost}/css?family=${fontFamilies.concat(fontDisplay, fontSubset)}`, + media: 'none', + onload: "this.media='all'" }) : '' }) @@ -76,9 +73,6 @@ hexo.extend.helper.register('vendor_js', function () { for (const jsSync in vendors.js) { res += htmlTag('script', { src: getVendorLink(hexo, vendors.js[jsSync]), async: true }, '') } - // for (const jsAsync in vendors.async_js) { - // res += htmlTag('script', { src: getVendorLink(hexo, vendors.async_js[jsAsync]), async: true }, '') - // } return res }) diff --git a/scripts/plugin/index.ts b/scripts/plugin/index.ts index 9a5807a..4d72865 100644 --- a/scripts/plugin/index.ts +++ b/scripts/plugin/index.ts @@ -22,10 +22,10 @@ hexo.on('generateBefore', () => { hexo.on('generateAfter', () => { // 检查版本更新 - fetch('https://api.github.com/repos/theme-shoka-x/hexo-theme-shokaX/releases/latest').then((res) => { + fetch('https://registry.npmmirror.com/hexo-theme-shokax').then((res) => { res.json().then((resp) => { try { - const latest = resp.tag_name.replace('v', '').split('.') + const latest = resp['dist-tags'].latest const current = version.split('.') let isOutdated = false for (let i = 0; i < Math.max(latest.length, current.length); i++) {