Enabled SSR with pre-renders
- Enable server output mode - Pre-render for (almost) every .astro file - Fixed custom middleware
This commit is contained in:
parent
397ba05c7c
commit
7a71a66dc7
@ -9,7 +9,7 @@ import react from "@astrojs/react";
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
output: "hybrid",
|
||||
output: "server",
|
||||
adapter: node({
|
||||
mode: "standalone",
|
||||
}),
|
||||
|
@ -1,4 +1,6 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
|
||||
import SinglePage from "../layouts/SinglePage.astro";
|
||||
|
||||
import AboutModule from "./AboutModule.astro";
|
||||
|
@ -1,5 +1,6 @@
|
||||
---
|
||||
const { row, flipped, image, alt } = Astro.props;
|
||||
---
|
||||
export const prerender = true;
|
||||
const { row, flipped, image } = Astro.props;
|
||||
---
|
||||
|
||||
<div class={`rows-start-${row} row-span-1 h-full w-full`}>
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
import SingleCompositionCard from "./SingleCompositionCard.astro";
|
||||
import { Separator } from "./ui/separator";
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
import { ContactButton } from "./ContactButton";
|
||||
---
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
import SinglePage from "../layouts/SinglePage.astro";
|
||||
import { getLangFromUrl, useTranslations } from "../i18n/utils";
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
import { ThemeSelector } from "./ThemeSelector"
|
||||
import NavbarSkeleton from "./NavbarSkeleton.astro";
|
||||
import { LangSwitcher } from "./LangSwitcher";
|
||||
|
@ -1,3 +1,6 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
---
|
||||
<nav class="w-full flex justify-center">
|
||||
<div class="fixed w-full top-0 z-50 bg-bkgNavbar/70 shadow-md rounded-b-md backdrop-blur-lg">
|
||||
<div
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
import SinglePostCard from "./SinglePostCard.astro";
|
||||
|
||||
export const prerender = true;
|
||||
const { filteredPosts } = Astro.props;
|
||||
---
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
---
|
||||
import SinglePage from "../layouts/SinglePage.astro";
|
||||
import { ShowcaseTabs } from "./ShowcaseTabs.jsx";
|
||||
export const prerender = true;
|
||||
---
|
||||
|
||||
<SinglePage>
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
import { Image } from "astro:assets";
|
||||
export const prerender = true;
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
|
@ -1,24 +1,24 @@
|
||||
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(async (ctx, next) => {
|
||||
// this response might come from Astro's i18n middleware, and it might return a 404
|
||||
const response = await next();
|
||||
|
||||
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 response
|
||||
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 response;
|
||||
return next();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,15 +1,13 @@
|
||||
---
|
||||
export const prerender = true;
|
||||
import MainLayout from "../layouts/MainLayout.astro";
|
||||
import SinglePage from "../layouts/SinglePage.astro";
|
||||
---
|
||||
|
||||
<MainLayout
|
||||
title="Error 404"
|
||||
,
|
||||
description="This page doesn't exists"
|
||||
,
|
||||
lang="en"
|
||||
>
|
||||
lang="en">
|
||||
<SinglePage>
|
||||
<div class="text-2xl text-center h-[80vh] grid place-content-center">
|
||||
<p class="text-accent">It looks like this page doesn't exists!</p>
|
||||
|
Loading…
Reference in New Issue
Block a user