File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change 11import { CopyButton } from '@/components/CopyButton' ;
2- import React , { DetailedHTMLProps , HTMLAttributes , Children } from 'react' ;
2+ import React , { DetailedHTMLProps , HTMLAttributes } from 'react' ;
3+ import config from '../../docs.config' ;
34
45interface PreProps
56 extends DetailedHTMLProps < HTMLAttributes < HTMLPreElement > , HTMLPreElement > {
@@ -24,19 +25,23 @@ async function getLatestVersion() {
2425 'https://releaseregistry.sourcegraph.com/v1/releases/sourcegraph/latest'
2526 ) ;
2627
27- const response = await fetch ( url . toString ( ) , {
28- method : 'GET' ,
29- headers : {
30- Accept : 'application/json'
28+ try {
29+ const response = await fetch ( url . toString ( ) , {
30+ method : 'GET' ,
31+ headers : {
32+ Accept : 'application/json'
33+ }
34+ } ) ;
35+
36+ if ( ! response . ok ) {
37+ throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
3138 }
32- } ) ;
3339
34- if ( ! response . ok ) {
35- throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
40+ const releaseInfo : ReleaseInfo = await response . json ( ) ;
41+ return releaseInfo . version ;
42+ } catch ( error ) {
43+ return config . DOCS_LATEST_VERSION ;
3644 }
37-
38- const releaseInfo : ReleaseInfo = await response . json ( ) ;
39- return releaseInfo . version ;
4045}
4146
4247function trimPrefix ( str : string , prefix : string ) {
You can’t perform that action at this time.
0 commit comments