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 }} key: ${{ runner.os }}-lfs-${{ env.LFS_CACHE_ID }}
restore-keys: | restore-keys: |
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: 📦 Install PNPM - name: 📦 Install PNPM
uses: pnpm/action-setup@v3 uses: pnpm/action-setup@v3
id: pnpm-install id: pnpm-install
with: with:
version: 8 version: 8
node_version: 20
run_install: false run_install: false
- name: Get pnpm store directory - 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 { i18n, filterSitemapByDefaultLocale } from "astro-i18n-aut/integration";
import sitemap from "@astrojs/sitemap"; import sitemap from "@astrojs/sitemap";
import mdx from '@astrojs/mdx'; import mdx from '@astrojs/mdx';
import tailwind from '@astrojs/tailwind';
import glsl from 'vite-plugin-glsl'; import glsl from 'vite-plugin-glsl';
import svelte from "@astrojs/svelte"; import svelte from "@astrojs/svelte";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
--- ---
import { useTranslations } from "@i18n/utils"; import { useTranslations } from "@i18n/utils";
const t = useTranslations(Astro); const t = useTranslations(Astro.url);
--- ---
<div class="arrow flex items-center gap-2"> <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"); const model = await GLTFLoader.load(gl, "/models/leaf.glb");
// @ts-ignore
const data = model.nodes[0].children[0].geometry.attributes; const data = model.nodes[0].children[0].geometry.attributes;
let offset = new Float32Array(num * 3); 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 debug = true;
let EXIF = {}; let EXIF = {};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,15 +3,13 @@ import Layout from "@layouts/Layout.astro";
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
import { useTranslatedPath } from "@i18n/utils"; 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( const posts = await Promise.all(
collections.map((collection) => { collections.map((collection) => {
return getCollection(collection, { return getCollection(collection);
fields: ["slug", "title", "date", "tags"],
});
}), }),
); );