feat: add hexo type define

This commit is contained in:
wherewhere 2025-01-14 16:59:59 +08:00
parent a36d5ef2df
commit 9fa79f78d1
9 changed files with 29 additions and 0 deletions

View File

@ -1,6 +1,8 @@
/* global hexo */
'use strict'
/** @typedef {import("@types/hexo")} */
hexo.config.minify = {
enable: true,
previewServer: true,

View File

@ -5,6 +5,7 @@ const { isMatch, match, logFn } = require('./tools')
/**
* @param {string} str
* @param {{ path: string }} data
* @this {import('@types/hexo')}
*/
async function minifyCss(str, data) {
const hexo = this
@ -25,6 +26,9 @@ async function minifyCss(str, data) {
}
}
/**
* @this {import('@types/hexo')}
*/
function minifyCssWithMap() {
const hexo = this
const options = hexo.config.minify.css

View File

@ -5,6 +5,7 @@ const { isMatch, logFn } = require('./tools')
/**
* @param {string} str
* @param {{ path: string }} data
* @this {import('@types/hexo')}
*/
async function minifyHtml(str, data) {
const hexo = this

View File

@ -5,6 +5,7 @@ const { isMatch, match, logFn } = require('./tools')
/**
* @param {string} str
* @param {{ path: string }} data
* @this {import('@types/hexo')}
*/
async function minifyJs(str, data) {
const hexo = this
@ -31,6 +32,9 @@ async function minifyJs(str, data) {
}
}
/**
* @this {import('@types/hexo')}
*/
function minifyJsWithMap() {
const hexo = this
const options = hexo.config.minify.js

View File

@ -1,6 +1,9 @@
'use strict'
const { match, logFn } = require('./tools')
/**
* @this {import('@types/hexo')}
*/
function minifyJson() {
const hexo = this
const options = hexo.config.minify.json

View File

@ -2,6 +2,9 @@
const { optimize: svgOptimize } = require('svgo')
const { match, logFn } = require('./tools')
/**
* @this {import('@types/hexo')}
*/
function minifySvg() {
const hexo = this
const options = hexo.config.minify.svg

View File

@ -1,6 +1,9 @@
'use strict'
const { match, logFn } = require('./tools')
/**
* @this {import('@types/hexo')}
*/
async function minifyXml() {
const { minify: compressXml } = await import('minify-xml')

View File

@ -5,6 +5,9 @@ const gzip = promisify(zlib.gzip)
const br = promisify(zlib.brotliCompress)
const { match, logFn } = require('./tools')
/**
* @this {import('@types/hexo')}
*/
function gzipFn() {
const hexo = this
const options = hexo.config.minify.gzip
@ -40,6 +43,9 @@ function gzipFn() {
}))
}
/**
* @this {import('@types/hexo')}
*/
function brotliFn() {
const hexo = this
const options = hexo.config.minify.brotli

View File

@ -25,6 +25,9 @@ function importZstd() {
const { compress: zstd, init = undefined } = importZstd()
const { match, logFn } = require('./tools')
/**
* @this {import('@types/hexo')}
*/
async function zstdFn() {
const hexo = this
const options = hexo.config.minify.zstd