add static site generation including robots.txt and sitemap.xml

This commit is contained in:
survellow
2024-07-03 17:33:12 +02:00
parent a003ba736c
commit cf638cf93c
31 changed files with 846 additions and 923 deletions

View File

@@ -17,6 +17,9 @@
import { Module } from "../model/module.ts";
export async function createIndividualFeed(modules: Module[]): Promise<string> {
if (import.meta.env.SSR) {
return "";
}
try {
const response = await fetch("/api/feed", {
method: "POST",
@@ -62,6 +65,9 @@ export async function saveIndividualFeed(
token: string,
modules: Module[],
): Promise<string> {
if (import.meta.env.SSR) {
return "";
}
await fetch("/api/collections/feeds/records/" + token, {
method: "PATCH",
headers: {
@@ -81,6 +87,9 @@ export async function saveIndividualFeed(
}
export async function deleteIndividualFeed(token: string): Promise<void> {
if (import.meta.env.SSR) {
return;
}
await fetch("/api/feed?token=" + token, {
method: "DELETE",
})

View File

@@ -19,6 +19,9 @@
import { Module } from "../model/module.ts";
export async function fetchCourse(): Promise<string[]> {
if (import.meta.env.SSR) {
return [];
}
const courses: string[] = [];
await fetch("/api/courses")
.then((response) => {
@@ -39,6 +42,9 @@ export async function fetchCourse(): Promise<string[]> {
export async function fetchCourseBySemester(
semester: string,
): Promise<string[]> {
if (import.meta.env.SSR) {
return [];
}
const courses: string[] = [];
await fetch("/api/courses/events?semester=" + semester)
.then((response) => {
@@ -60,6 +66,9 @@ export async function fetchModulesByCourseAndSemester(
course: string,
semester: string,
): Promise<Module[]> {
if (import.meta.env.SSR) {
return [];
}
const modules: Module[] = [];
await fetch("/api/course/modules?course=" + course + "&semester=" + semester)
.then((response) => {
@@ -86,6 +95,9 @@ export async function fetchModulesByCourseAndSemester(
}
export async function fetchAllModules(): Promise<Module[]> {
if (import.meta.env.SSR) {
return [];
}
const modules: Module[] = [];
await fetch("/api/modules")
.then((response) => {

View File

@@ -17,6 +17,9 @@
// function to fetch course data from the API
export async function fetchEventTypes(): Promise<string[]> {
if (import.meta.env.SSR) {
return [];
}
const eventTypes: string[] = [];
await fetch("/api/events/types")
.then((response) => {
@@ -30,4 +33,4 @@ export async function fetchEventTypes(): Promise<string[]> {
});
});
return eventTypes;
}
}

View File

@@ -17,6 +17,9 @@
import { Module } from "../model/module";
export async function fetchModule(module: Module): Promise<Module> {
if (import.meta.env.SSR) {
return new Module("", "", "", "", "", "", "", false, []);
}
// request to the data-manager on /api/module with query parameters name as the module name
const request = new Request("/api/module?uuid=" + module.uuid);

View File

@@ -17,6 +17,9 @@
import { AnonymizedEventDTO } from "../model/event.ts";
export async function fetchRoom(): Promise<string[]> {
if (import.meta.env.SSR) {
return [];
}
const rooms: string[] = [];
await fetch("/api/rooms")
.then((response) => {
@@ -33,6 +36,9 @@ export async function fetchEventsByRoomAndDuration(
from_date: string,
to_date: string,
): Promise<AnonymizedEventDTO[]> {
if (import.meta.env.SSR) {
return [];
}
const events: AnonymizedEventDTO[] = [];
await fetch(
"/api/schedule?room=" + room + "&from=" + from_date + "&to=" + to_date,

View File

@@ -18,6 +18,9 @@ import { Module } from "../model/module";
import { Calendar } from "../model/calendar";
export async function getCalender(token: string): Promise<Module[]> {
if (import.meta.env.SSR) {
return [];
}
const request = new Request("/api/collections/feeds/records/" + token, {
method: "GET",
});

View File

@@ -19,6 +19,9 @@ export async function requestFreeRooms(
from: string,
to: string,
): Promise<string[]> {
if (import.meta.env.SSR) {
return [];
}
const rooms: string[] = [];
await fetch("/api/rooms/free?from=" + from + "&to=" + to)
.then((response) => {