Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Dec 15, 2022
1 parent b718ea4 commit 9e2f02f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/helper/open_graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function openGraphHelper(options: Options = {}) {
result += meta('twitter:card', twitterCard);

if (options.twitter_image) {
let twitter_image = options.twitter_image;
let twitter_image: string | URL = options.twitter_image;
twitter_image = new URL(twitter_image, url || config.url);
result += meta('twitter:image', twitter_image, false);
} else if (images.length) {
Expand Down
23 changes: 22 additions & 1 deletion lib/plugins/helper/paginator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,28 @@ const pagenasionPartShow = (tags, options, ctx) => {
}
};

function paginatorHelper(options = {}) {
interface Options {
base?: string;
current?: number;
format?: string;
total?: number;
end_size?: number;
mid_size?: number;
space?: string;
next_text?: string;
prev_text?: string;
prev_next?: boolean;
escape?: boolean;
page_class?: string;
current_class?: string;
space_class?: string;
prev_class?: string;
next_class?: string;
force_prev_next?: boolean;
show_all?: boolean;
}

function paginatorHelper(options: Options = {}) {
options = Object.assign({
base: this.page.base || '',
current: this.page.current || 0,
Expand Down
7 changes: 6 additions & 1 deletion lib/plugins/helper/partial.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import {dirname, join} from 'path';

export = ctx => function partial(name, locals, options = {}) {
interface Options {
cache?: boolean | string;
only?: boolean;
}

export = ctx => function partial(name, locals, options: Options = {}) {
if (typeof name !== 'string') throw new TypeError('name must be a string!');

const { cache } = options;
Expand Down
8 changes: 7 additions & 1 deletion lib/plugins/helper/search_form.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import moize from 'moize';

function searchFormHelper(options = {}) {
interface Options {
class?: string;
text?: string;
button?: string | boolean;
}

function searchFormHelper(options: Options = {}) {
const { config } = this;
const className = options.class || 'search-form';
const { text = 'Search', button } = options;
Expand Down
15 changes: 14 additions & 1 deletion lib/plugins/helper/toc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import {tocObj, escapeHTML, encodeURL} from 'hexo-util';

function tocHelper(str, options = {}) {
interface Options {
min_depth?: number;
max_depth?: number;
class?: string;
class_item?: string;
class_link?: string;
class_text?: string;
class_child?: string;
class_number?: string;
class_level?: string;
list_number?: boolean;
}

function tocHelper(str, options: Options = {}) {
options = Object.assign({
min_depth: 1,
max_depth: 6,
Expand Down

0 comments on commit 9e2f02f

Please sign in to comment.