chore: pnpm up
This commit is contained in:
@@ -53,10 +53,15 @@ const allowedExif = [
|
||||
];
|
||||
|
||||
export async function getExifData(image: ImageMetadata) {
|
||||
if (image.format === "svg") return undefined; // SVGs don't have EXIF data")
|
||||
const sharp = await getSharp();
|
||||
if (!sharp) return;
|
||||
const imagePath = (image as ImageMetadata & { fsPath: string }).fsPath;
|
||||
try {
|
||||
const tags = await ExifReader.load((image as ImageMetadata & { fsPath: string }).fsPath, { async: true });
|
||||
|
||||
const buffer = await sharp(imagePath).toBuffer();
|
||||
|
||||
const tags = await ExifReader.load(buffer, { async: true });
|
||||
|
||||
const out: Record<string, any> = {};
|
||||
let hasExif = false;
|
||||
@@ -70,7 +75,7 @@ export async function getExifData(image: ImageMetadata) {
|
||||
return hasExif ? out : undefined;
|
||||
} catch (error) {
|
||||
|
||||
console.log("Error reading EXIF data", error);
|
||||
console.log(`Error reading EXIF data from ${imagePath}`, error);
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
||||
10
src/helpers/memorium.ts
Normal file
10
src/helpers/memorium.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export async function listResource(id: string): Promise<any[]> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`http://localhost:8080/resources?name=${id}`,
|
||||
);
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
return []
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const response = await fetch(
|
||||
"http://localhost:8080/resources?name=Media/movies/*",
|
||||
);
|
||||
const movieReviews = await response.json();
|
||||
const movieReviews = await memorium.listResource("Media/movies/*");
|
||||
|
||||
const paths = movieReviews.map((review: any) => {
|
||||
return {
|
||||
@@ -16,16 +14,21 @@ export async function getStaticPaths() {
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
const reviews = await memorium.listResource(
|
||||
//@ts-ignore
|
||||
`http://localhost:8080/resources?name=Media/movies/${Astro.params.movieName}.md`,
|
||||
`Media/movies/${Astro.params.movieName}.md`,
|
||||
);
|
||||
const reviewes = await response.json();
|
||||
const review = reviewes[0];
|
||||
|
||||
if (reviews.length === 0) {
|
||||
return new Response(null, {
|
||||
status: 404,
|
||||
statusText: "Not found",
|
||||
});
|
||||
}
|
||||
const review = reviews[0];
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import HeroCard from "@components/HeroCard.astro";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
|
||||
const response = await fetch(
|
||||
"http://localhost:8080/resources?name=Media/movies/*",
|
||||
);
|
||||
const movieReviews = await response.json();
|
||||
const movieReviews = await memorium.listResource("Media/movies/*");
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
|
||||
@@ -2,35 +2,40 @@
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import { useTranslatedPath } from "@i18n/utils";
|
||||
import markdownToText from "@helpers/markdownToText";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
|
||||
const path = useTranslatedPath(Astro.url);
|
||||
|
||||
const collection = "resources/recipes";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const response = await fetch(
|
||||
"http://localhost:8080/resources?name=Recipes/*",
|
||||
);
|
||||
const recipes = await response.json();
|
||||
|
||||
const paths = recipes.map((recipe: any) => {
|
||||
return {
|
||||
params: {
|
||||
recipeName: recipe.identifier
|
||||
.replace("Recipes/", "")
|
||||
.replace(/\.md$/, ""),
|
||||
},
|
||||
};
|
||||
});
|
||||
const recipes = await memorium.listResource("Recipes/*");
|
||||
|
||||
return paths;
|
||||
const paths = recipes.map((recipe: any) => {
|
||||
return {
|
||||
params: {
|
||||
recipeName: recipe.identifier
|
||||
.replace("Recipes/", "")
|
||||
.replace(/\.md$/, ""),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
|
||||
const recipes = await memorium.listResource(
|
||||
//@ts-ignore
|
||||
`http://localhost:8080/resources?name=Recipes/${Astro.params.recipeName}.md`,
|
||||
`Recipes/${Astro.params.recipeName}.md`,
|
||||
);
|
||||
const recipes = await response.json();
|
||||
if (recipes.length === 0) {
|
||||
return new Response(null, {
|
||||
status: 404,
|
||||
statusText: "Not found",
|
||||
});
|
||||
}
|
||||
const recipe = recipes[0];
|
||||
---
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import HeroCard from "@components/HeroCard.astro";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
|
||||
const response = await fetch("http://localhost:8080/resources?name=Recipes/*");
|
||||
const recipes = await response.json();
|
||||
const recipes = await memorium.listResource("Recipes/*");
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
---
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import { useTranslatedPath } from "@i18n/utils";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
|
||||
const collection = "resources/series";
|
||||
|
||||
const path = useTranslatedPath(Astro.url);
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const response = await fetch(
|
||||
"http://localhost:8080/resources?name=Media/series/*",
|
||||
);
|
||||
const seriesReviews = await response.json();
|
||||
const seriesReviews = await memorium.listResource("Media/series/*");
|
||||
|
||||
const paths = seriesReviews.map((review:any) => {
|
||||
const paths = seriesReviews.map((review: any) => {
|
||||
return {
|
||||
params: {
|
||||
seriesName: review.identifier
|
||||
@@ -25,12 +23,18 @@ export async function getStaticPaths() {
|
||||
return paths;
|
||||
}
|
||||
|
||||
const response = await fetch(
|
||||
|
||||
const reviews = await memorium.listResource(
|
||||
//@ts-ignore
|
||||
`http://localhost:8080/resources?name=Media/series/${Astro.params.seriesName}.md`,
|
||||
`Media/series/${Astro.params.seriesName}.md`,
|
||||
);
|
||||
const reviewes = response.ok ? await response.json() : [];
|
||||
const review = reviewes[0];
|
||||
if (reviews.length === 0) {
|
||||
return new Response(null, {
|
||||
status: 404,
|
||||
statusText: "Not found",
|
||||
});
|
||||
}
|
||||
const review = reviews[0];
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
---
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import HeroCard from "@components/HeroCard.astro";
|
||||
import * as memorium from "@helpers/memorium";
|
||||
|
||||
const response = await fetch(
|
||||
"http://localhost:8080/resources?name=Media/series/*",
|
||||
);
|
||||
const seriesReviewes = await response.json();
|
||||
const seriesReviewes = await memorium.listResource("Media/series/*");
|
||||
---
|
||||
|
||||
<Layout title="Max Richter">
|
||||
|
||||
Reference in New Issue
Block a user