Skip to content

Commit

Permalink
feat: support $clicks context shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Aug 31, 2023
1 parent be72de4 commit bf9e5b5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/slidev/node/plugins/loaders.ts
Expand Up @@ -345,11 +345,13 @@ ${title}

delete frontmatter.title
const imports = [
'import { inject as vueInject } from "vue"',
'import { inject as _vueInject, toRef as _vueToRef } from "vue"',
`import InjectedLayout from "${toAtFS(layouts[layoutName])}"`,
'import { injectionSlidevContext } from "@slidev/client/constants.ts"',
`const frontmatter = ${JSON.stringify(frontmatter)}`,
'const $slidev = vueInject(injectionSlidevContext)',
'const $frontmatter = frontmatter',
'const $slidev = _vueInject(injectionSlidevContext)',
'const $clicks = _vueToRef($slidev.nav, "clicks")',
]

code = code.replace(/(<script setup.*>)/g, `$1\n${imports.join('\n')}\n`)
Expand Down

0 comments on commit bf9e5b5

Please sign in to comment.