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

fix: next/prev navigation in docs #2871

Merged
merged 1 commit into from
Nov 4, 2024
Merged

Conversation

fykaa
Copy link
Contributor

@fykaa fykaa commented Oct 29, 2024

fixes: #2870

So, it is a quite strange distinction.

I looked into it more, but I could not find any notable differences between Kargo and Akuity that could lead to a navigation failure in the live document.

Aside from that, I did observe that some versions of Package.json were not updated.

But since the navigation appear well locally, I am not sure how to test this change in the live document to see if updating the version was able to improve things.

cc: @Marvin9 ptal

@fykaa fykaa self-assigned this Oct 29, 2024
@fykaa fykaa requested review from a team as code owners October 29, 2024 17:58
Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for docs-kargo-io ready!

Name Link
🔨 Latest commit 0e3807e
🔍 Latest deploy log https://app.netlify.com/sites/docs-kargo-io/deploys/6728b129ecaf1c0008567adc
😎 Deploy Preview https://deploy-preview-2871.docs.kargo.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 49.98%. Comparing base (8d43018) to head (0e3807e).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2871   +/-   ##
=======================================
  Coverage   49.98%   49.98%           
=======================================
  Files         275      275           
  Lines       24526    24526           
=======================================
  Hits        12259    12259           
  Misses      11596    11596           
  Partials      671      671           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@krancour
Copy link
Member

I am not sure how to test this change in the live document

There is a link for a preview of any documentation modifications in the checks section at the bottom of every PR.

In this case, you will see that the doc build actually fails with these changes.

I don't believe this PR will solve the issue.

What I would suggest is using your browser's tools to attempt identifying a font or any other resource that isn't loading correctly on the live site, which may explain this. It could be that some font has been excluded from the static production build that is included when running locally from a Docusaurus server.

@Marvin9
Copy link
Contributor

Marvin9 commented Oct 29, 2024

Took a glance. I suspect its related to encoding CSS files that docusaurus generates.

One of this or any other reason could be problem

  • character is converted to "?" in css on build time (by css minifier)
  • when browser requests css file and receives it and transform some characters to "?"
  • netlify transforms it based on request headers and gives browser with characters "?"
  • Couldn't think of other reason but there might be

I would start looking at build css files that netlify is serving (if I could download) and search for ".pagination-nav__link--next .pagination-nav__label:after" style

@krancour
Copy link
Member

krancour commented Oct 29, 2024

Here's a new datapoint:

FROM node:latest AS builder

COPY ./docs /docs

WORKDIR /docs

RUN npm install pnpm -g && pnpm install && pnpm build

FROM nginx:alpine

COPY --from=builder /docs/build /usr/share/nginx/html

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
docker build -t site .
docker run -it -p 8080:80 site

Everything works.

So everything comes out ok when:

  • Running locally
  • Building the static site and serving it from Nginx

The issue seems then to only happen with Netlify.

I've noticed warnings in the build logs in the past. Maybe they are worth looking into.

@fykaa
Copy link
Contributor Author

fykaa commented Oct 29, 2024

I would start looking at build css files that netlify is serving (if I could download) and search for ".pagination-nav__link--next .pagination-nav__label:after" style

that suspicion about encoding issues is spot on.
something in the build or deployment process is causing character encoding problems.

.pagination-nav__link--prev .pagination-nav__label::before {
      content: '� ';
    }

.pagination-nav__link--next .pagination-nav__label::after {
      content: ' �';
    }

So everything comes out ok when:
Running locally
Building the static site and serving it from Nginx

i see, so this strengthens the case that the issue is specific to how Netlify handles the build particularly with character encoding in the css

since i dont have access to logs on netlify’s dashboard through gh actions, i am not aware of any warnings that might occur during the css minification. I will try an explicit definition of pagination to bypass encoding transformations netlify might apply

@fykaa fykaa force-pushed the fix-ui-navigation branch 2 times, most recently from 7f747ec to 0cad23e Compare October 29, 2024 21:19
@fykaa
Copy link
Contributor Author

fykaa commented Oct 29, 2024

This commit solves the problem with netlify, but there could be a more optimized approach to preempt similar encoding issues in the future—perhaps through a different font choice or other encoding settings.

Comment on lines 64 to 68
docs: {
sidebar: {
hideable: true,
},
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a different feature and not part of the Issue.

Copy link
Member

@krancour krancour Oct 29, 2024

Choose a reason for hiding this comment

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

I'd rather not include unrelated changes in a bug fix. Just make a separate PR for this please. This change is actually easier to say yes to on its own that this PR is, so it moves that change along faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@@ -17,11 +17,11 @@
},
"packageManager": "pnpm@9.0.3",
"dependencies": {
"@cmfcmf/docusaurus-search-local": "^0.11.0",
"@cmfcmf/docusaurus-search-local": "^1.1.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These version updates aren’t necessary to resolve this issue, but in my opinion, it's better to use the latest versions as long as they don't disrupt anything on our site at the moment

Copy link
Member

Choose a reason for hiding this comment

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

Upgrading major versions of a dependency usually runs a higher risk of a compatibility issue. I would suggest doing this as a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay.

Comment on lines 43 to 51

/* Pagination symbols for next and previous buttons */
.pagination-nav__link--prev .pagination-nav__label:before {
content: '« ';
}

.pagination-nav__link--next .pagination-nav__label:after {
content: ' »';
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you know why this fixes the problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because custom styles tend to stay unminified in netlify's handling of docusaurus files

Copy link
Contributor Author

@fykaa fykaa Oct 30, 2024

Choose a reason for hiding this comment

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

I actually did dig docs.akuity.io CNAME and figured akuity docs site isn't served by Netlify.
Hence, it perhaps were a netlify issue for docs.kargo.io

as Mayur mentioned it seems to come from an encoding conflict during the CSS minification or request processing

docusaurus’s CSS originally defined the content values for pagination symbols correctly, but netlify serves these characters as �

and i think by explicitly setting the content property for .pagination-nav__link within a custom css file, we avoid re-encoding during minification.

But imo there is more to this issue. It occurs to me that unless I don't use upgraded versions for docusaurus-search-local, clsx and typescript, the site will still not build those symbols correctly.

Copy link
Member

Choose a reason for hiding this comment

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

A lot of that isn't adding up though...

Content type headers on the CSS correctly reflect UTF-8 encoding.

A UTF-8 encoded file, would have no difficulty displaying », so if you open the downloaded and see the � character, that actual character is what's in the file.

So the question is how it got there.

If you build the site locally or in a container, you'll find » in the minified CSS; not �. This means that the minification process, and more broadly the build process, isn't the problem in and of itself.

The only possibilities I see at the moment are:

  • Build/minification is producing a different result in the Netlify build environment for a reason we have not yet identified.

    If we can nail this down as being the issue, we can probably fix it because we have a reasonable degree of control over that build environment.

  • The build/minification, even in the Netlfiy build environment, is working perfectly and the file is being corrupted somehow after that. The file would be served from the Netlify CDN, which calls that into question.

It occurs to me that unless I don't use upgraded versions for docusaurus-search-local, clsx and typescript, the site will still not build those symbols correctly.

If this were the issue, we'd be able to replicate the problem in a local build.

@fykaa fykaa force-pushed the fix-ui-navigation branch from 0cad23e to d46199e Compare October 30, 2024 13:58
@fykaa fykaa marked this pull request as draft October 30, 2024 15:15
@Marvin9
Copy link
Contributor

Marvin9 commented Oct 31, 2024

facebook/docusaurus#10465

@krancour
Copy link
Member

I can force Netlify's build env to use a different version of Node. Will try tomorrow.

@fykaa fykaa force-pushed the fix-ui-navigation branch 2 times, most recently from 7516592 to b11c313 Compare November 4, 2024 11:12
@fykaa
Copy link
Contributor Author

fykaa commented Nov 4, 2024

I can force Netlify's build env to use a different version of Node.

Since we are already using a netlify.toml file, I tried changing

[build.environment]
NODE_VERSION = "22.11.0"

Also, I do not have access to the Netlify Build logs it seems

Signed-off-by: Faeka Ansari <faeka6@gmail.com>
@fykaa fykaa force-pushed the fix-ui-navigation branch from 9ed7eae to 0e3807e Compare November 4, 2024 11:33
@fykaa fykaa marked this pull request as ready for review November 4, 2024 11:48
@krancour
Copy link
Member

krancour commented Nov 4, 2024

I can force Netlify's build env to use a different version of Node.

Well, I clearly never got around to that as planned. Thank you for beating me to it, @fykaa. 😄

I can see in the logs that the build for the doc preview of this PR used Node 22.11.0. You should also be able to see in the preview that the characters in the prev/next buttons are displaying correctly.

Good teamwork. Thanks @Marvin9 for digging up that relevant issue from the docusaurus repo. @fykaa thanks for the fix.

LGTM

@krancour krancour added this pull request to the merge queue Nov 4, 2024
Merged via the queue into akuity:main with commit 7813eff Nov 4, 2024
25 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 4, 2024
Signed-off-by: Faeka Ansari <faeka6@gmail.com>
(cherry picked from commit 7813eff)
@akuitybot
Copy link

Successfully created backport PR for release-1.0:

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

Successfully merging this pull request may close these issues.

docs: previous/next links at bottom of documents have unresolved characters
4 participants