New Website in VueJS #6

Open
alice wants to merge 11 commits from new-website into main
3 changed files with 9 additions and 60 deletions
Showing only changes of commit b011620850 - Show all commits

View file

@ -15,6 +15,7 @@ const router = createRouter({
{ path: "/", component: HomeView },
{ path: "/about", component: AboutView },
{ path: "/wiki", component: () => import("./views/WikiView.vue") },
{ path: "/wiki/:slug", component: () => import("./views/WikiView.vue") },
{ path: "/events", component: () => import("./views/EventsView.vue") },
{
path: "/events/:slug",

View file

@ -1,52 +0,0 @@
import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: "/",
name: "home",
component: HomeView,
},
{
path: "/about",
name: "about",
component: () => import("../views/AboutView.vue"),
},
{
path: "/wiki",
name: "wiki",
component: () => import("../views/WikiView.vue"),
},
{
path: "/events",
name: "events",
component: () => import("../views/EventsView.vue"),
},
{
path: "/projects",
name: "projects",
component: () => import("../views/ProjectsView.vue"),
},
{
path: "/media",
name: "media",
component: () => import("../views/MediaView.vue"),
},
{
path: "/lab",
name: "lab",
component: () => import("../views/LabView.vue"),
},
],
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition;
} else {
return { top: 0 };
}
},
});
export default router;

View file

@ -379,7 +379,7 @@ async function loadPage(slug) {
currentPage.value = normalizedSlug;
// Aggiorna URL senza ricaricare
router.push({ query: { page: normalizedSlug } });
router.push(`/wiki/${normalizedSlug}`);
try {
const possiblePaths = buildPossibleWikiPaths(normalizedSlug);
@ -480,8 +480,8 @@ onMounted(async () => {
await loadSidebar();
// Carica la pagina dall'URL o Home come default
const page = route.query.page || "home";
await loadPage(page);
const slug = route.params.slug || "home";
await loadPage(slug);
window.addEventListener("scroll", handleScroll);
window.addEventListener("resize", updateBodyScrollLock);
@ -497,11 +497,11 @@ onUnmounted(() => {
});
watch(
() => route.query.page,
async (page) => {
const normalizedPage = typeof page === "string" ? page : "home";
if (normalizedPage !== currentPage.value) {
await loadPage(normalizedPage);
() => route.params.slug,
async (slug) => {
const normalizedSlug = typeof slug === "string" ? slug : "home";
if (normalizedSlug !== currentPage.value) {
await loadPage(normalizedSlug);
}
closeMobileSidebar();
},