-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ea3a0c
commit fdc24b1
Showing
6 changed files
with
376 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { ImageResponse } from '@analogjs/content/og'; | ||
import { Event } from '../../../models/event.model'; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const data = await fetch('http://localhost:4200/api/v1/events/upcoming'); | ||
const events: Event[] = await data.json(); | ||
const eventLength = events.length; | ||
const topEvents = events.slice(0, 3); | ||
|
||
const fontFile = await fetch( | ||
'https://og-playground.vercel.app/inter-latin-ext-700-normal.woff', | ||
); | ||
const fontData: ArrayBuffer = await fontFile.arrayBuffer(); | ||
const query = getQuery(event); // query params | ||
|
||
const template = ` | ||
<div tw="bg-gray-50 flex flex-col w-full h-full items-center justify-center"> | ||
<h2 class="text-5xl">${eventLength} upcoming events</h2> | ||
${topEvents.map((event) => `${event.name}`)} | ||
</div> | ||
`; | ||
|
||
const cards = ` | ||
${topEvents.map((event) => { | ||
return `<h4 class="text-xl font-bold my-1"> | ||
${event.name} | ||
</h4> | ||
<div class="flex gap-4 mb-2"> | ||
<div class="flex justify-center items-center w-20 h-20"> | ||
<img | ||
class="rounded-xl" | ||
[src]="${event.community?.logo}" | ||
aria-hidden="true" | ||
height="70" | ||
width="70" | ||
alt="" | ||
/> | ||
</div> | ||
<div class="flex-1"> | ||
<span class="font-bold text-primary" itemprop="date"> | ||
${event.date} | ||
${event.endDate ? '- ' + event.endDate : ''} | ||
</span> | ||
</div> | ||
</div>`; | ||
})} | ||
`; | ||
|
||
return new ImageResponse(template, { | ||
debug: true, // disable caching | ||
fonts: [ | ||
{ | ||
name: 'Inter Latin', | ||
data: fontData, | ||
style: 'normal', | ||
}, | ||
], | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.