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:
Shahed Nasser
2023-04-07 14:15:48 +03:00
committed by GitHub
parent a7b57e8201
commit 74c54a134d
2 changed files with 2 additions and 2 deletions

View File

@@ -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'

View File

@@ -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