-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
This might be a alternate solution for #3604 |
Test will be passed after hexo's dependencies updates. |
lib/plugins/helper/full_url_for.js
Outdated
'use strict'; | ||
const { full_url_for } = require('hexo-util'); | ||
|
||
module.exports = function(path = '/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be just path
, hexo-util.full_url_for()
already set default parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, and related test has been added.
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 |
3e75be3
to
bfd8b0a
Compare
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:
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:
http://service.weibo.com/share/share.php?appkey=&title=[title]&url=[url]&pic=[site logo]&searchPic=false&style=simple
https://twitter.com/intent/tweet?text=[title]&url=[url]
https://www.facebook.com/sharer/sharer.php?u=[url]
https://t.me/share/url?url=[url]&text=[title]
Absolute urls are needed for
[url]
and[site logo]
, andfull_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
Screenshots
I have implemented a
_full_url_for
for my suka theme and it works perfectly.Pull request tasks