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

baseUrl's value sometimes wrong when referencing inner website's content #262

Closed
damithc opened this issue Jun 11, 2018 · 3 comments · Fixed by #263
Closed

baseUrl's value sometimes wrong when referencing inner website's content #262

damithc opened this issue Jun 11, 2018 · 3 comments · Fixed by #263
Assignees

Comments

@damithc
Copy link
Contributor

damithc commented Jun 11, 2018

v1.8.0 (not the latest version)

Consider this page:
https://github.com/nus-cs2103/website-base/edit/master/se-book-adapted/chapters/test.md

Rendered version:
https://nus-cs2103.github.io/website-base/se-book-adapted/chapters/test.html

It's the same content included twice, once directly (i.e., text.md#body), once indirectly (i.e., index.md). Surprisingly, the direct version has broken image links while the indirect version that goes through further variables, includes, and boilerplates seems to have the correct image links.

Any idea what's going on?

BTW, it works locally. The problem happens when I deploy.

@yamgent
Copy link
Member

yamgent commented Jun 12, 2018

Preliminary finding: {{hostBaseUrl}} were different values at different stages of the rendering, and both parts had their variables replaced at different times. Update: Apparently not, it seems that the computation algorithm of the baseUrl is implemented wrongly instead. Will get a PR up soon.

Still investigating this issue.

yamgent added a commit to yamgent/markbind-problems that referenced this issue Jun 12, 2018
This commit replicates the bug in MarkBind/markbind#262.
@yamgent yamgent self-assigned this Jun 12, 2018
@yamgent yamgent changed the title Help needed: debugging broken image links baseUrl's value sometimes wrong when referencing inner website's content Jun 12, 2018
@yamgent
Copy link
Member

yamgent commented Jun 18, 2018

@damithc FYI, the first issue (see below) can immediately be fixed by making changes on your side in website-base: yamgent/website-base@4f74fdb

I have found the fix for the second issue, and modified PR #263 accordingly. Will have to wait for that to be merged before the images work.


1. CSS url issue

Affected webpage: https://nus-cs2103.github.io/website-base/se-book-adapted/chapters/architecture.html

Description: The URL to the CSS (textbook.css) did not work (resulting in a stretched webpage effect), as it uses the {{baseUrl}} variable.

Why the Bug Exist: When using nunjucks' import feature, nunjucks will ignore any variables declared inside the imported file, unless it is specified to import the file "with context".

Solution: If we want to use {{baseUrl}} for the URL to the CSS file, we must use the keywords "with context" when importing "config.md" and "chapter.md". The commit that fixes this can be found here.

2. Broken image issue

Affected webpages: https://nus-cs2103.github.io/website-base/se-book-adapted/chapters/architecture.html, https://nus-cs2103.github.io/website-base/se-book-adapted/chapters/test.html

Description: The images are broken because the URL to the images are wrong (the baseUrl appears to be missing).

Why the Bug Exist: I have traced down the issue to {{hostBaseUrl}} being prematurely replaced when the value is not injected yet.

Solution: I have fixed the behavior, and the fix is in PR #263. The images will no longer be broken after the PR is merged.

How the webpages look like after applying the fixes

@damithc
Copy link
Contributor Author

damithc commented Jun 18, 2018

Yup, the CSS url issue worked. Thanks for finding the workaround 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants