184 lines
5.0 KiB
Plaintext
184 lines
5.0 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 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";
|
|
|
|
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.replace(/\/$/, "");
|
|
const page = await getPage(settings, pathName);
|
|
|
|
console.log(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: {
|
|
title: page.page.searchEngine.title,
|
|
description: page.page.searchEngine.description,
|
|
allowCrawlers: page.page.searchEngine.allowCrawlers,
|
|
canonical: page.page.searchEngine.canonical,
|
|
priority: page.page.searchEngine.priority,
|
|
thumbnail: {
|
|
url: page.page.searchEngine.thumbnail.url,
|
|
width: 1200,
|
|
height: 630
|
|
}
|
|
}}}>
|
|
<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: {
|
|
title: page.page.searchEngine.title,
|
|
description: page.page.searchEngine.description,
|
|
allowCrawlers: page.page.searchEngine.allowCrawlers,
|
|
canonical: page.page.searchEngine.canonical,
|
|
priority: page.page.searchEngine.priority,
|
|
thumbnail: {
|
|
url: page.page.searchEngine.thumbnail.url,
|
|
width: 1200,
|
|
height: 630
|
|
}
|
|
},
|
|
tags: []
|
|
}}>
|
|
<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: {
|
|
title: "Projects",
|
|
description: "",
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: {
|
|
url: "",
|
|
width: 1200,
|
|
height: 630
|
|
}
|
|
},
|
|
tags: []
|
|
}}>
|
|
<Fragment slot="content">
|
|
<ProjectPost project={page.page} />
|
|
</Fragment>
|
|
</ProjectLayout>
|
|
) }
|
|
|
|
{ page.pageType === "PhotoCategoryIndex" && (
|
|
<WebpageLayout settings={{
|
|
searchEngine: {
|
|
title: "Projects",
|
|
description: "",
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: {
|
|
url: "",
|
|
width: 1200,
|
|
height: 630
|
|
}
|
|
}}}>
|
|
<Fragment slot="content">
|
|
<div>PhotoCategoryIndex</div>
|
|
</Fragment>
|
|
</WebpageLayout>
|
|
) }
|
|
|
|
{ page.pageType === "Photo" && (
|
|
<WebpageLayout settings={{
|
|
searchEngine: {
|
|
title: "Projects",
|
|
description: "",
|
|
allowCrawlers: true,
|
|
canonical: null,
|
|
priority: 65,
|
|
thumbnail: {
|
|
url: "",
|
|
width: 1200,
|
|
height: 630
|
|
}
|
|
}}}>
|
|
<Fragment slot="content">
|
|
<div>Photo</div>
|
|
</Fragment>
|
|
</WebpageLayout>
|
|
) }
|