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: scoping of breadcrumb links, add unified function that resolves … #3099

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

manuelblum
Copy link
Collaborator

Description

This Pull Requests:

  • adds a unified function, resolveUrl that resolves all kinds of URLs (scoped, not scoped, anchor, baseUrl)
  • Breadcrumb links got fixed (they are language scoped now).

Screenshots/screencasts

Before After
Screenshot 2025-01-13 at 14 31 24 Screenshot 2025-01-13 at 14 30 51

Further information

/**
* Resolves a path, scope and a baseUrl to a real URL which can be navigated to.
*/
export const resolveUrl = ({ baseUrl = "/", path, scope, anchor }: ResolveUrlOptions) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

missing test setup in demo/site, would like to unit test this function.

@manuelblum manuelblum force-pushed the fix/com-1533-breadcrumb-links-not-respecting-scope-language branch 2 times, most recently from 5bfefd2 to f0d7e1c Compare January 13, 2025 13:49
@manuelblum manuelblum force-pushed the fix/com-1533-breadcrumb-links-not-respecting-scope-language branch from bb92f22 to 14eeac0 Compare January 14, 2025 06:55
*
* @return {string} The resolved URL: /{scope.language}/test/to/my/page#my-anchor
*/
export const resolveUrl = ({ baseUrl = "/", path, scope, anchor }: ResolveUrlOptions) => {
Copy link
Member

@nsams nsams Jan 14, 2025

Choose a reason for hiding this comment

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

  • baseUrl should not include trailing / and default to ""
  • I would even consider removing the baseUrl from this new function and keep appending it in sitemap (as this is the only place where it is needed)
  • scope.language should be required (in this multi-lang setup) - creating urls without scope.language is not possible and would result in an invalid url
  • maybe rename to createSiteUrl, resolveUrl might be too generic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed resolveUrl to createSiteUrl

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I made the scope optional because of the implementation detail of InternalLink: https://github.com/vivid-planet/comet/pull/3099/files#diff-3dfc3d13f8394017033da0b81712accc4475939f36a1df4826a6151807d8ba57R22-R26.

I think scope can be null there, at least its mentioned in the blocks.generated.ts
Screenshot 2025-01-14 at 13 45 45

I am unsure about that, but I can make the scope required in this function and render the span instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Concerning the baseUrl -> nearly every link I have seen in the demo is starting with a /.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but I think it's a good idea to start with default value = empty string.

@manuelblum manuelblum force-pushed the fix/com-1533-breadcrumb-links-not-respecting-scope-language branch from a68a326 to 0b96f43 Compare January 14, 2025 12:43
@manuelblum manuelblum requested a review from nsams January 14, 2025 12:53
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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