Remove duplicate 'Alle Termine anzeigen' button from TermineVorschau
This commit is contained in:
64
.output/server/chunks/routes/api/termine.get.mjs
Normal file
64
.output/server/chunks/routes/api/termine.get.mjs
Normal file
@@ -0,0 +1,64 @@
|
||||
import { d as defineEventHandler } from '../../nitro/nitro.mjs';
|
||||
import { promises } from 'fs';
|
||||
import path from 'path';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:events';
|
||||
import 'node:buffer';
|
||||
import 'node:fs';
|
||||
import 'node:path';
|
||||
import 'node:crypto';
|
||||
import 'node:url';
|
||||
|
||||
const termine_get = defineEventHandler(async (event) => {
|
||||
try {
|
||||
const cwd = process.cwd();
|
||||
let csvPath;
|
||||
if (cwd.endsWith(".output")) {
|
||||
csvPath = path.join(cwd, "../public/data/termine.csv");
|
||||
} else {
|
||||
csvPath = path.join(cwd, "public/data/termine.csv");
|
||||
}
|
||||
const csv = await promises.readFile(csvPath, "utf-8");
|
||||
const lines = csv.split("\n").filter((line) => line.trim() !== "");
|
||||
if (lines.length < 2) {
|
||||
return { success: true, termine: [] };
|
||||
}
|
||||
const termine = [];
|
||||
for (let i = 1; i < lines.length; i++) {
|
||||
const values = [];
|
||||
let current = "";
|
||||
let inQuotes = false;
|
||||
for (let j = 0; j < lines[i].length; j++) {
|
||||
const char = lines[i][j];
|
||||
if (char === '"') {
|
||||
inQuotes = !inQuotes;
|
||||
} else if (char === "," && !inQuotes) {
|
||||
values.push(current.trim());
|
||||
current = "";
|
||||
} else {
|
||||
current += char;
|
||||
}
|
||||
}
|
||||
values.push(current.trim());
|
||||
if (values.length >= 4) {
|
||||
termine.push({
|
||||
datum: values[0],
|
||||
titel: values[1],
|
||||
beschreibung: values[2],
|
||||
kategorie: values[3]
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
termine
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden der Termine:", error);
|
||||
return { success: true, termine: [] };
|
||||
}
|
||||
});
|
||||
|
||||
export { termine_get as default };
|
||||
//# sourceMappingURL=termine.get.mjs.map
|
||||
Reference in New Issue
Block a user