Not allowed to actually do it
This commit is contained in:
1
package-lock.json
generated
1
package-lock.json
generated
@@ -18,6 +18,7 @@
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-svelte": "^3.14.0",
|
||||
"globals": "^17.1.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"prettier": "^3.8.1",
|
||||
"prettier-plugin-svelte": "^3.4.1",
|
||||
"svelte": "^5.48.2",
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-svelte": "^3.14.0",
|
||||
"globals": "^17.1.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"prettier": "^3.8.1",
|
||||
"prettier-plugin-svelte": "^3.4.1",
|
||||
"svelte": "^5.48.2",
|
||||
|
||||
16
scripts/parse-maps.js
Normal file
16
scripts/parse-maps.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import yaml from 'js-yaml';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const inputDir = '../static/mapFiles/yaml';
|
||||
const outputDir = '../static/mapFiles/json';
|
||||
|
||||
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, {recursive: true});
|
||||
|
||||
fs.readdirSync(inputDir).forEach(file => {
|
||||
if (file.endsWith('.yaml')) {
|
||||
const content = yaml.load(fs.readFileSync(path.join(inputDir, file), 'utf8'));
|
||||
const fileName = file.replace('.yaml', '.json');
|
||||
fs.writeFileSync(path.join(outputDir, fileName), JSON.stringify(content));
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
<script lang="ts">
|
||||
import RouteRow from "$lib/components/RouteRow.svelte";
|
||||
|
||||
export let data;
|
||||
|
||||
let reversed = false;
|
||||
|
||||
$: proceccedFeatures = (() => {
|
||||
const list = reversed ? [...data.route].reverse() : [...data.route];
|
||||
})
|
||||
</script>
|
||||
29
src/routes/map/[slug]/+page.ts
Normal file
29
src/routes/map/[slug]/+page.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { PageLoad } from '/$types';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: PageLoad = async ({ params, fetch }) => {
|
||||
const { slug } = params;
|
||||
|
||||
try {
|
||||
const res = await fetch(`/mapFiles/json/${slug}.json`);
|
||||
|
||||
if (!res.ok) {
|
||||
throw error(404, {
|
||||
message: `Route ${slug} not found`
|
||||
});
|
||||
}
|
||||
|
||||
const rawData = await res.json();
|
||||
|
||||
return {
|
||||
route: rawData,
|
||||
slug: slug,
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(`Error loading map ${slug}: `, err);
|
||||
|
||||
throw error(500, {
|
||||
message: `Failed to parse map data for ${slug}`
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user