From c919e44572cc81a8fd7564ed1395155d09d7fae1 Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Tue, 3 Sep 2019 20:26:50 +0100 Subject: [PATCH] feat(img): drop Cloudinary - move site assets to gitlab - update path name --- scripts/cloudinary.js | 25 +++++++------------ source/_posts/aliexpress-no-login-firefox.md | 4 --- source/_posts/firefox-containers.md | 2 +- .../_posts/view-image-dark-reader-firefox.md | 2 +- source/_redirects | 2 +- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/scripts/cloudinary.js b/scripts/cloudinary.js index 338aeba..7a9749d 100644 --- a/scripts/cloudinary.js +++ b/scripts/cloudinary.js @@ -3,34 +3,27 @@ /* * Put {% cloudinary 'folder/filename.jpg' 'description' %} in your post. -* Change the username in 'user' variable -* More info: -* https://cloudinary.com/blog/responsive_images_with_srcset_sizes_and_cloudinary */ hexo.extend.tag.register('cloudinary', (args) => { - const user = 'curben' let [fileName, alt] = args if (!alt) alt = '' - let modern = '' - let legacy = '' - const link = '/img/' + user + let modern = fileName + let legacy = fileName + const link = '/img/' - if (fileName.endsWith('.png')) { - modern = fileName.replace(/\.png$/, '.webp') - legacy = fileName + if (fileName.endsWith('.png') || fileName.endsWith('.jpg')) { + modern = fileName.concat('?format=webp') } else if (fileName.endsWith('.webp')) { - // Statically doesn't support animated webp + // Statically has yet to support animated webp // https://github.com/marsble/statically/issues/36 - // modern = fileName + // modern = fileName.concat('?auto_format=false') modern = fileName.replace(/\.webp$/, '.gif') legacy = fileName.replace(/\.webp$/, '.gif') - } else { - legacy = fileName } - const modernLink = link + '/' + modern + '?auto_format=false' - const legacyLink = link + '/' + legacy + '?auto_format=false' + const modernLink = link + modern + const legacyLink = link + legacy const img = ` -{% cloudinary '20190228/my-orders-ani.webp' "Screenrecord of Aliexpress 'My Orders' link" %} ## Reset XOriginPolicy diff --git a/source/_posts/firefox-containers.md b/source/_posts/firefox-containers.md index 1c9ef5c..b299296 100644 --- a/source/_posts/firefox-containers.md +++ b/source/_posts/firefox-containers.md @@ -43,7 +43,7 @@ We also can open a new container tab by long-pressing the plus (+) button, next {% cloudinary '20190812/containers-tabs.png' "New Container Tab" %} -{% cloudinary '20190812/containers-webp.webp' "Container Tab in action" %} +{% cloudinary '20190812/containers-tabs.webp' "Container Tab in action" %} ## Facebook Container diff --git a/source/_posts/view-image-dark-reader-firefox.md b/source/_posts/view-image-dark-reader-firefox.md index 2e04216..f2f1642 100644 --- a/source/_posts/view-image-dark-reader-firefox.md +++ b/source/_posts/view-image-dark-reader-firefox.md @@ -23,7 +23,7 @@ To resolve it, add the following CSS rule to the DR's setting via **Dev tools**. {% cloudinary '20190628/dark-reader-dev-tools.png' 'Dev tools of Dark Reader' %} -{% cloudinary '20190628/dev-tools-video.webp' 'A video of Dev Tools' %} +{% cloudinary '20190628/dev-tools-demo.webp' 'A video of Dev Tools' %} After adding the CSS, you should be able to see the whole image. But the fix is not perfect, the image sticks to the top rather than centred. diff --git a/source/_redirects b/source/_redirects index 9694155..1ef768d 100644 --- a/source/_redirects +++ b/source/_redirects @@ -3,4 +3,4 @@ # Reverse proxy to cdn /libs/* https://cdn.statically.io/libs/:splat 200 -/img/* https://cdn.statically.io/img/res.cloudinary.com/:splat 200 +/img/* https://cdn.statically.io/img/gitlab.com/curben/blog/raw/site/:splat 200