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: apply pretty_url to url_for & full_url_for #134

Merged
merged 1 commit into from Nov 23, 2019
Merged

Conversation

@SukkaW
Copy link
Member

SukkaW commented Nov 17, 2019

I have noticed url_for & full_url_for will not remove index.html while trailing_index is disabled. This PR is addressed to make the trailing_index behavior more consistent.

I haven't apply pretty_url options to relative_url() yet because relative_url doesn't require bind(hexo) and can not read hexo.config directly. After we finish relative_url() I will make this PR "Ready to Review".

@SukkaW SukkaW requested a review from curbengh Nov 17, 2019
@SukkaW SukkaW mentioned this pull request Nov 17, 2019
@coveralls

This comment has been minimized.

Copy link

coveralls commented Nov 17, 2019

Coverage Status

Coverage increased (+0.02%) to 95.302% when pulling 07705cd on SukkaW:pretty_url into beb8526 on hexojs:master.

@SukkaW SukkaW requested a review from YoshinoriN Nov 17, 2019
Copy link
Member

YoshinoriN left a comment

url_for & full url_for implementations are LGTM.

@curbengh

This comment has been minimized.

Copy link
Contributor

curbengh commented Nov 20, 2019

LGTM too.

@SukkaW SukkaW marked this pull request as ready for review Nov 22, 2019
@curbengh

This comment has been minimized.

Copy link
Contributor

curbengh commented Nov 23, 2019

how about adding an optional boolean parameter to relative_url()?

relative_url(from, to, true), then remove trailing index.html if false.

I'm assuming ../../ is equivalent to ../../index.html?

Copy link
Contributor

curbengh left a comment

Due to urgency of 1.6, I don't mind holding off relative_url to later.

@SukkaW

This comment has been minimized.

Copy link
Member Author

SukkaW commented Nov 23, 2019

@curbengh pretty_url will have trailing_index, trailing_html, maybe even more options in the future. A simple boolean parameter just won't help.

@SukkaW SukkaW merged commit a5fcfa5 into hexojs:master Nov 23, 2019
3 checks passed
3 checks passed
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
coverage/coveralls Coverage increased (+0.02%) to 95.302%
Details
@curbengh

This comment has been minimized.

Copy link
Contributor

curbengh commented Nov 24, 2019

pretty_url will have trailing_index, trailing_html, maybe even more options in the future.

what about codeblock() tag plugin approach? e.g. relative_url(from, to, { trailing_index: true, trailing_html: true }).

Another idea I just thought of is that making bind(hexo)/call() optional, where those functions can be used as url_for(input, siteConfig). They can check existence of this.config.url and siteConfig.url and respond appropriately.

This is useful where this object doesn't refer to hexo (like in hexo-renderer-marked) or the hexo object can't be accessed directly.

@SukkaW

This comment has been minimized.

Copy link
Member Author

SukkaW commented Nov 24, 2019

I think pass a config as the last parameter could be a good idea. We first check if that parameter is given, if doesn't, then get config from this.

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.