Skip to content

Commit d3942a1

Browse files
updates
1 parent 4927949 commit d3942a1

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

lib/builder.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ import { useEffect, useState } from 'react';
2828
import { useTranslations } from 'next-intl';
2929
import { useRouter } from 'next/router';
3030
import Script from 'next/script';
31-
32-
const monaco_version = '0.52.2';
31+
import useMonacoVersion, { defaultMonacoVersion } from './monacoversion.js';
3332

3433
const Builder = () => {
3534
const translate = useTranslations();
35+
const router = useRouter();
36+
37+
const monaco_version = useMonacoVersion(router.asPath) || defaultMonacoVersion;
3638

3739
return (
3840
<>

lib/monacoversion.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
3+
MIT License
4+
5+
Copyright (c) 2025 JustStudio <https://juststudio.is-a.dev/>
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
25+
*/
26+
27+
const searchParam = 'v';
28+
const useMonacoVersion = (routerAsPath) => {
29+
try {
30+
return new URL(routerAsPath).searchParams.get(searchParam);
31+
} catch {
32+
return false;
33+
}
34+
}
35+
export default useMonacoVersion;
36+
export const defaultMonacoVersion = '0.52.2';
37+
export const monacoVersionSearchParam = searchParam;

pages/_document.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ SOFTWARE.
2626

2727
import Document, { Html, Head, Main, NextScript } from 'next/document';
2828
import Script from 'next/script';
29+
import useMonacoVersion, { defaultMonacoVersion } from '@/lib/monacoversion';
30+
import { useRouter } from 'next/router';
2931
class CustomDocument extends Document {
3032
render() {
33+
const router = useRouter();
3134
return (
3235
<Html>
3336
<Head>
3437
<link rel="preconnect" href="https://fonts.googleapis.com" />
3538
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
3639
<link href="https://fonts.googleapis.com/css2?family=Lexend+Zetta:[email protected]&family=Rubik+Mono+One&family=Rubik:ital,wght@0,300..900;1,300..900&family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&display=swap" rel="stylesheet" />
3740
<title>Just an Ultimate Site Tool Demo</title>
38-
<link rel="stylesheet" data-name="vs/editor/editor.main" href="/third-party/monaco-editor/0.52.2/package/min/vs/editor/editor.main.css" />
41+
<link rel="stylesheet" data-name="vs/editor/editor.main" href={`/third-party/monaco-editor/${useMonacoVersion(router.asPath) || defaultMonacoVersion}/package/min/vs/editor/editor.main.css`} />
3942
</Head>
4043
<body>
4144
<Main></Main>

0 commit comments

Comments
 (0)