Skip to content

Commit 00c2ee5

Browse files
committed
feat: mock images
1 parent c908e3f commit 00c2ee5

File tree

5 files changed

+67
-9
lines changed

5 files changed

+67
-9
lines changed

components/ImgBlurHash.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ function getDataUrlFromArr(arr: Uint8ClampedArray, w: number, h: number) {
3939
}
4040
4141
onMounted(() => {
42+
// Decode the blurhash if available
43+
if (props.blurhash) {
44+
const pixels = decode(props.blurhash, 32, 32)
45+
placeholderSrc.value = getDataUrlFromArr(pixels, 32, 32)
46+
}
47+
4248
// Create a temporary image to check when the image has loaded
4349
const img = document.createElement('img')
4450
img.onload = () => {
@@ -52,12 +58,6 @@ onMounted(() => {
5258
setTimeout(() => {
5359
isLoaded.value = true
5460
}, 3000)
55-
56-
// Decode the blurhash if available
57-
if (props.blurhash) {
58-
const pixels = decode(props.blurhash, 32, 32)
59-
placeholderSrc.value = getDataUrlFromArr(pixels, 32, 32)
60-
}
6161
})
6262
</script>
6363

components/nav/NavHeader.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const routes = reactive<Menu[]>([
99
{ path: '/posts', icon: 'i-ri-blogger-line' },
1010
{ path: '/projects', icon: 'i-ri-dashboard-line' },
1111
{ path: '/talks', icon: 'i-ri-file-ppt-line' },
12+
{ path: '/images', icon: 'i-ri-image-line' },
1213
])
1314
1415
const route = useRoute()

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
},
2929
"dependencies": {
3030
"blurhash": "^2.0.5",
31-
"dayjs": "^1.11.13"
31+
"dayjs": "^1.11.13",
32+
"unsplash-js": "^7.0.19"
3233
},
3334
"devDependencies": {
3435
"@antfu/eslint-config": "3.7.1",
@@ -45,6 +46,7 @@
4546
"esno": "^4.7.0",
4647
"fs-extra": "^11.2.0",
4748
"lint-staged": "^15.2.10",
49+
"node-fetch": "^3.3.2",
4850
"nuxt": "3.13.2",
4951
"octokit": "^4.0.2",
5052
"postcss-import": "^16.1.0",

pages/images.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<script lang="ts" setup>
22
const { data } = await useFetch('/api/images')
3-
4-
console.log(data.value)
53
</script>
64

75
<template>

pnpm-lock.yaml

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)