Skip to content

Commit

Permalink
feat: add hexo type define
Browse files Browse the repository at this point in the history
  • Loading branch information
wherewhere committed Jan 14, 2025
1 parent a36d5ef commit 9fa79f7
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* global hexo */
'use strict'

/** @typedef {import("@types/hexo")} */

hexo.config.minify = {
enable: true,
previewServer: true,
Expand Down
4 changes: 4 additions & 0 deletions lib/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,6 +26,9 @@ async function minifyCss(str, data) {
}
}

/**
* @this {import('@types/hexo')}
*/
function minifyCssWithMap() {
const hexo = this
const options = hexo.config.minify.css
Expand Down
1 change: 1 addition & 0 deletions lib/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lib/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,6 +32,9 @@ async function minifyJs(str, data) {
}
}

/**
* @this {import('@types/hexo')}
*/
function minifyJsWithMap() {
const hexo = this
const options = hexo.config.minify.js
Expand Down
3 changes: 3 additions & 0 deletions lib/json.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions lib/xml.js
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
6 changes: 6 additions & 0 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -40,6 +43,9 @@ function gzipFn() {
}))
}

/**
* @this {import('@types/hexo')}
*/
function brotliFn() {
const hexo = this
const options = hexo.config.minify.brotli
Expand Down
3 changes: 3 additions & 0 deletions lib/zstd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9fa79f7

Please sign in to comment.