Skip to content

Commit

Permalink
Use our own image component
Browse files Browse the repository at this point in the history
  • Loading branch information
Siilwyn committed Jan 3, 2025
1 parent 4d6c007 commit 1fde16d
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 160 deletions.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@json-feed-types/1_1": "^1.0.2",
"@nuxtjs/plausible": "^1.2.0",
"@std/http": "npm:@jsr/std__http@^1.0.10",
"@voorhoede/image-vue": "^1.0.1",
"@voorhoede/vue-dato-video": "^3.1.0",
"datocms-listen": "^0.1.14",
"datocms-structured-text-utils": "^2.0.4",
Expand Down
45 changes: 0 additions & 45 deletions src/components/app-image/app-image.vue

This file was deleted.

47 changes: 0 additions & 47 deletions src/components/app-image/generate-src-set.ts

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/app-image/readme.md

This file was deleted.

5 changes: 0 additions & 5 deletions src/components/app-image/types.ts

This file was deleted.

53 changes: 27 additions & 26 deletions src/components/dato-image/dato-image.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<app-image
<Image
class="dato-image"
:src="props.src"
:loader="loader"
Expand All @@ -8,36 +8,37 @@
</template>

<script setup lang="ts">
import { withQuery } from 'ufo';
import { type ImageLoader } from '../app-image/types';
import type { ImgixUrl } from 'typescript-imgix-url-params';
import { withQuery, type QueryObject } from "ufo";
import type { ImgixUrl } from "typescript-imgix-url-params";
import { Image, type ImageLoader } from "@voorhoede/image-vue";
const props = defineProps<{
src: string,
srcset?: string,
modifiers?: ImgixUrl.Params,
}>();
const props = defineProps<{
src: string;
srcset?: string;
modifiers?: ImgixUrl.Params;
}>();
const imgixLoader: ImageLoader = ({ src, width, quality }) => (
withQuery(src, { w: width, q: quality, auto: 'format,compress', ...props.modifiers })
);
const imgixLoader: ImageLoader = ({ src, width, quality }) =>
withQuery(src, {
w: width,
q: quality,
auto: "format,compress",
cs: "origin",
...(props.modifiers as QueryObject),
});
const loader = computed(() => (
props.src.endsWith('.svg')
? undefined
: imgixLoader
));
const loader = computed(() =>
props.src.endsWith(".svg") ? ({ src }: { src: string }) => src : imgixLoader
);
const checkedSrcset = computed(() => (
props.src.endsWith('.svg')
? ''
: props.srcset
));
const checkedSrcset = computed(() =>
props.src.endsWith(".svg") ? "" : props.srcset
);
</script>

<style>
.dato-image {
display: block;
max-width: 100%;
}
.dato-image {
display: block;
max-width: 100%;
}
</style>

0 comments on commit 1fde16d

Please sign in to comment.