Finish first part of creating the full list of routes
This commit is contained in:
46
astro/package-lock.json
generated
46
astro/package-lock.json
generated
@@ -13,12 +13,16 @@
|
||||
"@rollup/plugin-graphql": "^2.0.5",
|
||||
"@tailwindcss/vite": "^4.2.1",
|
||||
"astro": "^5.17.1",
|
||||
"md5": "^2.3.0",
|
||||
"mdast-util-to-string": "^4.0.0",
|
||||
"minify-xml": "^4.5.2",
|
||||
"preact": "^10.28.4",
|
||||
"reading-time": "^1.5.0",
|
||||
"tailwindcss": "^4.2.1",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/md5": "^2.3.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@astrojs/compiler": {
|
||||
@@ -2728,6 +2732,13 @@
|
||||
"@types/unist": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/md5": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/md5/-/md5-2.3.6.tgz",
|
||||
"integrity": "sha512-WD69gNXtRBnpknfZcb4TRQ0XJQbUPZcai/Qdhmka3sxUR3Et8NrXoeAoknG/LghYHTf4ve795rInVYHBTQdNVA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/mdast": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz",
|
||||
@@ -3729,6 +3740,15 @@
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/charenc": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
|
||||
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/chokidar": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-5.0.0.tgz",
|
||||
@@ -3845,6 +3865,15 @@
|
||||
"uncrypto": "^0.1.3"
|
||||
}
|
||||
},
|
||||
"node_modules/crypt": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
|
||||
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/css-select": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz",
|
||||
@@ -4626,6 +4655,12 @@
|
||||
"url": "https://github.com/sponsors/brc-dd"
|
||||
}
|
||||
},
|
||||
"node_modules/is-buffer": {
|
||||
"version": "1.1.6",
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/is-docker": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
|
||||
@@ -5065,6 +5100,17 @@
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/md5": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
|
||||
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"charenc": "0.0.2",
|
||||
"crypt": "0.0.2",
|
||||
"is-buffer": "~1.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mdast-util-definitions": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-6.0.0.tgz",
|
||||
|
||||
@@ -14,11 +14,15 @@
|
||||
"@rollup/plugin-graphql": "^2.0.5",
|
||||
"@tailwindcss/vite": "^4.2.1",
|
||||
"astro": "^5.17.1",
|
||||
"md5": "^2.3.0",
|
||||
"mdast-util-to-string": "^4.0.0",
|
||||
"minify-xml": "^4.5.2",
|
||||
"preact": "^10.28.4",
|
||||
"reading-time": "^1.5.0",
|
||||
"tailwindcss": "^4.2.1",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/md5": "^2.3.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,11 @@ export async function getAllAlbums(settings: GlobalSettings): Promise<PhotoAlbum
|
||||
|
||||
albumRecord["photos"].forEach((photoRecord: any) => {
|
||||
album.photos.push({
|
||||
id: photoRecord["id"],
|
||||
photo: {
|
||||
url: photoRecord["photo"]["filename_download"],
|
||||
height: photoRecord["photo"]["filename_download"]["height"],
|
||||
width: photoRecord["photo"]["filename_download"]["width"]
|
||||
url: photoRecord["photo"]["filename_disk"],
|
||||
width: photoRecord["photo"]["width"],
|
||||
height: photoRecord["photo"]["height"]
|
||||
},
|
||||
text: photoRecord["text"]
|
||||
});
|
||||
|
||||
@@ -40,7 +40,7 @@ query getAllAlbums($date: String!) {
|
||||
photo {
|
||||
id,
|
||||
created_on,
|
||||
filename_download,
|
||||
filename_disk,
|
||||
width,
|
||||
height
|
||||
},
|
||||
|
||||
12
astro/src/lib/hash.ts
Normal file
12
astro/src/lib/hash.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import md5 from "md5";
|
||||
|
||||
export function getPhotoHash(photo: PhotoAlbumPhoto) {
|
||||
const hash = md5(JSON.stringify({
|
||||
id: photo.id,
|
||||
url: photo.photo.url,
|
||||
width: photo.photo.width,
|
||||
height: photo.photo.height
|
||||
}));
|
||||
|
||||
return hash.substring(hash.length - 10);
|
||||
}
|
||||
@@ -1,3 +1,47 @@
|
||||
import { getAllBlogs } from "@/content/blogs/blogs";
|
||||
import { getAllWebpages } from "@/content/pages/pages";
|
||||
import { getAllAlbums } from "@/content/photos/albums";
|
||||
import { getAllProjects } from "@/content/projects/projects";
|
||||
import { getPhotoHash } from "./hash";
|
||||
|
||||
export async function getAllRoutesList(settings: GlobalSettings): Promise<string[]> {
|
||||
let routes: string[] = [];
|
||||
|
||||
const webpages = await getAllWebpages();
|
||||
|
||||
webpages.forEach((webpage) => {
|
||||
routes.push(webpage.url);
|
||||
});
|
||||
|
||||
if (settings.blog.enabled) {
|
||||
const blogs = await getAllBlogs(settings);
|
||||
|
||||
blogs.forEach((blog) => {
|
||||
routes.push(getBlogRoute(settings.blog, blog));
|
||||
});
|
||||
}
|
||||
if (settings.project.enabled) {
|
||||
const projects = await getAllProjects(settings);
|
||||
|
||||
projects.forEach((project) => {
|
||||
routes.push(getProjectRoute(settings.project, project));
|
||||
});
|
||||
}
|
||||
if (settings.photo.enabled) {
|
||||
const galleries = await getAllAlbums(settings);
|
||||
|
||||
galleries.forEach((gallery) => {
|
||||
routes.push(getAlbumRoute(settings.photo, gallery));
|
||||
|
||||
gallery.photos.forEach((photo) => {
|
||||
routes.push(getPhotoRoute(settings.photo, gallery, photo));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return routes;
|
||||
}
|
||||
|
||||
export function getBlogRoute(blogSettings: BlogSettings, blog: BlogPost) {
|
||||
const date = new Date(blog.date);
|
||||
|
||||
@@ -31,3 +75,16 @@ export function getAlbumRoute(photoSettings: WebsitePhotoSettings, album: PhotoA
|
||||
.replaceAll("%R", album.url)
|
||||
.replace(/\/+/g, '/');
|
||||
}
|
||||
|
||||
export function getPhotoRoute(photoSettings: WebsitePhotoSettings, album: PhotoAlbum, photo: PhotoAlbumPhoto) {
|
||||
const date = new Date(album.startDate);
|
||||
|
||||
return photoSettings.photo.routeTemplate
|
||||
.replaceAll("%Y", date.getFullYear().toString())
|
||||
.replaceAll("%M", (date.getMonth() + 1).toString().padStart(2, '0'))
|
||||
.replaceAll("%D", date.getDate().toString().padStart(2, '0'))
|
||||
.replaceAll("%C", album.category.url)
|
||||
.replaceAll("%R", album.url)
|
||||
.replaceAll("%H", getPhotoHash(photo))
|
||||
.replace(/\/+/g, '/');
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
---
|
||||
import { getAllWebpages } from "@/content/pages/pages";
|
||||
import { getAllAlbums } from "@/content/photos/albums";
|
||||
import { getAllRoutesList } from "@/lib/routing";
|
||||
import { getSettings } from "@/content/settings/settings"
|
||||
import WebpageLayout from "@/layouts/WebpageLayout.astro";
|
||||
|
||||
const settings = await getSettings();
|
||||
const webpages = await getAllWebpages();
|
||||
const routes = await getAllRoutesList(settings);
|
||||
console.log(routes);
|
||||
---
|
||||
|
||||
<WebpageLayout>
|
||||
|
||||
1
astro/src/types/photos/album.d.ts
vendored
1
astro/src/types/photos/album.d.ts
vendored
@@ -22,6 +22,7 @@ type PhotoAlbumCategory = {
|
||||
}
|
||||
|
||||
type PhotoAlbumPhoto = {
|
||||
id: string;
|
||||
photo: PhotoProps;
|
||||
text: string | null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user