project -> blog
This commit is contained in:
parent
3f9cf6a057
commit
424a8d0837
10 changed files with 72 additions and 72 deletions
|
@ -5,21 +5,21 @@ import type {
|
|||
GalleryListDefinition,
|
||||
HeaderEntry,
|
||||
Link,
|
||||
ProjectListDefinition,
|
||||
BlogListDefinition,
|
||||
RouteDefinition,
|
||||
SiteGlobals,
|
||||
TemplateType,
|
||||
} from '@goldenwere/mackenzii-types'
|
||||
|
||||
const markdownBody = () => import ('./views/markdown/markdown.vue')
|
||||
const projectListBody = () => import ('./views/project/project-list.vue')
|
||||
const projectViewBody = () => import ('./views/project/project-view.vue')
|
||||
const blogListBody = () => import ('./views/blog/blog-list.vue')
|
||||
const blogViewBody = () => import ('./views/blog/blog-view.vue')
|
||||
const galleryListBody = () => import ('./views/gallery/gallery-list.vue')
|
||||
const galleryViewBody = () => import ('./views/gallery/gallery-view.vue')
|
||||
|
||||
export const templates: Record<TemplateType, () => Promise<any>> = {
|
||||
'markdown': markdownBody,
|
||||
'project-list': projectListBody,
|
||||
'blog-list': blogListBody,
|
||||
'gallery-list': galleryListBody,
|
||||
}
|
||||
|
||||
|
@ -33,11 +33,11 @@ export const createRoutes = (): RouteRecordRaw[] => {
|
|||
component: templates[routes[route].template],
|
||||
}
|
||||
|
||||
if (routes[route].template === 'project-list') {
|
||||
if (routes[route].template === 'blog-list') {
|
||||
routeRecord.push({
|
||||
name: `${routes[route].id}: View Project`,
|
||||
name: `${routes[route].id}: View Blog`,
|
||||
path: `${route}/view`,
|
||||
component: projectViewBody,
|
||||
component: blogViewBody,
|
||||
props: route => ({ id: route.query.id }),
|
||||
})
|
||||
} else if (routes[route].template === 'gallery-list') {
|
||||
|
@ -129,10 +129,10 @@ export const initializeRouteStore = (routerRoutes: readonly RouteRecordRaw[]) =>
|
|||
...routerRoutes.find(other => other.path === route) as RouteRecordRaw,
|
||||
...routes[route] as RouteDefinition,
|
||||
}
|
||||
if (routes[route].template === 'project-list' || routes[route].template === 'gallery-list') {
|
||||
if (routes[route].template === 'blog-list' || routes[route].template === 'gallery-list') {
|
||||
routeStore._routes[`${route}/view`] = {
|
||||
...routerRoutes.find(other => other.path === `${route}/view`) as RouteRecordRaw,
|
||||
...(routes[route] as ProjectListDefinition | GalleryListDefinition).view,
|
||||
...(routes[route] as BlogListDefinition | GalleryListDefinition).view,
|
||||
} as any
|
||||
}
|
||||
})
|
||||
|
|
|
@ -121,7 +121,7 @@ export const fetchAndParseYaml = async <T>(path: string) => {
|
|||
/**
|
||||
* Fetches, sanitizes, and parses Markdown files
|
||||
* @param path the path of the markdown document to load
|
||||
* @returns the project parsed from the markdown document
|
||||
* @returns the content parsed from the markdown document
|
||||
*/
|
||||
export const fetchAndParseMarkdown = async (path: string) => {
|
||||
const document = await fetchAndReturnText(path)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import type {
|
||||
ProjectList,
|
||||
ProjectListingInfo,
|
||||
ProjectListDefinition,
|
||||
BlogList,
|
||||
BlogEntry,
|
||||
BlogListDefinition,
|
||||
} from '@goldenwere/mackenzii-types'
|
||||
|
||||
import { fetchAndParseYaml, fetchConfig } from 'src/utilities/fetch'
|
||||
|
@ -11,27 +11,27 @@ import { getCurrentRoute } from 'src/utilities/vuetils'
|
|||
import { useRouteStore } from 'src/routes'
|
||||
|
||||
import FilterPanel from 'src/components/shared/filter-panel.vue'
|
||||
import ProjectTile from './project-tile.vue'
|
||||
import BlogTile from './blog-tile.vue'
|
||||
|
||||
/**
|
||||
* A wrapper around {@link GalleryEntries} for the app's use only which adds additional fields
|
||||
* in order for the app to effectively display the entries.
|
||||
*/
|
||||
type ProjectDisplayedEntries = { [idOrTitle: string]: ProjectListingInfo & {
|
||||
type BlogDisplayedEntries = { [idOrTitle: string]: BlogEntry & {
|
||||
/**
|
||||
* specifies whether the entry is hidden by the tags selected by a visitor
|
||||
*/
|
||||
isHidden?: boolean
|
||||
}}
|
||||
|
||||
const projectIds = ref([] as string[])
|
||||
const projects = ref({} as ProjectDisplayedEntries)
|
||||
const entryIds = ref([] as string[])
|
||||
const entries = ref({} as BlogDisplayedEntries)
|
||||
const ready = ref(false)
|
||||
const currentRoute = getCurrentRoute()
|
||||
const routeStore = useRouteStore()
|
||||
const routeConfig = routeStore._routes[currentRoute.path] as ProjectListDefinition
|
||||
const config = ref(null as ProjectList | null)
|
||||
const projectViewPath = computed(() => `${currentRoute.path}/view`)
|
||||
const routeConfig = routeStore._routes[currentRoute.path] as BlogListDefinition
|
||||
const config = ref(null as BlogList | null)
|
||||
const viewPath = computed(() => `${currentRoute.path}/view`)
|
||||
|
||||
/**
|
||||
* Handler for a tag being selected;
|
||||
|
@ -40,22 +40,22 @@ const projectViewPath = computed(() => `${currentRoute.path}/view`)
|
|||
*/
|
||||
const onToggledTagsChanged = (tagsToggled: string[]) => {
|
||||
if (tagsToggled.length < 1) {
|
||||
Object.keys(projects.value).forEach(entryId => {
|
||||
projects.value[entryId].isHidden = false
|
||||
Object.keys(entries.value).forEach(entryId => {
|
||||
entries.value[entryId].isHidden = false
|
||||
})
|
||||
} else {
|
||||
Object.keys(projects.value).forEach(entryId => {
|
||||
projects.value[entryId].isHidden = !projects.value[entryId].tags?.some(own => tagsToggled.includes(own))
|
||||
Object.keys(entries.value).forEach(entryId => {
|
||||
entries.value[entryId].isHidden = !entries.value[entryId].tags?.some(own => tagsToggled.includes(own))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
config.value = await fetchAndParseYaml<ProjectList>(routeConfig.config)
|
||||
projectIds.value = Object.keys(config.value.projects)
|
||||
for (let i = 0; i < projectIds.value.length; ++i) {
|
||||
const id = projectIds.value[i]
|
||||
projects.value[id] = await fetchConfig(config.value.projects[id])
|
||||
config.value = await fetchAndParseYaml<BlogList>(routeConfig.config)
|
||||
entryIds.value = Object.keys(config.value.entries)
|
||||
for (let i = 0; i < entryIds.value.length; ++i) {
|
||||
const id = entryIds.value[i]
|
||||
entries.value[id] = await fetchConfig(config.value.entries[id])
|
||||
}
|
||||
document.title = routeConfig.fullTitle
|
||||
ready.value = true
|
||||
|
@ -63,20 +63,20 @@ onMounted(async () => {
|
|||
</script>
|
||||
|
||||
<template lang="pug">
|
||||
.template.project-list
|
||||
.template.blog-list
|
||||
Transition
|
||||
.projects(
|
||||
.blog(
|
||||
v-if='ready'
|
||||
)
|
||||
Transition(
|
||||
v-for='id in projectIds'
|
||||
v-for='id in entryIds'
|
||||
)
|
||||
ProjectTile(
|
||||
v-if='!projects[id].isHidden || !config.removeFromView'
|
||||
v-bind='projects[id]'
|
||||
:class='{ hidden: projects[id].isHidden && !config.removeFromView }'
|
||||
BlogTile(
|
||||
v-if='!entries[id].isHidden || !config.removeFromView'
|
||||
v-bind='entries[id]'
|
||||
:class='{ hidden: entries[id].isHidden && !config.removeFromView }'
|
||||
:id='id'
|
||||
:viewPath='projectViewPath'
|
||||
:viewPath='viewPath'
|
||||
:isInternal='true'
|
||||
)
|
||||
Transition
|
|
@ -3,14 +3,14 @@ import { computed } from 'vue'
|
|||
import { marked } from 'marked'
|
||||
import { getFormattedDate } from 'src/utilities/parse'
|
||||
import type {
|
||||
ProjectListingInfo,
|
||||
BlogEntry,
|
||||
} from '@goldenwere/mackenzii-types'
|
||||
|
||||
const props = defineProps<{
|
||||
id: string,
|
||||
viewPath: string,
|
||||
isInternal: boolean,
|
||||
} & ProjectListingInfo>()
|
||||
} & BlogEntry>()
|
||||
|
||||
const { thumbnail } = props
|
||||
const description = computed(() => marked.parse(props.description || ''))
|
||||
|
@ -40,7 +40,7 @@ mixin embedText
|
|||
v-if='date'
|
||||
)
|
||||
span {{ date }}
|
||||
.project-embed
|
||||
.blog-embed
|
||||
.thumbnail-wrapper(
|
||||
v-if='!!thumbnail'
|
||||
)
|
|
@ -1,9 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import type {
|
||||
ProjectList,
|
||||
ProjectListingInfo,
|
||||
ProjectListDefinition,
|
||||
BlogList,
|
||||
BlogEntry,
|
||||
BlogListDefinition,
|
||||
RoutedWindow,
|
||||
} from '@goldenwere/mackenzii-types'
|
||||
|
||||
|
@ -20,19 +20,19 @@ const emits = defineEmits<{
|
|||
}>()
|
||||
|
||||
const ready = ref(false)
|
||||
const info = ref(null! as ProjectListingInfo)
|
||||
const info = ref(null! as BlogEntry)
|
||||
const content = ref('')
|
||||
const currentRoute = getCurrentRoute()
|
||||
const routeStore = useRouteStore()
|
||||
const routeConfig = routeStore._routes[currentRoute.path.substring(0, currentRoute.path.length - 5)] as ProjectListDefinition
|
||||
const routeConfig = routeStore._routes[currentRoute.path.substring(0, currentRoute.path.length - 5)] as BlogListDefinition
|
||||
const routeSubConfig = routeStore._routes[currentRoute.path]
|
||||
|
||||
onMounted(async () => {
|
||||
const config = await fetchAndParseYaml<ProjectList>(routeConfig.config)
|
||||
info.value = await fetchConfig(config.projects[currentRoute.query.id as string])
|
||||
const md = await fetchContent(config.projects[currentRoute.query.id as string])
|
||||
const config = await fetchAndParseYaml<BlogList>(routeConfig.config)
|
||||
info.value = await fetchConfig(config.entries[currentRoute.query.id as string])
|
||||
const md = await fetchContent(config.entries[currentRoute.query.id as string])
|
||||
content.value = md
|
||||
document.title = routeSubConfig.fullTitle?.replace('$PROJECT', info.value.title)
|
||||
document.title = routeSubConfig.fullTitle?.replace('$ENTRY', info.value.title)
|
||||
routeStore.setBreadcrumbs(currentRoute, info.value.title)
|
||||
window.routeConfig = {...routeConfig}
|
||||
window.routeSubConfig = {...routeSubConfig}
|
||||
|
@ -44,7 +44,7 @@ onMounted(async () => {
|
|||
</script>
|
||||
|
||||
<template lang="pug">
|
||||
.template.project-view
|
||||
.template.blog-view
|
||||
Transition
|
||||
article(
|
||||
v-if='ready'
|
Loading…
Add table
Add a link
Reference in a new issue