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(full_url_for): utilize hexo-util module #3701

Merged
merged 4 commits into from Sep 17, 2019

Conversation

@SukkaW
Copy link
Member

SukkaW commented Sep 2, 2019

What does it do?

hexojs/hexo-util#84

Returns a url with the config.url prefixed.

Use Case 1

link[canonical] tag, which is one of a best practice for SEO, needs an absolute url of current page.

According to the test carried out by theme NexT team:

{{ page.permalink }} works on every page exclude index and archive page.
{{ url }} is everywhere.

A full_url_for(page.path) can be used in this case.

Use Case 2

Use url to share the post at social media, which is similar to the first case:

  • Sina Weibo http://service.weibo.com/share/share.php?appkey=&title=[title]&url=[url]&pic=[site logo]&searchPic=false&style=simple
  • Twitter https://twitter.com/intent/tweet?text=[title]&url=[url]
  • Facebook https://www.facebook.com/sharer/sharer.php?u=[url]
  • Telegram https://t.me/share/url?url=[url]&text=[title]

Absolute urls are needed for [url] and [site logo], and full_url_for(page.path) & full_url_for(${site_logo_url}) can be used.

Use Case 3

All examples of structured data (Image, Page path...) and open-graph use absolute urls. If they are best practices, then full_url_for helper can be used.

How to test

git clone -b full_url_for https://github.com/sukkaw/hexo.git
cd hexo
npm install
npm test

Screenshots

I have implemented a _full_url_for for my suka theme and it works perfectly.

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.
@SukkaW SukkaW added this to the Candidate next release milestone Sep 2, 2019
@coveralls

This comment has been minimized.

Copy link

coveralls commented Sep 2, 2019

Coverage Status

Coverage increased (+0.003%) to 97.222% when pulling bfd8b0a on SukkaW:full_url_for into bc474dc on hexojs:master.

@SukkaW

This comment has been minimized.

Copy link
Member Author

SukkaW commented Sep 4, 2019

This might be a alternate solution for #3604

@SukkaW

This comment has been minimized.

Copy link
Member Author

SukkaW commented Sep 15, 2019

Test will be passed after hexo's dependencies updates.

@SukkaW SukkaW changed the title feat(helper): bring up a full_url_for helper feat(full_url_for): utilize hexo-util module Sep 15, 2019
@SukkaW SukkaW requested a review from hexojs/core Sep 15, 2019
'use strict';
const { full_url_for } = require('hexo-util');

module.exports = function(path = '/') {

This comment has been minimized.

Copy link
@curbengh

curbengh Sep 15, 2019

Contributor

can be just path, hexo-util.full_url_for() already set default parameter.

This comment has been minimized.

Copy link
@SukkaW

SukkaW Sep 16, 2019

Author Member

Fixed, and related test has been added.

@curbengh

This comment has been minimized.

Copy link
Contributor

curbengh commented Sep 15, 2019

Test will be passed after hexo's dependencies updates.

Just update hexo-util to ^1.2.0.

https://github.com/hexojs/hexo/pull/3710/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R48


I'll merge this for v4. @SukkaW

@SukkaW SukkaW force-pushed the SukkaW:full_url_for branch from 3e75be3 to bfd8b0a Sep 16, 2019
@curbengh curbengh merged commit 19ac152 into hexojs:master Sep 17, 2019
4 checks passed
4 checks passed
Travis CI - Pull Request Build Passed
Details
codeclimate All good!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
coverage/coveralls Coverage increased (+0.003%) to 97.222%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.