New Website in VueJS #6
3 changed files with 9 additions and 60 deletions
|
|
@ -15,6 +15,7 @@ const router = createRouter({
|
||||||
{ path: "/", component: HomeView },
|
{ path: "/", component: HomeView },
|
||||||
{ path: "/about", component: AboutView },
|
{ path: "/about", component: AboutView },
|
||||||
{ path: "/wiki", component: () => import("./views/WikiView.vue") },
|
{ path: "/wiki", component: () => import("./views/WikiView.vue") },
|
||||||
|
{ path: "/wiki/:slug", component: () => import("./views/WikiView.vue") },
|
||||||
{ path: "/events", component: () => import("./views/EventsView.vue") },
|
{ path: "/events", component: () => import("./views/EventsView.vue") },
|
||||||
{
|
{
|
||||||
path: "/events/:slug",
|
path: "/events/:slug",
|
||||||
|
|
|
||||||
|
|
@ -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;
|
|
||||||
|
|
@ -379,7 +379,7 @@ async function loadPage(slug) {
|
||||||
currentPage.value = normalizedSlug;
|
currentPage.value = normalizedSlug;
|
||||||
|
|
||||||
// Aggiorna URL senza ricaricare
|
// Aggiorna URL senza ricaricare
|
||||||
router.push({ query: { page: normalizedSlug } });
|
router.push(`/wiki/${normalizedSlug}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const possiblePaths = buildPossibleWikiPaths(normalizedSlug);
|
const possiblePaths = buildPossibleWikiPaths(normalizedSlug);
|
||||||
|
|
@ -480,8 +480,8 @@ onMounted(async () => {
|
||||||
await loadSidebar();
|
await loadSidebar();
|
||||||
|
|
||||||
// Carica la pagina dall'URL o Home come default
|
// Carica la pagina dall'URL o Home come default
|
||||||
const page = route.query.page || "home";
|
const slug = route.params.slug || "home";
|
||||||
await loadPage(page);
|
await loadPage(slug);
|
||||||
|
|
||||||
window.addEventListener("scroll", handleScroll);
|
window.addEventListener("scroll", handleScroll);
|
||||||
window.addEventListener("resize", updateBodyScrollLock);
|
window.addEventListener("resize", updateBodyScrollLock);
|
||||||
|
|
@ -497,11 +497,11 @@ onUnmounted(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route.query.page,
|
() => route.params.slug,
|
||||||
async (page) => {
|
async (slug) => {
|
||||||
const normalizedPage = typeof page === "string" ? page : "home";
|
const normalizedSlug = typeof slug === "string" ? slug : "home";
|
||||||
if (normalizedPage !== currentPage.value) {
|
if (normalizedSlug !== currentPage.value) {
|
||||||
await loadPage(normalizedPage);
|
await loadPage(normalizedSlug);
|
||||||
}
|
}
|
||||||
closeMobileSidebar();
|
closeMobileSidebar();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue