mm.site/src/api/Router.js

144 lines
3.7 KiB
JavaScript

// Conditional ESM module loading (Node.js and browser)
// @ts-ignore: Property 'UrlPattern' does not exist
// eslint-disable-next-line no-undef
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_video'),
title: 'Video Documentaries, Interviews & Talks',
short: 'VideoDocs',
icon: 'film',
group: 'Documentaries, Interviews & Talks',
plugins: [
lazy(() => import('../views/videos.js'))
],
render: () => html`<mm-videos></mm-videos>`
},
{
path: resolveRouterPath('documentaries_interviews_audio'),
title: 'Audio Interviews',
short: 'Interviews',
icon: 'headphones',
group: 'Documentaries, Interviews & Talks',
plugins: [
lazy(() => import('../views/audio.js'))
],
render: () => html`<mm-audio></mm-audio>`
},
{
path: resolveRouterPath('music_sound_ecm'),
title: 'ECM',
short: 'ECM',
icon: 'headphones',
group: 'Music & Sound',
plugins: [
lazy(() => import('../views/audio.js'))
],
render: () => html`<mm-audio></mm-audio>`,
},
{
path: resolveRouterPath('music_sound_various'),
title: 'Recordings on Various Labels',
short: 'Various Labels',
icon: 'headphones',
group: 'Music & Sound',
plugins: [
lazy(() => import('../views/audio.js'))
],
render: () => html`<mm-audio></mm-audio>`,
},
{
path: resolveRouterPath('music_sound_unpublished'),
title: 'Unpublished Music Recordings',
short: 'Unpublished',
icon: 'headphones',
group: 'Music & Sound',
disabled: true,
plugins: [
lazy(() => import('../views/audio.js'))
],
render: () => html`<mm-audio></mm-audio>`,
},
{
path: resolveRouterPath('theatre'),
title: 'Music-Theatre Works',
short: 'Music-Theatre',
icon: 'film',
plugins: [
lazy(() => import('../views/videos.js'))
],
render: () => html`<mm-videos></mm-videos>`
},
{
path: resolveRouterPath('concerts'),
title: 'Concert Recordings',
short: 'Concerts',
icon: 'film',
plugins: [
lazy(() => import('../views/videos.js'))
],
render: () => html`<mm-videos></mm-videos>`
},
{
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: 'Scores, Posters, Ephemera',
short: 'images',
icon: 'camera',
disabled: true,
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
}