Transfer some Posts and automate original German
This commit is contained in:
@ -4,26 +4,37 @@ import {getCollection, CollectionEntry} from "astro:content";
|
||||
import PageLayout from "../../layouts/PageLayout.astro";
|
||||
import {TagSolid, CalendarMonthSolid} from "flowbite-svelte-icons"
|
||||
import TagComponent from "../../components/TagComponent.astro";
|
||||
import {l} from "../../util/util";
|
||||
import {capitalize} from "../../components/admin/util";
|
||||
|
||||
export const getStaticPaths = createGetStaticPaths(async () => {
|
||||
const posts = await getCollection('announcements', entry => entry.id.split('/')[0] === astroI18n.locale)
|
||||
const posts = await getCollection('announcements', entry => entry.id.split('/')[0] === astroI18n.locale);
|
||||
|
||||
const germanPosts = await getCollection('announcements', entry => entry.id.split('/')[0] === 'de');
|
||||
|
||||
germanPosts.forEach(value => {
|
||||
if (posts.find(post => post.data.key === value.data.key)) {
|
||||
return
|
||||
} else {
|
||||
posts.push(value)
|
||||
}
|
||||
})
|
||||
|
||||
return posts.map(value => ({
|
||||
params: {
|
||||
slug: value.slug.split("/").slice(1).join("/")
|
||||
},
|
||||
props: {
|
||||
post: value
|
||||
post: value,
|
||||
german: value.id.split('/')[0] != astroI18n.locale
|
||||
}
|
||||
}))
|
||||
})
|
||||
|
||||
interface Props {
|
||||
post: CollectionEntry<'announcements'>
|
||||
post: CollectionEntry<'announcements'>,
|
||||
german: boolean
|
||||
}
|
||||
|
||||
const {post} = Astro.props;
|
||||
const {post, german} = Astro.props;
|
||||
const { Content } = await post.render();
|
||||
---
|
||||
|
||||
@ -37,7 +48,7 @@ const { Content } = await post.render();
|
||||
month: 'short',
|
||||
year: 'numeric'
|
||||
}).format(post.data.created)} </h5>
|
||||
{post.data.german && (
|
||||
{german && (
|
||||
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4" role="alert">
|
||||
<div class="font-bold">{t("warning.title", {}, {route: "/rules"})}</div>
|
||||
<div>{t("warning.text", {}, {route: "/rules"})}</div>
|
||||
@ -111,6 +122,10 @@ const { Content } = await post.render();
|
||||
|
||||
<style is:global>
|
||||
article {
|
||||
fight-table, group-table {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
>* {
|
||||
all: revert;
|
||||
}
|
||||
|
||||
@ -3,10 +3,25 @@ import { getCollection } from "astro:content"
|
||||
import PageLayout from "../../layouts/PageLayout.astro";
|
||||
import {astroI18n, t} from "astro-i18n";
|
||||
import PostComponent from "../../components/PostComponent.astro";
|
||||
import * as dayjs from "dayjs";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const posts = (await getCollection("announcements", (entry) => entry.id.split("/")[0] === astroI18n.locale))
|
||||
.sort((a, b) => dayjs(b.data.created).unix() - dayjs(a.data.created).unix());
|
||||
async function getPosts() {
|
||||
const posts = await getCollection('announcements', entry => entry.id.split('/')[0] === astroI18n.locale);
|
||||
|
||||
const germanPosts = await getCollection('announcements', entry => entry.id.split('/')[0] === 'de');
|
||||
|
||||
germanPosts.forEach(value => {
|
||||
if (posts.find(post => post.data.key === value.data.key)) {
|
||||
return
|
||||
} else {
|
||||
posts.push(value)
|
||||
}
|
||||
})
|
||||
|
||||
return posts.sort((a, b) => dayjs(b.data.created).unix() - dayjs(a.data.created).unix()).filter((value, index) => index < 20);
|
||||
}
|
||||
|
||||
const posts = await getPosts();
|
||||
|
||||
---
|
||||
|
||||
|
||||
@ -5,11 +5,24 @@ import {getCollection} from "astro:content";
|
||||
import PageLayout from "../../../layouts/PageLayout.astro";
|
||||
import {capitalize} from "../../../components/admin/util";
|
||||
import PostComponent from "../../../components/PostComponent.astro";
|
||||
import * as dayjs from "dayjs";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export const getStaticPaths = createGetStaticPaths(async () => {
|
||||
const posts = (await getCollection('announcements', entry => entry.id.split("/")[0] === astroI18n.locale))
|
||||
.sort((a, b) => dayjs(b.data.created).unix() - dayjs(a.data.created).unix());
|
||||
let posts = (await getCollection('announcements', entry => entry.id.split("/")[0] === astroI18n.locale));
|
||||
|
||||
const germanPosts = await getCollection('announcements', entry => entry.id.split('/')[0] === 'de');
|
||||
|
||||
posts.sort((a, b) => dayjs(b.data.created).unix() - dayjs(a.data.created).unix());
|
||||
|
||||
germanPosts.forEach(value => {
|
||||
if (posts.find(post => post.data.key === value.data.key)) {
|
||||
return
|
||||
} else {
|
||||
posts.push(value)
|
||||
}
|
||||
})
|
||||
|
||||
posts = posts.filter((value, index) => index < 20)
|
||||
|
||||
let groupedByTags: Record<string, CollectionEntry<'announcements'>[]> = {}
|
||||
posts.forEach(post => {
|
||||
|
||||
@ -6,23 +6,34 @@ import PageLayout from "../../layouts/PageLayout.astro";
|
||||
export const getStaticPaths = createGetStaticPaths(async () => {
|
||||
let posts = await getCollection("rules", value => value.id.split("/")[0] === astroI18n.locale);
|
||||
|
||||
const germanPosts = await getCollection('rules', entry => entry.id.split('/')[0] === 'de');
|
||||
|
||||
germanPosts.forEach(value => {
|
||||
if (posts.find(post => post.id.split("/")[1] === value.id.split("/")[1])) {
|
||||
return
|
||||
} else {
|
||||
posts.push(value)
|
||||
}
|
||||
})
|
||||
|
||||
return posts.map((page) => ({
|
||||
props: { page }, params: { mode: page.slug.split("/")[1] }
|
||||
props: { page, german: page.id.split("/")[0] != astroI18n.locale }, params: { mode: page.slug.split("/")[1] }
|
||||
}))
|
||||
})
|
||||
|
||||
interface Props {
|
||||
page: CollectionEntry<"rules">
|
||||
page: CollectionEntry<"rules">,
|
||||
german: boolean
|
||||
}
|
||||
|
||||
const { page } = Astro.props;
|
||||
const { page, german } = Astro.props;
|
||||
const { Content } = await page.render();
|
||||
---
|
||||
|
||||
|
||||
<PageLayout title={t("title", {mode: t(`${page.data.translationKey}.title`, {}, {route: "/rules"})}, {route: "/rules"})}>
|
||||
<article>
|
||||
{page.data.german && (
|
||||
{german && (
|
||||
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4" role="alert">
|
||||
<div class="font-bold">{t("warning.title", {}, {route: "/rules"})}</div>
|
||||
<div>{t("warning.text", {}, {route: "/rules"})}</div>
|
||||
|
||||
Reference in New Issue
Block a user