Skip to content

Commit

Permalink
fix: slide route meta (#1315)
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Feb 20, 2024
1 parent 2aba0cf commit c6e5cc0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/client/logic/nav.ts
Expand Up @@ -177,7 +177,7 @@ export async function downloadPDF() {
export async function openInEditor(url?: string) {
if (url == null) {
const slide = currentRoute.value?.meta?.slide
if (!slide?.filepath)
if (!slide)
return false
url = `${slide.filepath}:${slide.start}`
}
Expand Down
15 changes: 4 additions & 11 deletions packages/client/routes.ts
@@ -1,7 +1,7 @@
import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import type { TransitionGroupProps } from 'vue'
import type { ClicksContext } from '@slidev/types'
import type { ClicksContext, SlideInfo } from '@slidev/types'

// @ts-expect-error missing types
import _rawRoutes, { redirects } from '/@slidev/routes'
Expand Down Expand Up @@ -84,19 +84,12 @@ declare module 'vue-router' {
preload?: boolean

// slide info
slide?: {
slide?: Omit<SlideInfo, 'source'> & {
noteHTML: string
filepath: string
start: number
end: number
note?: string
noteHTML?: string
id: number
no: number
filepath: string
title?: string
level?: number
raw: string
content: string
frontmatter: Record<string, any>
}

// private fields
Expand Down
4 changes: 3 additions & 1 deletion packages/slidev/node/plugins/loaders.ts
Expand Up @@ -306,6 +306,7 @@ export function createSlidesLoader(
const slideBase = {
...renderNoteHTML(slide),
frontmatter: undefined,
source: undefined,
// remove raw content in build, optimize the bundle size
...(mode === 'build' ? { raw: '', content: '', note: '' } : {}),
}
Expand All @@ -326,7 +327,8 @@ export function createSlidesLoader(
slide: {
...(${JSON.stringify(slideBase)}),
frontmatter,
filepath: ${JSON.stringify(slide.source?.filepath || entry)},
filepath: ${JSON.stringify(slide.source.filepath)},
start: ${JSON.stringify(slide.source.start)},
id: ${pageNo},
no: ${no},
},
Expand Down

0 comments on commit c6e5cc0

Please sign in to comment.