docs: use cloudinary env variable (#3769)
* docs: use cloudinary env variable * fix error * added default value * add condition for cloud name
This commit is contained in:
1 parent
a7b57e8201
commit
74c54a134d
2 files changed
+2
-2
No files matched your search
@@ -132,7 +132,7 @@ const config = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
cloudinaryConfig: {
|
cloudinaryConfig: {
|
||||||
cloudName: 'dza7lstvk', // TODO replace with env variable
|
cloudName: process.env.CLOUDINARY_CLOUD_NAME || "",
|
||||||
flags: [
|
flags: [
|
||||||
'fl_lossy',
|
'fl_lossy',
|
||||||
'f_auto'
|
'f_auto'
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const imageRegex = /^https:\/\/res.cloudinary.com\/.*\/upload\/v[0-9]+\/(?<image
|
|||||||
export default function CloudinaryImage ({ src, ...props }) {
|
export default function CloudinaryImage ({ src, ...props }) {
|
||||||
const { cloudinaryConfig } = useThemeConfig();
|
const { cloudinaryConfig } = useThemeConfig();
|
||||||
const matchingRegex = src.match(imageRegex)
|
const matchingRegex = src.match(imageRegex)
|
||||||
if (!cloudinaryConfig || !matchingRegex?.groups || !matchingRegex.groups.imageId) {
|
if (!cloudinaryConfig || !cloudinaryConfig.cloudName || !matchingRegex?.groups || !matchingRegex.groups.imageId) {
|
||||||
// either cloudinary isn't configured or
|
// either cloudinary isn't configured or
|
||||||
// could not match url to a cloudinary url
|
// could not match url to a cloudinary url
|
||||||
// default to docusaurus's image component
|
// default to docusaurus's image component
|
||||||
|
|||||||
Reference in new issue
Block a user