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:
@@ -132,7 +132,7 @@ const config = {
|
||||
}
|
||||
},
|
||||
cloudinaryConfig: {
|
||||
cloudName: 'dza7lstvk', // TODO replace with env variable
|
||||
cloudName: process.env.CLOUDINARY_CLOUD_NAME || "",
|
||||
flags: [
|
||||
'fl_lossy',
|
||||
'f_auto'
|
||||
|
||||
@@ -27,7 +27,7 @@ const imageRegex = /^https:\/\/res.cloudinary.com\/.*\/upload\/v[0-9]+\/(?<image
|
||||
export default function CloudinaryImage ({ src, ...props }) {
|
||||
const { cloudinaryConfig } = useThemeConfig();
|
||||
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
|
||||
// could not match url to a cloudinary url
|
||||
// default to docusaurus's image component
|
||||
|
||||
Reference in New Issue
Block a user