File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Replace oldDomain with newDomain
2+ const oldDomain = 'canonical-multipass1.readthedocs-hosted.com' ;
3+ const newDomain = 'canonical.com/multipass/docs' ;
4+
5+ function escapeRegExp ( value ) {
6+ return value . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
7+ }
8+
9+ function overwriteMatchingAnchorUrls ( container ) {
10+ if ( ! container ) return ;
11+
12+ const anchors = container . querySelectorAll ( 'a[href], link[href]' ) ;
13+ const oldDomainRegex = new RegExp ( escapeRegExp ( oldDomain ) , 'g' ) ;
14+
15+ anchors . forEach ( anchor => {
16+ anchor . href = anchor . href . replace ( oldDomainRegex , newDomain ) ;
17+ } ) ;
18+ }
19+
20+ overwriteMatchingAnchorUrls ( document . querySelector ( 'header' ) ) ;
21+
22+ // Use a MutationObserver to wait for the RTD flyout element to appear in the DOM
23+ const observer = new MutationObserver ( function ( mutations , obs ) {
24+
25+ const rtdFlyout = document . querySelector ( 'readthedocs-flyout' ) ;
26+ if ( ! rtdFlyout ) return ;
27+
28+ obs . disconnect ( ) ;
29+
30+ rtdFlyout . addEventListener ( 'click' , function ( ) {
31+ const shadowRoot = rtdFlyout . shadowRoot ;
32+ if ( ! shadowRoot ) return ;
33+
34+ overwriteMatchingAnchorUrls ( shadowRoot ) ;
35+ } ) ;
36+ } ) ;
37+
38+ observer . observe ( document . body , { childList : true , subtree : true } ) ;
Original file line number Diff line number Diff line change 11import datetime
22import ast
3+ import os
34
45# Configuration for the Sphinx documentation builder.
56# All configuration specific to your project should be done in this file.
7071# NOTE: The Open Graph Protocol (OGP) enhances page display in a social graph
7172# and is used by social media platforms; see https://ogp.me/
7273
73- ogp_site_url = "https://documentation.ubuntu.com/multipass/en/latest/"
74+ version_slug = f"{ os .environ .get ('READTHEDOCS_VERSION' , 'local' )} "
75+ html_baseurl = f"https://canonical.com/multipass/docs/{ version_slug } /"
76+ ogp_site_url = html_baseurl
7477
75- html_baseurl = "https://documentation.ubuntu.com/multipass/" # for sitemap.xml, the trailing slash is important
76- sitemap_url_scheme = "en/latest/{link}"
78+ sitemap_url_scheme = "{link}"
79+ sitemap_filename = "doc-sitemap.xml" # Required to avoid sitemap conflicts
7780
7881# Preview name of the documentation website
7982#
164167# TODO: If your documentation is hosted on https://docs.ubuntu.com/,
165168# uncomment and update as needed.
166169
167- slug = "multipass"
170+ slug = "multipass/docs "
168171
169172
170173# Template and asset locations
273276
274277html_js_files = [
275278 "js/bundle.js" ,
279+ "js/overwrite_links.js" ,
276280]
277281
278282
You can’t perform that action at this time.
0 commit comments