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(docs): Configure SWA to never emit trailing slashes for website URLs #23286

Merged
merged 4 commits into from
Dec 11, 2024

Conversation

Josmithr
Copy link
Contributor

@Josmithr Josmithr commented Dec 10, 2024

Ensures consistent relative file path link behavior by ensuring resolved site URLs never include a trailing slash. See https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#never

Also makes some small fixes to config files for local development.

AB#25895

@github-actions github-actions bot added area: website base: main PRs targeted against main branch labels Dec 10, 2024
@@ -40,7 +40,7 @@
"prettier:fix": "prettier --write . --cache --ignore-path ../.prettierignore",
"rebuild": "npm run clean && npm run build",
"serve": "docusaurus serve",
"serve-with-azure-emulation": "swa start",
"serve-with-azure-emulation": "swa start --config-name ff-doc-site",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unclear from the CLI docs what the policy is for a config file with only a single "configuration" entry, but this makes things more explicit.

@@ -14,5 +14,6 @@
"route": "/404",
"statusCode": 404
}
]
],
"trailingSlash": "never"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The crux of the "fix" - configures SWA to never emit a trailing slash in URLs.

docs/swa-cli.config.json Outdated Show resolved Hide resolved
@Josmithr Josmithr requested a review from a team December 11, 2024 01:36
@Josmithr Josmithr marked this pull request as ready for review December 11, 2024 01:36
Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  170006 links
    1595 destination URLs
    1825 URLs ignored
       0 warnings
       0 errors


Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

🚀

@Josmithr Josmithr merged commit cecb995 into microsoft:main Dec 11, 2024
31 checks passed
@Josmithr Josmithr deleted the docs/trailing-slashes branch December 11, 2024 18:06
Josmithr added a commit that referenced this pull request Dec 11, 2024
Partial reversion of #23286.

SWA's implementation of `"trailingSlash": "never"` is currently flawed.
The resulting redirect ends up exposing the underlying SWA URL of the
site, rather than our configured front door URL. E.g.
`https://fluidframework.com/docs/concepts/signals/` ends up redirecting
to
`https://salmon-sand-0b7fa7c1e.1.azurestaticapps.net/docs/concepts/signals`.
- See Azure/static-web-apps#1036

This PR removes that configuration flag, and instead leverages
Docusaurus's
[trailingSlash](https://docusaurus.io/docs/api/docusaurus-config#trailingSlash)
configuration option to not emit trailing slashes.

This required updating a handful of relative URL links to use file path
links. The guidance documentation in the README has been updated to
offer new guidance around relative links in light of new learnings.

[AB#25895](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/25895)
Josmithr added a commit to Josmithr/FluidFramework that referenced this pull request Dec 12, 2024
…RLs (microsoft#23286)

Ensures consistent relative file path link behavior by ensuring resolved
site URLs never include a trailing slash. See
<https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#never>

Also makes some small fixes to config files for local development.


[AB#25895](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/25895)
Josmithr added a commit to Josmithr/FluidFramework that referenced this pull request Dec 12, 2024
Partial reversion of microsoft#23286.

SWA's implementation of `"trailingSlash": "never"` is currently flawed.
The resulting redirect ends up exposing the underlying SWA URL of the
site, rather than our configured front door URL. E.g.
`https://fluidframework.com/docs/concepts/signals/` ends up redirecting
to
`https://salmon-sand-0b7fa7c1e.1.azurestaticapps.net/docs/concepts/signals`.
- See Azure/static-web-apps#1036

This PR removes that configuration flag, and instead leverages
Docusaurus's
[trailingSlash](https://docusaurus.io/docs/api/docusaurus-config#trailingSlash)
configuration option to not emit trailing slashes.

This required updating a handful of relative URL links to use file path
links. The guidance documentation in the README has been updated to
offer new guidance around relative links in light of new learnings.

[AB#25895](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/25895)
Josmithr added a commit to Josmithr/FluidFramework that referenced this pull request Dec 12, 2024
…RLs (microsoft#23286)

Ensures consistent relative file path link behavior by ensuring resolved
site URLs never include a trailing slash. See
<https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#never>

Also makes some small fixes to config files for local development.


[AB#25895](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/25895)
Josmithr added a commit to Josmithr/FluidFramework that referenced this pull request Dec 12, 2024
Partial reversion of microsoft#23286.

SWA's implementation of `"trailingSlash": "never"` is currently flawed.
The resulting redirect ends up exposing the underlying SWA URL of the
site, rather than our configured front door URL. E.g.
`https://fluidframework.com/docs/concepts/signals/` ends up redirecting
to
`https://salmon-sand-0b7fa7c1e.1.azurestaticapps.net/docs/concepts/signals`.
- See Azure/static-web-apps#1036

This PR removes that configuration flag, and instead leverages
Docusaurus's
[trailingSlash](https://docusaurus.io/docs/api/docusaurus-config#trailingSlash)
configuration option to not emit trailing slashes.

This required updating a handful of relative URL links to use file path
links. The guidance documentation in the README has been updated to
offer new guidance around relative links in light of new learnings.

[AB#25895](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/25895)
Josmithr added a commit to Josmithr/FluidFramework that referenced this pull request Dec 12, 2024
…RLs (microsoft#23286)

Ensures consistent relative file path link behavior by ensuring resolved
site URLs never include a trailing slash. See
<https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#never>

Also makes some small fixes to config files for local development.


[AB#25895](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/25895)
Josmithr added a commit to Josmithr/FluidFramework that referenced this pull request Dec 12, 2024
Partial reversion of microsoft#23286.

SWA's implementation of `"trailingSlash": "never"` is currently flawed.
The resulting redirect ends up exposing the underlying SWA URL of the
site, rather than our configured front door URL. E.g.
`https://fluidframework.com/docs/concepts/signals/` ends up redirecting
to
`https://salmon-sand-0b7fa7c1e.1.azurestaticapps.net/docs/concepts/signals`.
- See Azure/static-web-apps#1036

This PR removes that configuration flag, and instead leverages
Docusaurus's
[trailingSlash](https://docusaurus.io/docs/api/docusaurus-config#trailingSlash)
configuration option to not emit trailing slashes.

This required updating a handful of relative URL links to use file path
links. The guidance documentation in the README has been updated to
offer new guidance around relative links in light of new learnings.

[AB#25895](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/25895)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: website base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants