Skip to content
Help you insert <a> snippet in hexo templates. A bit different from Hexo helper `link_to`. Helpers are used in templates to help you insert snippets quickly.
Branch: master
Clone or download
Pull request Compare This branch is 14 commits ahead, 1 commit behind hexojs:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.npmignore
LICENSE
LICENSE_Tommy_Chen
README.md
index.js
package.json

README.md

hexo-helper-link-too

Help you insert <a> snippet in hexo templates. A bit different from Hexo helper link_to.

Helpers are used in templates to help you insert snippets quickly. Helpers cannot be used in source files.

帮助您在Hexo模板文件中插入<a>代码片段。辅助函数帮助您在模版中快速插入内容。辅助函数不能在源文件中使用。

inspired by Hexojs helper link_to.

Because I can't specify the title separately by link_to, I modified the code in lib/plugins/helper/link_to.js.

灵感来自Hexojs的辅助函数link_to

因为无法使用link_to单独指定标题,所以修改了这里的代码lib/plugins/helper/link_to.js

Setup

via npm:

npm i hexo-helper-link-too

Usage

  • in your hexo templates (e.g.: .ejs files),
  • 在您的模板文件中(例如:.ejs文件),
<%- link_too(path, text, options) %>

e.g.:

path

<%- link_too("https://futaba.love") %>
<a href="https://futaba.love" title="futaba.love">futaba.love</a>

path, text

<%- link_too('https://futaba.love', "Futaba Isshiki's Blog") %>
<a href="https://futaba.love" title="Futaba Isshiki\'s Blog">Futaba Isshiki\'s Blog</a>

path, text, boolean

一、options === true

<%- link_too('https://futaba.love', "Futaba Isshiki's Blog", true) %>
<a href="https://futaba.love" title="Futaba Isshiki\'s Blog" target="_blank" rel="noopener nofollow">Futaba Isshiki\'s Blog</a>

二、options === false

<%- link_too('https://futaba.love', "Futaba Isshiki's Blog", false) %>
<a href="https://futaba.love" title="Futaba Isshiki\'s Blog">Futaba Isshiki\'s Blog</a>

三、options.external: true

<%- link_too('https://futaba.love', "Futaba Isshiki's Blog", {external:true}) %>
<a href="https://futaba.love" title="Futaba Isshiki\'s Blog" target="_blank" rel="noopener nofollow">Futaba Isshiki\'s Blog</a>

path, text, options

一、options.title

<%- link_too('https://futaba.love', "Futaba Isshiki's Blog", {title: "I love Hatsune Miku!"}) %>
<a href="https://futaba.love" title="I love Hatsune Miku!">Futaba Isshiki\'s Blog</a>

二、options.external: true & title

<%- link_too('https://futaba.love', "Futaba Isshiki's Blog", {external:true, title: "I Love Hastsune Miku!"}) %>
<a href="https://futaba.love" title="I Love Hastsune Miku!" target="_blank" rel="noopener nofollow">Futaba Isshiki\'s Blog</a>

Tests

Sorry, but there no tests yet.

Changelog

Issues

License

MIT ©Futaba Isshiki

You can’t perform that action at this time.