File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ const config: Config = {
35
35
customFields : {
36
36
ui5Version : packageJson . version ,
37
37
ui5DeploymentType : process . env . DEPLOYMENT_TYPE ,
38
+ urlShortenerApiKey : process . env . URL_SHORTENER_API_KEY ,
38
39
} ,
39
40
title : 'UI5 Web Components' ,
40
41
tagline : 'An open-source UI components library for building enterprise-ready applications!' ,
Original file line number Diff line number Diff line change
1
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext' ;
2
+
1
3
const URL_SHORTEN_API = "https://linkshortener.int.sap/api/url" ;
2
4
3
5
export default async function shortenURL ( longUrl ) {
4
6
if ( process . env . NODE_ENV === 'development' ) {
5
7
return ;
6
8
}
9
+
10
+ const { siteConfig } = useDocusaurusContext ( ) ;
11
+ const URL_SHORTEN_API_KEY = siteConfig . customFields . urlShortenerApiKey ;
7
12
8
- const URL_API_KEY = process . env . URL_SHORTENER_API_KEY ;
9
- if ( ! URL_API_KEY ) {
13
+ if ( ! URL_SHORTEN_API_KEY ) {
10
14
console . warn ( "URL shortener API key not available." ) ;
11
15
return "" ;
12
16
}
@@ -21,7 +25,7 @@ export default async function shortenURL(longUrl) {
21
25
headers : {
22
26
"Content-Type" : "application/json" ,
23
27
"Accept" : "application/json" ,
24
- "ApiKey" : URL_API_KEY ,
28
+ "ApiKey" : URL_SHORTEN_API_KEY ,
25
29
"X-Requested-With" : "XMLHttpRequest"
26
30
} ,
27
31
body : JSON . stringify ( payload ) ,
You can’t perform that action at this time.
0 commit comments