|
| 1 | +Override External URLs |
| 2 | +====================== |
| 3 | + |
| 4 | +What is getExternalLinkUrl? |
| 5 | +--------------------------- |
| 6 | + |
| 7 | +The `getExternalLinkUrl` function is a utility from `@edx/frontend-platform` that allows for centralized management of external URLs. It enables the override of external links through configuration, making it possible to customize external references without modifying the source code directly. |
| 8 | + |
| 9 | +URLs wrapped with getExternalLinkUrl |
| 10 | +------------------------------------ |
| 11 | +Use cases: |
| 12 | + |
| 13 | +1. **Accessibility Page** (`src/accessibility-page/AccessibilityPage.jsx`) |
| 14 | + - `COMMUNITY_ACCESSIBILITY_LINK` - Points to community accessibility resources: https://www.edx.org/accessibility |
| 15 | + |
| 16 | +2. **Course Outline** (if applicable) |
| 17 | + - Documentation links |
| 18 | + - Help resources |
| 19 | + |
| 20 | +3. **Other pages** (search for `getExternalLinkUrl` usage across the codebase) |
| 21 | + - Help documentation |
| 22 | + - External tool integrations |
| 23 | + |
| 24 | +Following external URLs are wrapped with `getExternalLinkUrl` in the authoring application: |
| 25 | + |
| 26 | +- 'https://www.edx.org/accessibility' |
| 27 | +- 'https://docs.openedx.org/en/latest/educators/concepts/exercise_tools/about_multi_select.html' |
| 28 | +- 'https://docs.openedx.org/en/latest/educators/how-tos/course_development/exercise_tools/add_multi_select.html' |
| 29 | +- 'https://docs.openedx.org/en/latest/educators/how-tos/course_development/exercise_tools/add_dropdown.html' |
| 30 | +- 'https://docs.openedx.org/en/latest/educators/how-tos/course_development/exercise_tools/manage_numerical_input_problem.html' |
| 31 | +- 'https://docs.openedx.org/en/latest/educators/how-tos/course_development/exercise_tools/add_text_input.html' |
| 32 | +- 'https://docs.openedx.org/en/latest/educators/how-tos/course_development/social_sharing.html' |
| 33 | +- 'https://docs.openedx.org/en/latest/educators/references/course_development/exercise_tools/guide_problem_types.html#advanced-problem-types' |
| 34 | +- 'https://docs.openedx.org/en/latest/educators/references/course_development/parent_child_components.html' |
| 35 | +- 'https://openai.com/api-data-privacy' |
| 36 | +- 'https://docs.openedx.org/en/latest/educators/how-tos/course_development/create_new_library.html' |
| 37 | +- 'https://bigbluebutton.org/privacy-policy/' |
| 38 | +- 'https://creativecommons.org/about' |
| 39 | + |
| 40 | +Note: as new external URLs are added to the codebase, more URLs will be wrapped with `getExternalLinkUrl` and this list may not always be up to date. |
| 41 | + |
| 42 | +How to Override External URLs |
| 43 | +----------------------------- |
| 44 | + |
| 45 | +To override external URLs, you can use the frontend platform's configuration system. |
| 46 | +This object should be added to the config object defined in the env.config.[js,jsx,ts,tsx], and must be named externalLinkUrlOverrides. |
| 47 | + |
| 48 | +1. **Environment Configuration** |
| 49 | + Add the URL overrides to your environment configuration: |
| 50 | + |
| 51 | + .. code-block:: javascript |
| 52 | +
|
| 53 | + const config = { |
| 54 | + // Other config options... |
| 55 | + externalLinkUrlOverrides: { |
| 56 | + 'https://www.edx.org/accessibility': 'https://your-custom-domain.com/accessibility', |
| 57 | + // Add other URL overrides here |
| 58 | + } |
| 59 | + }; |
| 60 | +
|
| 61 | +Examples |
| 62 | +-------- |
| 63 | + |
| 64 | +**Original URL:** Default community accessibility link |
| 65 | +**Override:** Your institution's accessibility policy page |
| 66 | + |
| 67 | +.. code-block:: javascript |
| 68 | +
|
| 69 | + // In your app configuration |
| 70 | + getExternalLinkUrl('https://www.edx.org/accessibility') |
| 71 | + // Returns: 'https://your-custom-domain.com/accessibility' |
| 72 | + // Instead of the default Open edX community link |
| 73 | +
|
| 74 | +Benefits |
| 75 | +-------- |
| 76 | + |
| 77 | +- **Customization**: Institutions can point to their own resources |
| 78 | +- **Maintainability**: URLs can be changed without code modifications |
| 79 | +- **Consistency**: Centralized URL management across the application |
| 80 | +- **Flexibility**: Different environments can have different external links |
0 commit comments