-
Notifications
You must be signed in to change notification settings - Fork 0
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
stefanlaux
committed
Sep 11, 2023
1 parent
124a3a9
commit bed803f
Showing
1 changed file
with
55 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,63 @@ | ||
export default async function Home() { | ||
const pdfDataUrls = await getPdfUrls(); | ||
const pdfDataUrls = await getPdfUrls(); | ||
|
||
return ( | ||
<main className="flex min-h-screen items-center justify-between flex-row p-5 bg-gray-900 text-white"> | ||
{pdfDataUrls.map((pdf, i) => ( | ||
<div key={i} className="w-full h-full p-5"> | ||
<h2 className="text-lg font-semibold mb-5 uppercase tracking-wide shadow-md p-3 rounded bg-gray-800"> | ||
{pdf.title} | ||
</h2> | ||
{/*<embed src={pdf.dataUrl} type="application/pdf" style={{ width: '100%', height: 'calc(100vh - 200px)' }}></embed>*/} | ||
<object data={pdf.dataUrl} type="application/pdf" style={{ width: '100%', height: 'calc(100vh - 200px)' }}></object> | ||
</div> | ||
))} | ||
</main> | ||
) | ||
return ( | ||
<main className="flex min-h-screen items-center justify-between flex-row p-5 bg-gray-900 text-white"> | ||
{pdfDataUrls.map((pdf, i) => ( | ||
<div key={i} className="w-full h-full p-5"> | ||
<h2 className="text-lg font-semibold mb-5 uppercase tracking-wide shadow-md p-3 rounded bg-gray-800"> | ||
{pdf.title} | ||
</h2> | ||
{/*<embed src={pdf.dataUrl} type="application/pdf" style={{ width: '100%', height: 'calc(100vh - 200px)' }}></embed>*/} | ||
<object | ||
data={pdf.dataUrl} | ||
type="application/pdf" | ||
style={{ width: "100%", height: "calc(100vh - 200px)" }} | ||
></object> | ||
</div> | ||
))} | ||
</main> | ||
); | ||
} | ||
|
||
function getCurrentWeekday() { | ||
const currentDate = new Date(); | ||
const dayOfWeek = currentDate.getDay(); | ||
const weekdays = [ | ||
"Sunday", | ||
"Monday", | ||
"Tuesday", | ||
"Wednesday", | ||
"Thursday", | ||
"Friday", | ||
"Saturday", | ||
]; | ||
const currentWeekday = weekdays[dayOfWeek]; | ||
return currentWeekday; | ||
} | ||
|
||
async function getPdfUrls() { | ||
const pdfData = [ | ||
{ url: "https://www.betriebsrestaurants-migros.ch/media/x4vjg4pd/menueplan_six-ht201.pdf", title: "Menu Plan HT201" }, | ||
{ url: "https://www.betriebsrestaurants-migros.ch/media/k5dnh0sd/landingpage_menueplan_htp.pdf", title: "Menu Plan HTP" } | ||
]; | ||
const pdfData = [ | ||
{ | ||
url: "https://www.betriebsrestaurants-migros.ch/media/x4vjg4pd/menueplan_six-ht201.pdf", | ||
title: "Menu Plan HT201", | ||
}, | ||
{ | ||
url: "https://www.betriebsrestaurants-migros.ch/media/k5dnh0sd/landingpage_menueplan_htp.pdf", | ||
title: "Menu Plan HTP", | ||
}, | ||
]; | ||
|
||
return await Promise.all(pdfData.map(async (data) => { | ||
const response = await fetch(data.url); | ||
const blob = await response.blob(); | ||
const buffer = await blob.arrayBuffer(); | ||
const base64 = Buffer.from(buffer).toString('base64'); | ||
return { | ||
title: data.title, | ||
dataUrl: `data:application/pdf;base64,${base64}#zoom=100&view=FitW&toolbar=0` | ||
}; | ||
})); | ||
return await Promise.all( | ||
pdfData.map(async (data) => { | ||
const response = await fetch(data.url); | ||
const blob = await response.blob(); | ||
const buffer = await blob.arrayBuffer(); | ||
const base64 = Buffer.from(buffer).toString("base64"); | ||
return { | ||
title: data.title, | ||
dataUrl: `data:application/pdf;base64,${base64}#zoom=100&view=FitW&toolbar=0`, | ||
}; | ||
}) | ||
); | ||
} |