Middleware modifications #1
@ -9,7 +9,7 @@ import react from "@astrojs/react";
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
output: "server",
|
||||
output: "hybrid",
|
||||
adapter: node({
|
||||
mode: "standalone",
|
||||
}),
|
||||
@ -45,7 +45,10 @@ export default defineConfig({
|
||||
},
|
||||
],
|
||||
defaultLocale: "en",
|
||||
routing: "manual",
|
||||
routing: {
|
||||
redirectToDefaultLocale: true,
|
||||
prefixDefaultLocale: true
|
||||
},
|
||||
fallback: {
|
||||
de: "en",
|
||||
fr: "en",
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
export const prerender = false;
|
||||
import SingleCompositionCard from "./SingleCompositionCard.astro";
|
||||
import { Separator } from "./ui/separator";
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
export const prerender = true;
|
||||
|
||||
import * as React from "react"
|
||||
|
||||
|
@ -14,7 +14,6 @@ import {
|
||||
} from "./ui/tooltip"
|
||||
|
||||
export function NavButton({ selected, variant, tooltip }) {
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
export const prerender = false;
|
||||
import { ThemeSelector } from "./ThemeSelector"
|
||||
import NavbarSkeleton from "./NavbarSkeleton.astro";
|
||||
import { LangSwitcher } from "./LangSwitcher";
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
import SinglePostCard from "./SinglePostCard.astro";
|
||||
export const prerender = true;
|
||||
import SinglePostCard from "./SinglePostCard.astro";
|
||||
const { filteredPosts } = Astro.props;
|
||||
---
|
||||
|
||||
|
@ -13,8 +13,6 @@ import {
|
||||
TabsTrigger,
|
||||
} from "../components/ui/tabs";
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export function ShowcaseTabs({ currentLocale }) {
|
||||
const t = useTranslations(currentLocale);
|
||||
const showcase = t("showcase");
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
export const prerender = false;
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
|
@ -17,8 +17,6 @@ import {
|
||||
TooltipTrigger,
|
||||
} from "./ui/tooltip"
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
// Please note that clang = lang, it's just for more confusion
|
||||
export function ThemeSelector({ tooltip }) {
|
||||
function getTheme() {
|
||||
|
@ -1,31 +0,0 @@
|
||||
import { defineMiddleware, sequence } from "astro:middleware";
|
||||
import { middleware } from "astro:i18n"; // Astro's own i18n routing config
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const langs = ["en", "de", "cs", "fr"]
|
||||
|
||||
export const userMiddleware = defineMiddleware((ctx, next) => {
|
||||
|
||||
const exceptions = ["/api", "/public"]
|
||||
|
||||
// If path is in exceptions (i.e. api or public) return default middleware to handle it
|
||||
if (exceptions.includes(ctx.url.pathname) ) {
|
||||
return next();
|
||||
|
||||
// If no lang is set => set to english (some pages are language-les exceptions)
|
||||
} else if ( !langs.some(item => ctx.url.href.includes(item)) ) {
|
||||
return Response.redirect(`${ctx.url.protocol}${ctx.url.host}/en${ctx.url.pathname}`);
|
||||
|
||||
} else {
|
||||
return next();
|
||||
}
|
||||
});
|
||||
|
||||
export const onRequest = sequence(
|
||||
userMiddleware,
|
||||
middleware({
|
||||
redirectToDefaultLocale: false,
|
||||
prefixDefaultLocale: true,
|
||||
})
|
||||
);
|
@ -8,7 +8,7 @@ import PostsList from "../../../components/PostsList.astro";
|
||||
import { getLangFromUrl, useTranslations } from "../../../i18n/utils";
|
||||
import { Separator } from "../../../components/ui/separator";
|
||||
|
||||
const t = useTranslations(getLangFromUrl(Astro.url))
|
||||
const t = useTranslations(getLangFromUrl(Astro.url));
|
||||
|
||||
export async function getStaticPaths() {
|
||||
return ["en", "fr", "cs", "de"].map((lang) => {
|
||||
@ -19,14 +19,21 @@ var posts = await getBlogPosts();
|
||||
var filtered_posts = posts.filter(
|
||||
(post) => post.data.language == Astro.currentLocale,
|
||||
);
|
||||
|
||||
---
|
||||
|
||||
<MainLayout title={t("blog")["title"]} description={t("blog")["description"]} lang={Astro.currentLocale}>
|
||||
<MainLayout
|
||||
title={t("blog")["title"]}
|
||||
description={t("blog")["description"]}
|
||||
lang={Astro.currentLocale}
|
||||
>
|
||||
<SinglePageBlogMode>
|
||||
<div class="p-4">
|
||||
<h4 class="mb-2 text-3xl font-semibold leading-none text-foreground">{t("blog")["visible"]}</h4>
|
||||
<p class="mb-4 text-md leading-none text-foreground">{t("blog")["description"]}</p>
|
||||
<h4 class="mb-2 text-3xl font-semibold leading-none text-foreground">
|
||||
{t("blog")["visible"]}
|
||||
</h4>
|
||||
<p class="mb-4 text-md leading-none text-foreground">
|
||||
{t("blog")["description"]}
|
||||
</p>
|
||||
<Separator className="my-4" />
|
||||
<PostsList filteredPosts={filtered_posts} lang={Astro.currentLocale} />
|
||||
</div>
|
||||
|
@ -1,16 +1,12 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
|
||||
export const prerender = false;
|
||||
import MainLayout from "../../../layouts/MainLayout.astro";
|
||||
|
||||
//@ts-ignore
|
||||
import { getCompositions } from "../../../content/config";
|
||||
import SinglePageBlogMode from "../../../layouts/SinglePageBlogMode.astro";
|
||||
import CompositionsList from "../../../components/CompositionsList.astro";
|
||||
import { getLangFromUrl, useTranslations } from "../../../i18n/utils";
|
||||
import { Separator } from "../../../components/ui/separator";
|
||||
|
||||
import SinglePageBlogMode from "../../../layouts/SinglePageBlogMode.astro";
|
||||
import { getCompositions } from "../../../content/config";
|
||||
import CompositionsList from "../../../components/CompositionsList.astro";
|
||||
|
||||
const t = useTranslations(getLangFromUrl(Astro.url));
|
||||
|
||||
export async function getStaticPaths() {
|
||||
@ -19,22 +15,21 @@ export async function getStaticPaths() {
|
||||
});
|
||||
}
|
||||
|
||||
const songs = await getCompositions()
|
||||
var songs = await getCompositions()
|
||||
songs = songs.reverse()
|
||||
---
|
||||
|
||||
<MainLayout
|
||||
title={t("music")["pageTitle"]}
|
||||
description={t("music")["description"]}
|
||||
lang={Astro.currentLocale}
|
||||
themeOverride="theme_auto"
|
||||
>
|
||||
<SinglePageBlogMode>
|
||||
<div class="p-4">
|
||||
<h4 class="mb-2 text-3xl font-semibold leading-none text-foreground">{t("music")["title"]}</h4>
|
||||
<p class="mb-4 text-md leading-none text-foreground">{t("music")["description"]}</p>
|
||||
{ // @ts-ignore }
|
||||
<Separator className="my-4"/>
|
||||
<CompositionsList songs={songs.reverse()}/>
|
||||
<CompositionsList songs={songs}/>
|
||||
</div>
|
||||
</SinglePageBlogMode>
|
||||
</MainLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user