Skip to content

Commit

Permalink
feat: new render context none for out side of slides
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 21, 2024
1 parent 061a29f commit 10eb167
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/client/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, shallowRef, toRef } from 'vue'
import { shallowRef, toRef } from 'vue'
import { injectLocal, objectOmit, provideLocal } from '@vueuse/core'
import { useFixedClicks } from './composables/useClicks'
import {
Expand All @@ -23,7 +23,7 @@ export function useSlideContext() {
const $clicksContext = injectLocal(injectionClicksContext, clicksContextFallback)!.value
const $clicks = toRef($clicksContext, 'current')
const $page = injectLocal(injectionCurrentPage)!
const $renderContext = injectLocal(injectionRenderContext, ref('slide'))
const $renderContext = injectLocal(injectionRenderContext)!
const $frontmatter = injectLocal(injectionFrontmatter, {})
const $route = injectLocal(injectionRoute, undefined)

Expand Down
5 changes: 3 additions & 2 deletions packages/client/modules/context.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { App } from 'vue'
import { computed, reactive } from 'vue'
import { computed, reactive, ref } from 'vue'
import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
import type { ComputedRef } from '@vue/reactivity'
import type { configs } from '../env'
import * as nav from '../logic/nav'
import { route } from '../logic/nav'
import { isDark } from '../logic/dark'
import { injectionCurrentPage, injectionSlidevContext } from '../constants'
import { injectionCurrentPage, injectionRenderContext, injectionSlidevContext } from '../constants'
import { useContext } from '../composables/useContext'

export type SlidevContextNavKey = 'path' | 'total' | 'clicksContext' | 'clicks' | 'clicksTotal' | 'currentPage' | 'currentPath' | 'currentRoute' | 'currentSlideId' | 'currentLayout' | 'nextRoute' | 'rawTree' | 'treeWithActiveStatuses' | 'tree' | 'downloadPDF' | 'next' | 'nextSlide' | 'openInEditor' | 'prev' | 'prevSlide' | 'rawRoutes' | 'go'
Expand All @@ -25,6 +25,7 @@ export default function createSlidevContext() {
return {
install(app: App) {
const context = reactive(useContext(route))
app.provide(injectionRenderContext, ref('none'))
app.provide(injectionSlidevContext, context)
app.provide(injectionCurrentPage, computed(() => context.nav.currentPage))

Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface SlidevPreparserExtension {

export type PreparserExtensionLoader = (headmatter?: Record<string, unknown>, filepath?: string) => Promise<SlidevPreparserExtension[]>

export type RenderContext = 'slide' | 'overview' | 'presenter' | 'previewNext'
export type RenderContext = 'none' | 'slide' | 'overview' | 'presenter' | 'previewNext'

export type LoadedSnippets = Record<string, string>

Expand Down

0 comments on commit 10eb167

Please sign in to comment.