Fix some more routing related things
This commit is contained in:
@@ -3,6 +3,7 @@ import { getAllWebpages } from "@/content/pages/pages";
|
||||
import { getAllAlbums } from "@/content/photos/albums";
|
||||
import { getAllProjects } from "@/content/projects/projects";
|
||||
import { getPhotoHash } from "./hash";
|
||||
import { getAllCategories } from "@/content/photos/categories";
|
||||
|
||||
export async function getAllRoutesList(settings: GlobalSettings): Promise<string[]> {
|
||||
let routes: string[] = [];
|
||||
@@ -28,10 +29,36 @@ export async function getAllRoutesList(settings: GlobalSettings): Promise<string
|
||||
});
|
||||
}
|
||||
if (settings.photo.enabled) {
|
||||
const categories = await getAllCategories(settings);
|
||||
const galleries = await getAllAlbums(settings);
|
||||
|
||||
categories.forEach((category) => {
|
||||
let albums = galleries.filter(g => g.category.id === category.id);
|
||||
const pages = Math.ceil(albums.length / settings.photo.category.perPage);
|
||||
const categoryRoute = getCategoryRoute(settings.photo, category);
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
if (i !== 0) {
|
||||
routes.push(`${categoryRoute}/${i + 1}`);
|
||||
}
|
||||
else {
|
||||
routes.push(`${categoryRoute}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
galleries.forEach((gallery) => {
|
||||
routes.push(getAlbumRoute(settings.photo, gallery));
|
||||
const pages = Math.ceil(gallery.photos.length / settings.photo.album.perPage);
|
||||
const galleryRoute = getAlbumRoute(settings.photo, gallery);
|
||||
|
||||
for (let i = 0; i < pages; i++) {
|
||||
if (i !== 0) {
|
||||
routes.push(`${galleryRoute}/${i + 1}`);
|
||||
}
|
||||
else {
|
||||
routes.push(`${galleryRoute}`);
|
||||
}
|
||||
}
|
||||
|
||||
gallery.photos.forEach((photo) => {
|
||||
routes.push(getPhotoRoute(settings.photo, gallery, photo));
|
||||
@@ -64,6 +91,12 @@ export function getProjectRoute(projectSettings: ProjectSettings, project: Proje
|
||||
.replace(/\/+/g, '/');
|
||||
}
|
||||
|
||||
export function getCategoryRoute(photoSettings: WebsitePhotoSettings, category: PhotoAlbumCategory) {
|
||||
return photoSettings.category.routeTemplate
|
||||
.replaceAll("%C", category.url)
|
||||
.replace(/\/+/g, '/');
|
||||
}
|
||||
|
||||
export function getAlbumRoute(photoSettings: WebsitePhotoSettings, album: PhotoAlbum) {
|
||||
const date = new Date(album.startDate);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user