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

Fixes: Some assets is 404 when baseurl isn't empty and assets is 'self_host' #590

Closed
wants to merge 0 commits into from

Conversation

LawssssCat
Copy link
Contributor

@LawssssCat LawssssCat commented Jun 1, 2022

Description

Fixes: Some assets is 404 when baseurl isn't empty and assets is 'self_host'

baseurl: /i-am-not-empty
assets:
  self_host: true
    enabled:      # boolean, keep empty means false
    # specify the Jekyll environment, empty means both
    # only works if `assets.self_host.enabled` is 'true'
    env:          # [development|production]

image

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How has this been tested

  • I have run bash ./tools/deploy.sh --dry-run (at the root of the project) locally and passed
  • I have tested this feature in the browser

Test Configuration

  • Browser type & version: chrome
  • Operating system: win10
  • Ruby version: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
  • Bundler version: Bundler version 2.3.14
  • Jekyll version: * jekyll (4.2.2)

Checklist

  • I have performed a self-review of my code
  • I have commented on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

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

Thanks for reporting this bug. However, in your patch, cross-domain URLs will also be filtered by relative_url, which is not necessary and will affect the readability of the code. So maybe a better way is to handle baseurl in _data/assets/self_host.yml

@LawssssCat
Copy link
Contributor Author

Thanks for reporting this bug. However, in your patch, cross-domain URLs will also be filtered by relative_url, which is not necessary and will affect the readability of the code. So maybe a better way is to handle baseurl in _data/assets/self_host.yml

It may affect readability, but this relative_url is officially provided by liquid, so everyone should be aware of its function, and the liquid seems to have a hunch that relative_url will be uesed to filter cross-domain URLs so it doesn't seem to do extra processing for cross-domain URLs. On the contrary, every time you modify the baseurl, you need to modify _data/assets/self_host.yml synchronously, which makes me fell very troublesome, so I think relative_url should be added.

@cotes2020
Copy link
Owner

Maybe you don't get my point, of course we need relative_url, but I mean it should be used in the file _data/assets/self_host.yml, not in those HTML files.

@LawssssCat
Copy link
Contributor Author

Maybe you don't get my point, of course we need relative_url, but I mean it should be used in the file _data/assets/self_host.yml, not in those HTML files.

Yes, I didn't understand what you were trying to du, because I just tried it and relative_url doesn't seem to work in _data/*
(Is there any syntax I don't know yet?)

---
---

# fonts

webfonts: {{ "/assets/lib/fonts/main.css" | relative_url }}

@cotes2020
Copy link
Owner

Well, I didn't notice that Jekyll doesn't support parsing Liquid filters in data files, so adding baseurl in the HTML file is the only option left, will merge this PR.

| append: ',' | append: site.data.assets[origin].dayjs.js.locale
| replace: ':LOCALE', locale
| append: ',' | append: site.data.assets[origin].dayjs.js.relativeTime
| append: ',' | append: site.data.assets[origin].dayjs.js.localizedFormat
Copy link
Owner

Choose a reason for hiding this comment

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

Please undo these indents

Comment on lines 18 to 19
| append: ',' | append: site.data.assets[origin].lozad.js
| append: ',' | append: site.data.assets[origin].clipboard.js
Copy link
Owner

Choose a reason for hiding this comment

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

And undo these, too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And undo these, too

done. 👌

@LawssssCat LawssssCat requested a review from cotes2020 June 2, 2022 00:25
Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

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

If you can, squash all your commits, then rebase to the latest commit on the master branch.

{% endif %}

<!-- JavaScript -->

<script src="{{ site.data.assets[origin].jquery.js }}"></script>
<script src="{{ site.data.assets[origin].jquery.js | relative_url }}"></script>
Copy link
Owner

Choose a reason for hiding this comment

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

Please remove one space before |

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.

2 participants