Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(link): add external_link #116

Merged
merged 6 commits into from Nov 12, 2019
Merged

Conversation

curbengh
Copy link
Contributor

@curbengh curbengh commented Nov 8, 2019

This feature is introduced due to perf cost of the external_link filter. When use in renderer, it can be applied directly to links, instead of a filter which has to first parse the whole site content to look for links.

To take advantage of the perf improvement, external_link: of the site config needs to be disabled.

Configuration:

external_link:
  enable: false

marked:
  external_link:
    enable: true

Some notes:

  1. This feature is only applicable to []() markdown syntax, not raw <a>.
  2. This is not a duplicate hexo's external_link as that works on <a> element, not markdown.
    • hexo's external_link applies to every <a> regardless the source is raw <a> or []() (that is later rendered as <a>)
    • this also means the plugin uses its own external_link config, separate from the external_link site config.
  3. This feature applies to post and page, but not theme layout (see point 1).
  4. This should be compatible with hexo's external_link, meaning both hexo and this renderer's external_link can be enabled at the same time. hexo's external_link does avoid duplicate attributes.
  5. isExternalLink could not be used here as that utility uses site config (i.e. external_link site config), whereas this plugin has its own external_link config.

Ref: hexojs/hexo#3833 (comment)

@curbengh curbengh requested a review from a team November 8, 2019 04:55
@coveralls
Copy link

coveralls commented Nov 8, 2019

Coverage Status

Coverage increased (+1.8%) to 95.313% when pulling b4e83a4 on curbengh:external-link into 2394623 on hexojs:master.

@curbengh
Copy link
Contributor Author

curbengh commented Nov 8, 2019

nofollow could also be implemented, after this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants