Compare commits

..

No commits in common. "11bc60c10360cf2cb5a594b9eb42503f87944057" and "b103c045e2d0cf647e516a6422ca848c320cc505" have entirely different histories.

5 changed files with 11 additions and 48 deletions

1
.idea/mercury.iml generated
View file

@ -5,7 +5,6 @@
<excludeFolder url="file://$MODULE_DIR$/.tmp" /> <excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" /> <excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" /> <excludeFolder url="file://$MODULE_DIR$/tmp" />
<excludeFolder url="file://$MODULE_DIR$/.astro" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

View file

@ -3,7 +3,7 @@ import {posts} from './posts/_schemas';
import {pages} from "./pages/_schemas"; import {pages} from "./pages/_schemas";
import {file} from 'astro/loaders'; import {file} from 'astro/loaders';
import { z } from 'astro:content'; import { z } from 'astro:content';
import {authors} from '../data/authors._schema.ts'; import {siteConfig} from "../config.ts";
const blogCollection = defineCollection({ const blogCollection = defineCollection({
type: 'content', type: 'content',
@ -24,7 +24,15 @@ const blogRollData = defineCollection({
const authorsData = defineCollection({ const authorsData = defineCollection({
loader: file("src/data/authors.yaml"), loader: file("src/data/authors.yaml"),
schema: authors, schema: z.object({
name: z.string().default(siteConfig.defaultAuthor.name),
email: z.string().email().default(siteConfig.defaultAuthor.email),
mcplayerid: z.string().optional(),
social: z.object({
twitter: z.string().optional(),
fediverse: z.string().optional(),
}).optional(),
})
}); });
export const collections = { export const collections = {

View file

@ -1,13 +0,0 @@
import {z} from "astro:content";
import {siteConfig} from "../config.ts";
export const authors = ({ image }) => z.object({
name: z.string().default(siteConfig.defaultAuthor.name),
email: z.string().email().default(siteConfig.defaultAuthor.email),
avatar: image().optional(),
mcplayerid: z.string().optional(),
social: z.object({
twitter: z.string().optional(),
fediverse: z.string().optional(),
}).optional(),
});

View file

@ -1,8 +1,7 @@
Wheatley: # the key name (id) of the author, which is used in the front matter Wheatley: # the key name (id) of the author, which is used in the front matter
name: "Wheatley" # the display name of the author name: "Wheatley" # the display name of the author
email: "hello@example.org" # the email address of the author email: "hello@example.org" # the email address of the author
avatar: "https://minotar.net/helm/Wheatley/64.png" # the URL of the author's avatar image (takes precedence over the minecraft player avatar, a square image with no more than 64*64 is recommended) mcplayerid: "Wheatley" # the Minecraft player ID of the author, if applicable
mcplayerid: "Wheatley" # the Minecraft player ID of the author, if applicable (used for generating player avatars)
social: # the social media accounts of the author, if any (there is no reference for this yet except for the twitter handle) social: # the social media accounts of the author, if any (there is no reference for this yet except for the twitter handle)
twitter: "@wheatley" twitter: "@wheatley"
fediverse: "@" fediverse: "@"

View file

@ -1,5 +1,4 @@
import { getCollection } from 'astro:content'; import { getCollection } from 'astro:content';
import { getImage } from "astro:assets";
export async function getStaticPaths() { export async function getStaticPaths() {
const authorsData = await getCollection('authors'); const authorsData = await getCollection('authors');
@ -12,35 +11,6 @@ export async function getStaticPaths() {
export async function GET({ props }) { export async function GET({ props }) {
const { author } = props; const { author } = props;
if (author.data.avatar) {
try {
const optimizedImage = await getImage({
src: author.data.avatar,
width: 64,
height: 64,
format: 'png'
});
// Fetch the optimized image
const imageResponse = await fetch(optimizedImage.src);
if (!imageResponse.ok) {
throw new Error('Failed to fetch optimized image');
}
const imageBuffer = await imageResponse.arrayBuffer();
return new Response(imageBuffer, {
headers: {
'Content-Type': 'image/png',
'Cache-Control': 'public, max-age=86400' // Cache for 24 hours
}
});
} catch (error) {
console.error('Error processing avatar image:', error);
// Fall through to the mcplayerid check if avatar processing fails
}
}
if (!author.data.mcplayerid) { if (!author.data.mcplayerid) {
return new Response(null, { status: 404 }); return new Response(null, { status: 404 });
} }