mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2025-02-05 14:06:25 +00:00
cloudinary
This commit is contained in:
parent
fcf7907d16
commit
14e9772122
@ -6,8 +6,10 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.20.0",
|
"axios": "^0.20.0",
|
||||||
|
"cloudinary-core": "^2.11.3",
|
||||||
"compression": "^1.7.1",
|
"compression": "^1.7.1",
|
||||||
"dayjs": "^1.8.36",
|
"dayjs": "^1.8.36",
|
||||||
|
"lodash": "^4.17.20",
|
||||||
"polka": "next",
|
"polka": "next",
|
||||||
"sirv": "^1.0.0"
|
"sirv": "^1.0.0"
|
||||||
},
|
},
|
||||||
|
36
src/components/Image.svelte
Normal file
36
src/components/Image.svelte
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<script context="module">
|
||||||
|
const defaultOptions = {
|
||||||
|
fetchFormat: 'auto',
|
||||||
|
quality: 'auto:good',
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { Cloudinary } from 'cloudinary-core'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
|
export let src = ''
|
||||||
|
export let options = {}
|
||||||
|
export let alt = ''
|
||||||
|
export let crop = false
|
||||||
|
|
||||||
|
let img
|
||||||
|
let attrs = {}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (crop) {
|
||||||
|
let { width, height } = window.getComputedStyle(img)
|
||||||
|
width = (parseInt(width) * window.devicePixelRatio) | 0
|
||||||
|
height = (parseInt(height) * window.devicePixelRatio) | 0
|
||||||
|
options = { ...options, width, gravity: 'auto', crop: 'fill' }
|
||||||
|
}
|
||||||
|
const cl = Cloudinary.new({ cloud_name: 'cupcakearmy' })
|
||||||
|
const cleaned = src.replace('https://api.nicco.io', '/nicco')
|
||||||
|
const all = { ...defaultOptions, ...options }
|
||||||
|
console.log(all)
|
||||||
|
attrs = cl.imageTag(cleaned, all).attributes()
|
||||||
|
console.log(attrs)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<img bind:this={img} {...$$restProps} {alt} {...attrs} />
|
@ -1,10 +1,12 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import Image from './Image.svelte'
|
||||||
|
|
||||||
export let src
|
export let src
|
||||||
export let alt
|
export let alt
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
img {
|
:global(img.cdn) {
|
||||||
width: calc(100% - 0.25em);
|
width: calc(100% - 0.25em);
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: center;
|
object-position: center;
|
||||||
@ -14,10 +16,10 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
img:hover {
|
:global(img.cdn:hover) {
|
||||||
transform: scale(1.1);
|
transform: scale(1.1);
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<img {src} {alt} />
|
<Image crop class="cdn" {src} {alt} />
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<a href={`blog/${post.slug}`}>
|
<a href={`blog/${post.slug}`}>
|
||||||
{#if post.featured}
|
{#if post.featured}
|
||||||
<ImageFrame src={post.featured.sizes.medium_large} alt={post.featured.description} />
|
<ImageFrame src={post.featured.url} alt={post.featured.description} />
|
||||||
{/if}
|
{/if}
|
||||||
<PostAttributes {post} />
|
<PostAttributes {post} />
|
||||||
<h2>
|
<h2>
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
--ff-alt: 'Playfair Display', serif;
|
--ff-alt: 'Playfair Display', serif;
|
||||||
--clr-primary: hsl(219, 90%, 80%);
|
--clr-primary: hsl(219, 90%, 80%);
|
||||||
--clr-secondary: hsl(64, 93%, 51%);
|
--clr-secondary: hsl(64, 93%, 51%);
|
||||||
|
--clr-error: hsl(0, 73.9%, 65.5%);
|
||||||
--animation: all 250ms ease;
|
--animation: all 250ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
yarn.lock
10
yarn.lock
@ -167,6 +167,11 @@ clean-css@^4.2.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
source-map "~0.6.0"
|
source-map "~0.6.0"
|
||||||
|
|
||||||
|
cloudinary-core@^2.11.3:
|
||||||
|
version "2.11.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/cloudinary-core/-/cloudinary-core-2.11.3.tgz#1440f61c6280485094aac87021b7e10f746dc69e"
|
||||||
|
integrity sha512-ZRnpjSgvx+LbSf+aEz5NKzxDB4Z0436aY/0BSDa90kAHiwAyd84VyEi95I74SE80e15Ri9t5S2xtksTXpzk9Xw==
|
||||||
|
|
||||||
color-convert@^1.9.0:
|
color-convert@^1.9.0:
|
||||||
version "1.9.3"
|
version "1.9.3"
|
||||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
|
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
|
||||||
@ -505,6 +510,11 @@ load-json-file@^4.0.0:
|
|||||||
pify "^3.0.0"
|
pify "^3.0.0"
|
||||||
strip-bom "^3.0.0"
|
strip-bom "^3.0.0"
|
||||||
|
|
||||||
|
lodash@^4.17.20:
|
||||||
|
version "4.17.20"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||||
|
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
||||||
|
|
||||||
lower-case@^1.1.1:
|
lower-case@^1.1.1:
|
||||||
version "1.1.4"
|
version "1.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
|
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
|
||||||
|
Loading…
Reference in New Issue
Block a user