Skip to content

Latest commit

 

History

History
477 lines (359 loc) · 12 KB

helpers.md

File metadata and controls

477 lines (359 loc) · 12 KB

Functions

asset_url(slug, [post])string

Get URL of asset.
If asset is in _posts, then return URL from post-asset. Otherwise return URL from source.

compile_sass(css)string

Compile post(page)-specific SA(C)SS

full_url(url)string | void

Get fully url from relative/absolute URL.
In development mode, keep the given URL for demonstration

generate_uid()string

Generate unique id consisting of lowercase letters and numbers, like i49ygg04c64

archive_array(year)array

Get archive post list

archive_map()yearlyPosts

Get archives data mapped by year and month

icon_info(icon)IconInfo

Get name and category of icon from fontawesome

kor_josa(word, postposition)string

Generate appropriate postposition to the word for Korean

list_categories(categories, options)string

Insert a list of all categories
This is inspired from hexo listCategoriesHelper helper

list_links(links, options)string

Insert a list of external links
This is inspired from hexo listCategoriesHelper helper

list_menus(menus, options)string

Insert a list of menu
This is inspired from hexo listCategoriesHelper helper

open_graph(options)string

Insert OpenGraph data
This is inspired from hexo openGraphHelper.
Added hero config on theme and page into images entry

paginator(options)string

Insert pagination
This is inspired from hexo paginator helper. Improved accessibility more.

representative_image(page)ImageProbe

Get representative image object

strip_html(str)string

Strip HTML tags from string
The addition of highlightJS generated line indicator and special character conversion is different from hexo one.

truncate(str, len)string

Truncate by word to avoid making the sentence difficult to understand due to truncated by letter

Typedefs

archivePost : object

post data object for archive

monthlyPosts : Map.<number, Array.<archivePost>>
yearlyPosts : Map.<number, monthlyPosts>
IconInfo : object
ImageProbe : Object | null

asset_url(slug, [post]) ⇒ string

Get URL of asset.
If asset is in _posts, then return URL from post-asset. Otherwise return URL from source.

Kind: global function
Access: public

Param Type Description
slug string the slug of asset
[post] object the Post data from Hexo

Example

asset_url(post.thumbnail, post)

compile_sass(css) ⇒ string

Compile post(page)-specific SA(C)SS

Kind: global function
Access: public

Param Type Description
css string SA(C)SS for processing

Example

if page.style
  style
    != compile_sass(page.style)

full_url(url) ⇒ string | void

Get fully url from relative/absolute URL.
In development mode, keep the given URL for demonstration

Kind: global function
Access: public

Param Type
url string

Example

a(href= full_url(`/search`)

generate_uid() ⇒ string

Generate unique id consisting of lowercase letters and numbers, like i49ygg04c64

Kind: global function
Access: public
Example

a(id= generate_uid())

archive_array(year) ⇒ array

Get archive post list

Kind: global function
Returns: array - array of posts
Access: public

Param Type Description
year number the archive year.
If year is specify, return all posts for year. Otherwise, return posts up to last MAX_YEAR_LEN (_config.yml) years.

Example

- const archiveItems = getArchivePostsArray();
- const archiveItems = getArchivePostsArray(2023);

archive_map() ⇒ yearlyPosts

Get archives data mapped by year and month

Kind: global function
Access: public
Example

+archiveTimeline({
  archives: archive_map(),
  headingLevel: 2,
})

icon_info(icon) ⇒ IconInfo

Get name and category of icon from fontawesome

Kind: global function
Access: public

Param Type Description
icon string the name of icon, you can predefine icon category with slashes and words after slashes

Example

- const { iconName, iconCategory } = icon_info("bell")
- const { iconName, iconCategory } = icon_info("bell/regular")

kor_josa(word, postposition) ⇒ string

Generate appropriate postposition to the word for Korean

Kind: global function
Access: public

Param Type Description
word string the word to which want to add a postposition
postposition string kind of postposition (은/는, 이/가, 을/를)

Example

p= title + kor_josa(title, "")
p= title + kor_josa(title, "")
p= title + kor_josa(title, "")
p= title + kor_josa(title, "")
p= title + kor_josa(title, "")
p= title + kor_josa(title, "")

list_categories(categories, options) ⇒ string

Insert a list of all categories
This is inspired from hexo listCategoriesHelper helper

Kind: global function
Access: public

Param Type Description
categories object the iterable object of categories from Hexo
options object See https://hexo.io/docs/helpers#list-categories

Example

div
 | !{list_categories({})}

list_links(links, options) ⇒ string

Insert a list of external links
This is inspired from hexo listCategoriesHelper helper

Kind: global function
Access: public

Param Type Description
links Array.<{name: string, url: string}> the array of object that is consists of name and url
options object the configuration object
options.transform function The function that changes the display of link name
options.class string class name of link list

Example

div
 | !{list_links({})}

list_menus(menus, options) ⇒ string

Insert a list of menu
This is inspired from hexo listCategoriesHelper helper

Kind: global function
Access: public

Param Type Description
menus Array.<object> the menu from theme config
options object the configuration object
options.transform function The function that changes the display of menu name
options.class string class name of menu list

Example

div
 | !{list_menus({})}

open_graph(options) ⇒ string

Insert OpenGraph data
This is inspired from hexo openGraphHelper.
Added hero config on theme and page into images entry

Kind: global function
Access: public

Param Type Description
options object See https://hexo.io/docs/helpers#open-graph

Example

| !{ open_graph() }

paginator(options) ⇒ string

Insert pagination
This is inspired from hexo paginator helper. Improved accessibility more.

Kind: global function
Access: public

Param Type Description
options object @see https://hexo.io/docs/helpers#paginator

Example

| !{ paginator({ base: `/` }) }

representative_image(page) ⇒ ImageProbe

Get representative image object

Kind: global function
Access: public

Param Type Description
page object page object from hexo

Example

- const hero = representative_image(theme);

strip_html(str) ⇒ string

Strip HTML tags from string
The addition of highlightJS generated line indicator and special character conversion is different from hexo one.

Kind: global function
Access: public

Param Type Description
str string the original string

Example

p= strip_html(post.content)

truncate(str, len) ⇒ string

Truncate by word to avoid making the sentence difficult to understand due to truncated by letter

Kind: global function
Access: public

Param Type
str string
len number

archivePost : object

post data object for archive

Kind: global typedef
Properties

Name Type
title string
subtitle string
permalink string
date Moment
categories SchemaTypeArray

monthlyPosts : Map.<number, Array.<archivePost>>

Kind: global typedef


yearlyPosts : Map.<number, monthlyPosts>

Kind: global typedef


IconInfo : object

Kind: global typedef
Properties

Name Type
iconName string
iconCategory string

ImageProbe : Object | null

Kind: global typedef
Properties

Name Type Description
path string
width number
height number
type string type of image, usually file name extension
mime string
wUnits string
hUnits string