mm.site/src/api/Router.js

106 lines
2.6 KiB
JavaScript

// // Conditional ESM module loading (Node.js and browser)
// // @ts-ignore: Property 'UrlPattern' does not exist
if (!globalThis.URLPattern) {
await import('urlpattern-polyfill')
}
import { Router } from '@thepassle/app-tools/router.js'
import { lazy } from '@thepassle/app-tools/router/plugins/lazy.js'
import { html } from 'lit'
// home view
import '../views/home.js'
const baseURL = import.meta.env.BASE_URL
export default new Router({
fallback: '/404',
routes: [
{
path: resolveRouterPath(),
title: 'home',
short: 'home',
icon: 'home',
render: () => html`<mm-home></mm-home>`
},
{
path: resolveRouterPath('documentaries_interviews'),
title: 'Video Documentaries & Interviews',
short: 'docs & interviews',
icon: 'film',
plugins: [
lazy(() => import('../views/videos.js'))
],
render: () => html`<mm-videos></mm-videos>`
},
{
path: resolveRouterPath('audio_interviews'),
title: 'Audio Interviews',
short: 'interviews',
icon: 'headphones',
plugins: [
lazy(() => import('../views/audio.js'))
],
render: () => html`<mm-audio></mm-audio>`
},
{
path: resolveRouterPath('recordings_live'),
title: 'Recordings of Live Works',
short: 'live works',
icon: 'film',
plugins: [
lazy(() => import('../views/videos.js'))
],
render: () => html`<mm-videos></mm-videos>`
},
{
path: resolveRouterPath('music_sound'),
title: 'Music & Sound',
short: 'music & sound',
icon: 'headphones',
plugins: [
lazy(() => import('../views/audio.js'))
],
render: () => html`<mm-audio></mm-audio>`
},
{
path: resolveRouterPath('films'),
title: 'Films',
short: 'films',
icon: 'film',
plugins: [
lazy(() => import('../views/videos.js'))
],
render: () => html`<mm-videos></mm-videos>`
},
{
path: resolveRouterPath('images'),
title: 'Images',
short: 'images',
icon: 'camera',
plugins: [
lazy(() => import('../views/images.js'))
],
render: () => html`<mm-images></mm-images>`
},
{
path: '/404',
title: 'Not found',
hide: true,
plugins: [
lazy(() => import('../views/fourohfour.js'))
],
render: () => html`<mm-404></mm-404>`
}
]
})
export function resolveRouterPath(unresolvedPath) {
let resolvedPath = baseURL
if(unresolvedPath) {
resolvedPath = resolvedPath + unresolvedPath
}
return resolvedPath
}