166 lines
4.9 KiB
Plaintext
166 lines
4.9 KiB
Plaintext
---
|
|
import { getAllRoutesList } from "@/lib/routing";
|
|
import { getPage } from "@/lib/pages";
|
|
import { getSettings } from "@/content/settings/settings"
|
|
import WebpageLayout from "@/layouts/WebpageLayout.astro";
|
|
import BlogLayout from "@/layouts/BlogLayout.astro";
|
|
import ProjectLayout from "@/layouts/ProjectLayout.astro";
|
|
import PhotoLayout from '@/layouts/PhotoLayout.astro';
|
|
import BlogIndex from "@/components/blogs/BlogIndex.astro";
|
|
import ProjectIndex from "@/components/projects/ProjectIndex.astro";
|
|
import Webpage from "@/components/webpage/Webpage.astro";
|
|
import BlogPost from "@/components/blogs/BlogPost.astro";
|
|
import ProjectPost from "@/components/projects/ProjectPost.astro";
|
|
import CategoryIndex from "@/components/photos/CategoryIndex.astro";
|
|
import Category from "@/components/photos/Category.astro";
|
|
import { getImageUrl } from "@/lib/images";
|
|
|
|
export async function getStaticPaths() {
|
|
const settings = await getSettings();
|
|
const pages = await getAllRoutesList(settings);
|
|
|
|
let routes: any[] = [];
|
|
|
|
pages.forEach((page) => {
|
|
routes.push({ params: { route: page } });
|
|
});
|
|
|
|
return routes;
|
|
}
|
|
|
|
const settings = await getSettings();
|
|
const pathName = Astro.url.pathname === "/" ? "/" : Astro.url.pathname.replace(/\/$/, "");
|
|
const page = await getPage(settings, pathName);
|
|
|
|
if (page === null || page.page === null || !page.page.exists) {
|
|
return new Response("Page not found.", {
|
|
status: 404,
|
|
statusText: "Not Found"
|
|
});
|
|
}
|
|
---
|
|
|
|
{ page.page.type === "Webpage" && page.page.exists && (
|
|
<WebpageLayout settings={{
|
|
searchEngine: page.page.searchEngine
|
|
}}>
|
|
<Fragment slot="content">
|
|
<Webpage webpage={page.page.components} />
|
|
</Fragment>
|
|
</WebpageLayout>
|
|
) }
|
|
|
|
{ page.page.type === "BlogIndex" && (
|
|
<WebpageLayout settings={{
|
|
searchEngine: {
|
|
title: "Blogs",
|
|
description: "",
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: {
|
|
url: "",
|
|
width: 1200,
|
|
height: 630
|
|
}
|
|
}}}>
|
|
<Fragment slot="content">
|
|
<BlogIndex page={page.page} />
|
|
</Fragment>
|
|
</WebpageLayout>
|
|
) }
|
|
|
|
{ page.page.type === "BlogPost" && (
|
|
<BlogLayout settings={{
|
|
searchEngine: page.page.searchEngine,
|
|
tags: page.page.tags.map((tag) => tag.text)
|
|
}}>
|
|
<Fragment slot="content">
|
|
<BlogPost blog={page.page} />
|
|
</Fragment>
|
|
</BlogLayout>
|
|
) }
|
|
|
|
{ page.page.type === "ProjectIndex" && (
|
|
<WebpageLayout settings={{
|
|
searchEngine: {
|
|
title: "Projects",
|
|
description: "",
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: {
|
|
url: "",
|
|
width: 1200,
|
|
height: 630
|
|
}
|
|
}}}>
|
|
<Fragment slot="content">
|
|
<ProjectIndex page={page.page} />
|
|
</Fragment>
|
|
</WebpageLayout>
|
|
) }
|
|
|
|
{ page.page.type === "ProjectPost" && (
|
|
<ProjectLayout settings={{
|
|
searchEngine: page.page.searchEngine,
|
|
tags: page.page.tags.map((tag) => tag.text)
|
|
}}>
|
|
<Fragment slot="content">
|
|
<ProjectPost project={page.page} />
|
|
</Fragment>
|
|
</ProjectLayout>
|
|
) }
|
|
|
|
{ page.pageType === "PhotoCategoryIndex" && (
|
|
<WebpageLayout settings={{
|
|
searchEngine: {
|
|
title: "Categories",
|
|
description: "See the photo categories on this page, where you can see the different types of photography I do.",
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: page.page.category.thumbnail
|
|
}}}>
|
|
<Fragment slot="content">
|
|
<CategoryIndex />
|
|
</Fragment>
|
|
</WebpageLayout>
|
|
) }
|
|
|
|
{ page.pageType === "PhotoCategory" && (
|
|
<WebpageLayout settings={{
|
|
searchEngine: {
|
|
title: page.page.category.title,
|
|
description: `See the photos in the ${page.page.category.title.toLowerCase()} category.`,
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: page.page.category.thumbnail
|
|
}}}>
|
|
<Fragment slot="content">
|
|
<Category category={page.page} />
|
|
</Fragment>
|
|
</WebpageLayout>
|
|
) }
|
|
|
|
{ page.pageType === "Photo" && (
|
|
<PhotoLayout settings={{
|
|
searchEngine: {
|
|
title: page.page.album.title,
|
|
description: `See this photo from the album ${page.page.album.title}`,
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: {
|
|
url: getImageUrl(page.page.photo.url),
|
|
width: page.page.photo.width,
|
|
height: page.page.photo.height
|
|
}
|
|
}}}>
|
|
<Fragment slot="content">
|
|
<div>{JSON.stringify(page.page)}</div>
|
|
</Fragment>
|
|
</PhotoLayout>
|
|
) }
|