From dda472f10bf92fb2c6ec9fb387215f801565c698 Mon Sep 17 00:00:00 2001 From: dimaslanjaka Date: Sat, 5 Oct 2024 11:39:50 +0700 Subject: [PATCH] feat: shim hexo-util refer to doc https://hexo.io/api/helper#How-do-I-use-another-registered-helper-in-my-custom-helper --- lib/extend/helper.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/extend/helper.ts b/lib/extend/helper.ts index 9fe13e9fed..37ddb5ae0e 100644 --- a/lib/extend/helper.ts +++ b/lib/extend/helper.ts @@ -1,9 +1,39 @@ import Hexo from '../hexo'; import { PageSchema } from '../types'; +import * as hutil from 'hexo-util'; interface HexoContext extends Hexo { + // get current page information // https://github.com/dimaslanjaka/hexo-renderers/blob/147340f6d03a8d3103e9589ddf86778ed7f9019b/src/helper/related-posts.ts#L106-L113 page?: PageSchema; + + // hexo-util shims + url_for: typeof hutil.url_for; + full_url_for: typeof hutil.full_url_for; + relative_url: typeof hutil.relative_url; + slugize: typeof hutil.slugize; + escapeDiacritic: typeof hutil.escapeDiacritic; + escapeHTML: typeof hutil.escapeHTML; + unescapeHTML: typeof hutil.unescapeHTML; + encodeURL: typeof hutil.encodeURL; + decodeURL: typeof hutil.decodeURL; + escapeRegExp: typeof hutil.escapeRegExp; + stripHTML: typeof hutil.stripHTML; + stripIndent: typeof hutil.stripIndent; + hash: typeof hutil.hash; + createSha1Hash: typeof hutil.createSha1Hash; + highlight: typeof hutil.highlight; + prismHighlight: typeof hutil.prismHighlight; + tocObj: typeof hutil.tocObj; + wordWrap: typeof hutil.wordWrap; + prettyUrls: typeof hutil.prettyUrls; + isExternalLink: typeof hutil.isExternalLink; + gravatar: typeof hutil.gravatar; + htmlTag: typeof hutil.htmlTag; + truncate: typeof hutil.truncate; + spawn: typeof hutil.spawn; + camelCaseKeys: typeof hutil.camelCaseKeys; + deepMerge: typeof hutil.deepMerge; } interface StoreFunction {