@@ -3,6 +3,8 @@ import type { DefaultTheme } from 'vitepress/theme';
3
3
import { apiPages } from './api-pages' ;
4
4
import {
5
5
algoliaIndex ,
6
+ commitHash ,
7
+ isReleaseBranch ,
6
8
version ,
7
9
versionBannerInfix ,
8
10
versionLabel ,
@@ -13,7 +15,13 @@ type SidebarItem = DefaultTheme.SidebarItem;
13
15
14
16
const description =
15
17
'Generate massive amounts of fake (but reasonable) data for testing and development.' ;
16
- const image = 'https://fakerjs.dev/social-image.png' ;
18
+ const socialImage = 'https://fakerjs.dev/social-image.png' ;
19
+ const consoleDownload = isReleaseBranch
20
+ ? `https://cdn.jsdelivr.net/npm/@faker-js/faker@${ version } /+esm`
21
+ : '/faker.js' ;
22
+ const consoleVersion = isReleaseBranch
23
+ ? version
24
+ : `${ version . replace ( / - .* $ / , '' ) } -preview+${ commitHash } ` ;
17
25
18
26
function getSideBarWithExpandedEntry ( entryToExpand : string ) : SidebarItem [ ] {
19
27
const links : SidebarItem [ ] = [
@@ -111,12 +119,12 @@ const config: UserConfig<DefaultTheme.Config> = {
111
119
[ 'meta' , { name : 'theme-color' , content : '#40af7c' } ] ,
112
120
[ 'meta' , { name : 'og:title' , content : 'FakerJS' } ] ,
113
121
[ 'meta' , { name : 'og:description' , content : description } ] ,
114
- [ 'meta' , { name : 'og:image' , content : image } ] ,
122
+ [ 'meta' , { name : 'og:image' , content : socialImage } ] ,
115
123
[ 'meta' , { name : 'twitter:card' , content : 'summary_large_image' } ] ,
116
124
[ 'meta' , { name : 'twitter:title' , content : 'FakerJS' } ] ,
117
125
[ 'meta' , { name : 'twitter:description' , content : description } ] ,
118
126
[ 'meta' , { name : 'twitter:site' , content : '@faker_js' } ] ,
119
- [ 'meta' , { name : 'twitter:image' , content : image } ] ,
127
+ [ 'meta' , { name : 'twitter:image' , content : socialImage } ] ,
120
128
[ 'meta' , { name : 'twitter:image:alt' , content : 'The FakerJS logo' } ] ,
121
129
[ 'link' , { rel : 'me' , href : 'https://fosstodon.org/@faker_js' } ] ,
122
130
[
@@ -127,9 +135,9 @@ const logStyle = 'background: rgba(16, 183, 127, 0.14); color: rgba(255, 255, 24
127
135
console.log(\`%cIf you would like to test Faker in the browser console, you can do so using 'await enableFaker()'.
128
136
If you would like to test Faker in a playground, visit https://new.fakerjs.dev.\`, logStyle);
129
137
async function enableFaker() {
130
- const imported = await import('https://cdn.jsdelivr.net/npm/@faker-js/faker@ ${ version } /+esm ');
138
+ const imported = await import('${ consoleDownload } ');
131
139
Object.assign(globalThis, imported);
132
- console.log(\`%cYou can now start using Faker v${ version } :
140
+ console.log(\`%cYou can now start using Faker v${ consoleVersion } :
133
141
e.g. 'faker.food.description()' or 'fakerZH_CN.person.firstName()'
134
142
For other languages please refer to https://fakerjs.dev/guide/localization.html#available-locales
135
143
For a full list of all methods please refer to https://fakerjs.dev/api/\`, logStyle);
0 commit comments