Skip to content

Commit

Permalink
Merge pull request #235 from zkz098/main
Browse files Browse the repository at this point in the history
perf: 改进LCP & 优化谷歌字体
  • Loading branch information
zkz098 authored Feb 14, 2024
2 parents 8807c6f + 9fcfdc8 commit 69a3cd2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
14 changes: 11 additions & 3 deletions layout/_partials/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 3 additions & 9 deletions scripts/helpers/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down Expand Up @@ -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'"
})
: ''
})
Expand 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
})

Expand Down
4 changes: 2 additions & 2 deletions scripts/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 69a3cd2

Please sign in to comment.