Commit 6d11508
authored
fix: Fix css loading on direct links (#31)
This pull request introduces several improvements and fixes related to
asset handling, CSS layer ordering, and proxy compatibility for the
documentation marketplace. The main changes focus on ensuring consistent
CSS rendering, correct asset resolution when served from sub-paths, and
preventing encoding issues with proxies and gateways.
**Asset handling and CSS fixes:**
* In `scripts/build-vite.js`, the asset copy logic now rewrites
root-relative `url()` references in CSS bundles (e.g.,
`url(/fonts/...)`) to relative paths (e.g., `url(../fonts/...)`). This
ensures that CSS assets resolve correctly when the app is served from a
sub-path, such as `/knowledge-base/{slug}/_astro/`.
* Added `writeFileSync` import to support the CSS rewriting logic in the
build script.
**CSS layer ordering:**
* In `src/layouts/Base.astro`, a fix was added to declare `@layer base`
before sub-app stylesheets are slotted in. This guarantees that
Tailwind's base layer has lower priority than Starlight's content
layers, ensuring heading sizes and other styles render correctly on both
direct page loads and client-side navigation.
**Proxy and gateway compatibility:**
* In `nginx.conf`, the `gzip_proxied` directive is now set to `off` to
prevent nginx from gzip-encoding responses to proxies or gateways that
already sent `Accept-Encoding` upstream. This avoids issues where the
`Content-Encoding` header could be leaked to the browser, causing
decoding errors.
* Added a `Cache-Control: no-transform` header for `/knowledge-base/`
routes in `nginx.conf` to instruct intermediate proxies (like
FragmentGateway) not to transcode or re-encode responses, further
preventing encoding mismatches.
**Dependency updates:**
* Updated `@astrojs/check` development dependency from `^0.9.9` to
`^0.9.10` in `package.json`.
**Release notes:**
* Fix css loading on direct links
**Related:**
Closes #305 files changed
Lines changed: 820 additions & 649 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
| |||
0 commit comments