feat: some shit
Some checks failed
Deploy to GitHub Pages / build (push) Failing after 7m15s
Deploy to GitHub Pages / deploy (push) Has been skipped

This commit is contained in:
max_richter 2024-04-03 18:07:54 +02:00
parent 5e931f15d3
commit 58b74bb801
19 changed files with 62 additions and 63 deletions

View File

@ -37,11 +37,17 @@ jobs:
key: ${{ runner.os }}-lfs-${{ env.LFS_CACHE_ID }}
restore-keys: |
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: 📦 Install PNPM
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 8
node_version: 20
run_install: false
- name: Get pnpm store directory

View File

@ -2,7 +2,6 @@ import { defineConfig } from 'astro/config';
import { i18n, filterSitemapByDefaultLocale } from "astro-i18n-aut/integration";
import sitemap from "@astrojs/sitemap";
import mdx from '@astrojs/mdx';
import tailwind from '@astrojs/tailwind';
import glsl from 'vite-plugin-glsl';
import svelte from "@astrojs/svelte";

View File

@ -24,8 +24,8 @@ const {
slug,
} = Astro.props.post;
const translatePath = useTranslatedPath(Astro);
const t = useTranslations(Astro);
const translatePath = useTranslatedPath(Astro.url);
const t = useTranslations(Astro.url);
const imagePath = `../content/${collection}/${slug.split("/")[0]}/${headerImg}`;

View File

@ -6,7 +6,7 @@
let progress = [];
let currentIndex = -1;
const maxZoom = 5;
import { swipe } from "svelte-gestures";
// import { swipe } from "svelte-gestures";
const mod = (a: number, b: number) => ((a % b) + b) % b;

View File

@ -16,7 +16,7 @@ function translatePath(lang: string) {
return `/${[lang, ...split].join("/")}`;
}
const t = useTranslations(Astro);
const t = useTranslations(Astro.url);
---
<ul>

View File

@ -6,7 +6,7 @@ import { Card } from "./card";
import { useTranslations } from "@i18n/utils";
const t = useTranslations(Astro);
const t = useTranslations(Astro.url);
---
<Card

View File

@ -7,8 +7,8 @@ function isActive(path: string) {
return Astro.url.pathname === path ? "active" : "";
}
const t = useTranslations(Astro);
const translatePath = useTranslatedPath(Astro);
const t = useTranslations(Astro.url);
const translatePath = useTranslatedPath(Astro.url);
const paths = [
{

View File

@ -5,9 +5,9 @@ interface Props {
post: {
data: {
title: string;
description: string;
icon: string;
tags: string[];
description?: string;
icon?: string;
tags?: string[];
};
collection: string;
body: string;

View File

@ -1,6 +1,6 @@
---
import { useTranslations } from "@i18n/utils";
const t = useTranslations(Astro);
const t = useTranslations(Astro.url);
---
<div class="arrow flex items-center gap-2">

View File

@ -1,6 +1,6 @@
---
import { useTranslations } from "@i18n/utils";
const t = useTranslations(Astro);
const t = useTranslations(Astro.url);
---
<div class="arrow flex items-center gap-2">

View File

@ -50,6 +50,7 @@ export function createLeaves({ canvas, num = 20, alpha = false, minZ = -1, maxZ
const model = await GLTFLoader.load(gl, "/models/leaf.glb");
// @ts-ignore
const data = model.nodes[0].children[0].geometry.attributes;
let offset = new Float32Array(num * 3);

View File

@ -1,3 +1,6 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
let debug = true;
let EXIF = {};

View File

@ -1,3 +1,4 @@
//@ts-nocheck
// Reasonable defaults
var PIXEL_STEP = 10;

View File

@ -1,18 +1,15 @@
import { defaultLocale, getLocale } from 'astro-i18n-aut';
import { ui, defaultLang, showDefaultLang } from './ui';
import type { AstroGlobal } from 'astro';
export function useTranslatedPath(astro: AstroGlobal) {
const locale = getLocale(astro.url);
export function useTranslatedPath(url: URL) {
const locale = getLocale(url);
return function translatePath(path: string, l: string = locale) {
return !showDefaultLang && l === defaultLang ? path : `/${l}${path}`.replace(/\/$/g, '');
}
}
export function useTranslations(astro: AstroGlobal) {
const lang = getLocale(astro.url);
export function useTranslations(url: URL) {
const lang = getLocale(url);
return function t(key: keyof typeof ui[typeof defaultLang]) {
return ui[lang as keyof typeof ui][key] || ui[defaultLang][key];
}
@ -25,11 +22,11 @@ export function parseSlug(id: string) {
return [splitPath.join("/"), lang]
}
export function filterCollection<T extends { id: string }>(collection: T[], locale: string): T[] {
export function filterCollection<T extends { id: string, data: { date: Date } }>(collection: T[], locale: string): T[] {
return collection.filter(post => {
const [_, lang] = parseSlug(post?.id);
return lang === locale;
}).sort((a, b) => {
return a.data.date > b.data.date ? -1 : 1;
return (a?.data?.date > b?.data?.date) ? -1 : 1;
});
}

View File

@ -10,7 +10,7 @@ type CustomProps = {
type Props = CollectionEntry<"blog">["data"] & CustomProps;
const { title, date, _layout, backlink = "/blog" } = Astro.props;
const path = useTranslatedPath(Astro);
const path = useTranslatedPath(Astro.url);
---
<Layout title={title}>

View File

@ -19,8 +19,8 @@ const projects = filterCollection(
getLocale(Astro.url),
);
const t = useTranslations(Astro);
const tp = useTranslatedPath(Astro);
const t = useTranslations(Astro.url);
const tp = useTranslatedPath(Astro.url);
const featuredProject = projects.find((project) => project.data?.featured);
const otherProjects = projects

View File

@ -8,7 +8,7 @@ import HeroCard from "@components/HeroCard.astro";
const locale = getLocale(Astro.url);
const pages = await getCollection("projects");
const posts = filterCollection(pages, locale)
.sort((a, b) => b.data.date - a.data.date)
.sort((a, b) => (b.data.date > a.data.date ? 1 : -1))
.sort((a) => (a.data.featured ? -1 : 1));
---

View File

@ -3,28 +3,24 @@ import Layout from "@layouts/Layout.astro";
import { getCollection } from "astro:content";
import { useTranslatedPath } from "@i18n/utils";
const collections = ["blog", "photos", "projects"];
const collections = ["blog", "photos", "projects"] as const;
const tp = useTranslatedPath(Astro);
const tp = useTranslatedPath(Astro.url);
export async function getStaticPaths() {
const collections = ["blog", "photos", "projects"];
const posts = await Promise.all(
collections.map((collection) => {
return getCollection(collection, {
fields: ["slug", "title", "date", "tags"],
const collections = ["blog", "photos", "projects"] as const;
const posts = await Promise.all(
collections.map((collection) => getCollection(collection)),
);
const tags = new Set();
posts.flat().forEach((post) => {
if (!post.data?.tags) return;
post.data.tags.forEach((tag: string) => {
tags.add(tag.toLowerCase());
});
}),
);
const tags = new Set();
posts.flat().forEach((post) => {
if (!post.data?.tags) return;
post.data.tags.forEach((tag) => {
tags.add(tag.toLowerCase());
});
});
return [...tags.values()].map((tag) => {
return {
@ -37,22 +33,17 @@ posts.flat().forEach((post) => {
const { tag } = Astro.params;
const allPosts = (await Promise.all(
collections.map((collection) => {
return getCollection(collection, {
fields: ["slug", "title", "date", "tags"],
});
}),
)).flat();
const allPosts = (
await Promise.all(
collections.map((collection) => {
return getCollection(collection);
}),
)
).flat();
const posts = allPosts.filter((post) => {
return post.data?.tags?.find(t => t.toLowerCase() === tag);
return post.data?.tags?.find((t) => t.toLowerCase() === tag);
});
---
<Layout title="Max Richter">
@ -62,10 +53,13 @@ const posts = allPosts.filter((post) => {
<div class="flex flex-col gap-2">
{
posts.map((post) => {
return <a href={tp("/"+post.collection+"/" + post.slug)}>{post.slug}</a>;
return (
<a href={tp("/" + post.collection + "/" + post.slug)}>
{post.slug}
</a>
);
})
}
</div>
</article>
</Layout>

View File

@ -3,15 +3,13 @@ import Layout from "@layouts/Layout.astro";
import { getCollection } from "astro:content";
import { useTranslatedPath } from "@i18n/utils";
const tp = useTranslatedPath(Astro);
const tp = useTranslatedPath(Astro.url);
const collections = ["blog", "photos", "projects"];
const collections = ["blog", "photos", "projects"] as const;
const posts = await Promise.all(
collections.map((collection) => {
return getCollection(collection, {
fields: ["slug", "title", "date", "tags"],
});
return getCollection(collection);
}),
);