Skip to content

Commit

Permalink
chore: up
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Aug 16, 2024
1 parent 8bd5614 commit cb6271e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang="ts">
import type { BlobObject } from '@nuxthub/core'
import { UseTimeAgo, vInfiniteScroll } from '@vueuse/components'
const { data } = await useFetch('/api/drawings', {
Expand All @@ -19,6 +20,14 @@ async function loadMore() {
data.value.hasMore = more.hasMore
loading.value = false
}
function drawingTitle(drawing: BlobObject) {
const title = drawing.customMetadata?.description || ''
if (!drawing.customMetadata?.aiImage) {
return title + '\n[AI image could not be generated]'
}
return title
}
</script>

<template>
Expand All @@ -31,7 +40,7 @@ async function loadMore() {
>
<div
class="group relative max-w-[400px]"
:title="drawing.customMetadata?.description || ''"
:title="drawingTitle(drawing)"
>
<img
:src="`/drawings/${drawing.pathname}`"
Expand Down
9 changes: 8 additions & 1 deletion server/api/upload.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ export default eventHandler(async (event) => {
strength: 0.75,
image: [...new Uint8Array(await drawing.arrayBuffer())],
})
.then((blob) => {
.then((blob: Blob | Uint8Array) => {
if (blob instanceof Uint8Array) {
blob = new Blob([blob])
}
// If black image, skip
if (blob.size === 842) {
return null
}
return hubBlob().put(`${name}.png`, blob, {
prefix: 'ai/',
addRandomSuffix: true,
Expand Down

0 comments on commit cb6271e

Please sign in to comment.