File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -144,7 +144,13 @@ export class CodeBlock extends React.PureComponent<
144
144
}
145
145
146
146
function PlainImage ( imageProps ) {
147
+ const {
148
+ config : { displayImageTitleAsCaption} ,
149
+ } = React . useContext ( ConfigContext ) ;
147
150
const { isRss, src, ...props } = imageProps ;
151
+ const title = displayImageTitleAsCaption
152
+ ? props . title || props [ 'data-caption' ]
153
+ : props [ 'data-caption' ] ;
148
154
return (
149
155
< Box
150
156
margin = { { vertical : 'medium' } }
@@ -160,15 +166,15 @@ function PlainImage(imageProps) {
160
166
{ ...props }
161
167
/>
162
168
{ isRss ? < br /> : null }
163
- { props . title ? (
169
+ { title ? (
164
170
< Text
165
171
style = { { display : 'block' } }
166
172
size = "xsmall"
167
173
margin = "small"
168
174
weight = { 300 }
169
175
color = "dark-1"
170
176
textAlign = "center" >
171
- { isRss ? < em > { props . title } </ em > : props . title }
177
+ { isRss ? < em > { title } </ em > : title }
172
178
</ Text >
173
179
) : null }
174
180
</ Box >
Original file line number Diff line number Diff line change 39
39
) ;
40
40
}
41
41
42
+ function parseBool ( {
43
+ value,
44
+ defaultValue,
45
+ } : {
46
+ value : any ,
47
+ defaultValue : boolean ,
48
+ } ) : boolean {
49
+ if ( value == null ) {
50
+ return defaultValue ;
51
+ }
52
+ try {
53
+ return JSON . parse ( value ) ;
54
+ } catch ( e ) {
55
+ return defaultValue ;
56
+ }
57
+ }
58
+
42
59
const config : Config = {
43
60
// Owner of the repo that OneBlog should pull issues from
44
61
repoOwner : ensureEnv (
@@ -59,12 +76,19 @@ const config: Config = {
59
76
description : process . env . NEXT_PUBLIC_DESCRIPTION ,
60
77
defaultLogin : process . env . NEXT_PUBLIC_DEFAULT_GITHUB_LOGIN ,
61
78
siteHostname : removeTrailingSlash ( process . env . NEXT_PUBLIC_SITE_HOSTNAME ) ,
62
- hideAttribution : process . env . NEXT_PUBLIC_HIDE_ATTRIBUTION ,
79
+ hideAttribution : parseBool ( {
80
+ value : process . env . NEXT_PUBLIC_HIDE_ATTRIBUTION ,
81
+ defaultValue : false ,
82
+ } ) ,
63
83
gaTrackingId : process . env . NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID ,
64
84
vercelUrl : process . env . NEXT_PUBLIC_VERCEL_URL
65
85
? removeTrailingSlash ( `https://${ process . env . NEXT_PUBLIC_VERCEL_URL } ` )
66
86
: null ,
67
87
codeTheme : process . env . NEXT_PUBLIC_CODE_THEME || 'dark-plus' ,
88
+ displayImageTitleAsCaption : parseBool ( {
89
+ value : process . env . NEXT_PUBLIC_DISPLAY_IMAGE_TITLE_AS_CAPTION ,
90
+ defaultValue : true ,
91
+ } ) ,
68
92
} ;
69
93
70
94
export default config ;
You can’t perform that action at this time.
0 commit comments