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

Conversation

SukkaW
Copy link
Member

@SukkaW 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 November 17, 2019 10:17
@SukkaW SukkaW mentioned this pull request Nov 17, 2019
@coveralls
Copy link

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 November 17, 2019 18:48
Copy link
Member

@yoshinorin yoshinorin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url_for & full url_for implementations are LGTM.

@curbengh
Copy link
Contributor

LGTM too.

@SukkaW SukkaW marked this pull request as ready for review November 22, 2019 13:12
@curbengh
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 curbengh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@SukkaW
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
@curbengh
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
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants