Skip to content

Conversation

@florian-sanders-cc
Copy link
Contributor

@florian-sanders-cc florian-sanders-cc commented Oct 20, 2025

Fixes #1579

What does this PR do?

  • Refactors the helpers to generate dev hub & docs URLs so that consumers of the components may customize the base URL:
    • creates a new src/lib/dev-hub-url.js file,
    • renames generate...Url to get...Url and moves them from src/lib/utils.js to src/lib/dev-hub-url.js,
    • adds & refactors tests related to these helpers,
    • refactors all usage & import of the helpers to adapt to these changes.
  • Adds documentation about the new helpers (contributing for the get...Url helpers, and getting started for the set...Url helpers).

How to review?

  • Check the commits,
  • Make sure I didn't fail when changing the import paths from utils to dev-hub-urls (though TypeChecking should catch issues),
  • Check the new docs & tests (both tests & docs have been AI generated 😇).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the URL generation system for developer hub and documentation links, enabling consumers to customize the base URLs. The changes extract URL generation helpers into a dedicated module and provide a public API for overriding the default base URL.

Key changes:

  • Created a new dev-hub-url.js module with getDocUrl(), getDevHubUrl(), and setDevHubBaseUrl() functions
  • Renamed generate...Url helpers to get...Url and moved them from utils.js to the new module
  • Updated all references throughout the codebase to use the new import paths and function names
  • Added comprehensive documentation for contributors and consumers

Reviewed Changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib/dev-hub-url.js New module implementing URL generation with customizable base URL
src/lib/utils.js Removed URL generation functions (moved to dev-hub-url.js)
test/utils.test.js Removed URL generation tests (moved to resource-urls.test.js)
test/resource-urls.test.js Added comprehensive tests for URL generation and base URL customization
src/translations/translations.*.js Updated imports and function calls to use new module
src/components/*/*.js Updated imports and function calls across all components
src/stories/fixtures/*.js Updated imports and function calls in fixture files
docs/getting-started/custom-base-urls.md New documentation for consumers on customizing base URLs
docs/contributing/urls.md New documentation for contributors on using URL helpers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Rename `generateDevHubHref` to `getDevHubUrl` and move to
  `src/lib/dev-hub-url.js`
- Rename `generateDocsHref` to `getDocUrl` and move to
  `src/lib/dev-hub-url.js`
- Expose public `setDevHubBaseUrl` so that consumers of this project may
  change the base URL used for dev hub & doc links.

Fixes #1579
@florian-sanders-cc florian-sanders-cc force-pushed the doc-links/allow-overriding-base-url branch from 441d475 to 73d5627 Compare October 20, 2025 16:28
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

🧐 Visual tests report for PR #1587

The latest visual tests report is available. Please review the results.

1 components impacted
  • cc-product-card,

This comment was generated automatically by the Visual tests workflow.

- Rename assets-url.test.js to `resource-urls.test.js`,
- Add tests for `getDevHubUrl`, `getDevHubUrl`, and `setDevHubBaseUrl`
  based on the already existing assets URL tests.

Fixes #1579
- Replace all occurrences of `generateDocsHref` with `getDocUrl`,
- Replace all occurrences of `generateDevHubHref` with `getDevHubUrl`,
- Change import paths from `utils.js` to `dev-hub-url.js`,
- Remove all trailing slashes.

Fixes #1579
Add a new guide explaining how to correctly generate documentation,
developer hub, and asset URLs using helper functions.
Includes usage examples, translation file integration, and
best practices for avoiding hardcoded URLs.
Add a new documentation page explaining how to override the default developer hub
and assets base URLs in Clever Cloud components.
Includes usage examples for `setDevHubBaseUrl` and `setAssetsBaseUrl`, and highlights
the importance of configuring URLs before importing components.
@florian-sanders-cc florian-sanders-cc force-pushed the doc-links/allow-overriding-base-url branch from 73d5627 to 19b2ba9 Compare October 21, 2025 06:27
@github-actions
Copy link
Contributor

🔎 A preview has been automatically published : https://clever-components-preview.cellar-c2.services.clever-cloud.com/doc-links/allow-overriding-base-url/index.html.

This preview will be deleted once this PR is closed.

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.

Doc links: expose a setDocsBaseUrl to allow overrides

1 participant