Skip to content

Commit

Permalink
fix: disabled slides
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 23, 2021
1 parent 0d0c486 commit abbe368
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/client/internals/Editor.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { useEventListener, useFetch, useIntervalFn, useRafFn, useTransition } from '@vueuse/core'
import { useEventListener, useFetch } from '@vueuse/core'
import { computed, watch, ref, onMounted, onUnmounted } from 'vue'
import { useNavigateControls } from '../logic'
import { offsetRight } from '../logic/scale'
Expand All @@ -12,7 +12,7 @@ const frontmatter = ref<any>({})
const contentInput = ref<HTMLTextAreaElement>()
const controls = useNavigateControls()
const url = computed(() => `/@slidev/slide/${controls.currentPage.value}.json`)
const url = computed(() => `/@slidev/slide/${controls.currentRoute.value?.meta?.slide?.id}.json`)
const { data } = useFetch(
url,
{ refetch: true },
Expand Down
9 changes: 9 additions & 0 deletions packages/client/logic/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import { Router, RouteRecordRaw } from 'vue-router'
import { clickCurrent, clickElements } from '../modules/directives'
import { isInputing, magicKeys } from './state'

declare module 'vue-router' {
interface RouteMeta {
layout: string
slide?: {
id: number
}
}
}

export interface NavigateControls {
next: Fn
prev: Fn
Expand Down
9 changes: 7 additions & 2 deletions packages/slidev/node/plugins/slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,26 @@ export function createSlidesLoader({ entry }: ResolvedSlidevOptions): Plugin {
if (id === '/@slidev/routes') {
const imports: string[] = []

let no = 0
const routes = `export default [\n${
data.slides
.map((i, idx) => {
if (i.frontmatter?.disabled)
return ''
imports.push(`import n${idx} from '${entry}?id=${idx}.md'`)
imports.push(`import n${no} from '${entry}?id=${idx}.md'`)
const additions = {
slide: {
start: i.start,
end: i.end,
note: i.note,
file: entry,
id: idx,
no,
},
}
return `{ path: '/${idx}', name: 'page-${idx}', component: n${idx}, meta: ${JSON.stringify(Object.assign({}, i.frontmatter, additions))} },\n`
const route = `{ path: '/${no}', name: 'page-${no}', component: n${no}, meta: ${JSON.stringify(Object.assign({}, i.frontmatter, additions))} },\n`
no += 1
return route
})
.join('')
}]`
Expand Down

0 comments on commit abbe368

Please sign in to comment.