umberto 2.5.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "umberto",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "CKSource Documentation builder",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typescript": "^4.8.4"
|
|
75
75
|
},
|
|
76
76
|
"engines": {
|
|
77
|
-
"node": ">=
|
|
77
|
+
"node": ">=16.0.0",
|
|
78
78
|
"npm": ">=5.7.1"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
const latestRegexp = /(?<=\/)latest(?=\/)/;
|
|
7
|
-
|
|
8
6
|
export default function attachPermalinkListener() {
|
|
9
7
|
const projectVersionElement = document.querySelector( 'meta[name=project-version]' );
|
|
8
|
+
const projectSlugElement = document.querySelector( 'meta[name=project-slug]' );
|
|
10
9
|
|
|
11
|
-
if ( !projectVersionElement ) {
|
|
10
|
+
if ( !projectVersionElement || !projectSlugElement ) {
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
const projectVersion = projectVersionElement.getAttribute( 'content' );
|
|
15
|
+
const projectSlug = projectSlugElement.getAttribute( 'content' );
|
|
16
16
|
|
|
17
17
|
document.addEventListener( 'keypress', event => {
|
|
18
18
|
if ( event.metaKey ) {
|
|
@@ -27,11 +27,13 @@ export default function attachPermalinkListener() {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const latestRegexp = new RegExp( `/${ projectSlug }/latest/` );
|
|
31
|
+
|
|
30
32
|
if ( !latestRegexp.test( location.href ) ) {
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
const newUrl = location.href.replace( latestRegexp, projectVersion );
|
|
36
|
+
const newUrl = location.href.replace( latestRegexp, `/${ projectSlug }/${ projectVersion }/` );
|
|
35
37
|
|
|
36
38
|
history.replaceState( history.state, document.title, newUrl );
|
|
37
39
|
} );
|