Comments (5)
useNav()
is the global navigation API, which is a singleton.
useNav().currentPage
is the page displayed in the main area, while$page.value
is the page this component is rendered on. (Refer to https://sli.dev/custom/vue-context#page)If you want to get the current layout, you can use
$nav.currentLayout.value
.
$page
and$nav
are available without importing manually. See https://sli.dev/custom/vue-context .
Thank you for the clarification. However, I'm having a few issues when trying to correct based on this information.
- I can't use
$page
and$nav
inglobal-top/bottom
in the conditional without importing fromuseSlideContext()
. I tried without and the conditional failed like before. Is there an exception for root-level files likeglobal-top/bottom
? - Even when I ignore this and use
$page
and$nav
inglobal-top/bottom
imported fromuseSlideContext()
in the conditional, the global top/bottom still did not show up on the exported slides even though they were rendered properly in browser view.
from slidev.
I can't use
$page
and$nav
inglobal-top/bottom
in the conditional without importing fromuseSlideContext()
. I tried without and the conditional failed like before. Is there an exception for root-level files likeglobal-top/bottom
?
After some debugging I found this is because there is a "useSlideContext()
" in the source code (even it's commented out), and then Slidev won't inject const { $page, ...} = useSlideContext()
automatically in this condition.
- Even when I ignore this and use
$page
and$nav
inglobal-top/bottom
imported fromuseSlideContext()
in the conditional, the global top/bottom still did not show up on the exported slides even though they were rendered properly in browser view.
This is a bug. In print mode, the global-top
is rendered before injectionCurrentPage
is provided, so the value fallbacks to the global one. I will fix this ASAP.
from slidev.
useNav()
is the global navigation API, which is a singleton.
useNav().currentPage
is the page displayed in the main area, while $page.value
is the page this component is rendered on. (Refer to https://sli.dev/custom/vue-context#page)
If you want to get the current layout, you can use $nav.currentLayout.value
.
$page
and $nav
are available without importing manually. See https://sli.dev/custom/vue-context .
from slidev.
I can't use
$page
and$nav
inglobal-top/bottom
in the conditional without importing fromuseSlideContext()
. I tried without and the conditional failed like before. Is there an exception for root-level files likeglobal-top/bottom
?After some debugging I found this is because there is a "
useSlideContext()
" in the source code (even it's commented out), and then Slidev won't injectconst { $page, ...} = useSlideContext()
automatically in this condition.
- Even when I ignore this and use
$page
and$nav
inglobal-top/bottom
imported fromuseSlideContext()
in the conditional, the global top/bottom still did not show up on the exported slides even though they were rendered properly in browser view.This is a bug. In print mode, the
global-top
is rendered beforeinjectionCurrentPage
is provided, so the value fallbacks to the global one. I will fix this ASAP.
Thank you for the very quick response! I really appreciate your help, and I'm glad to have helped identify the bugs.
from slidev.
I've opened #1492 for this. However, as antfu pointed out in #1492 (comment), #1492 is currently not mergable, and the --per-slide
flag as a workaround currently.
from slidev.
Related Issues (20)
- Unmet peer dependencies, @typescript/ata 0.9.4 x typescript@^4.4.4: found 5.4.2 HOT 4
- Ability to control scale/font size of code blocks on a global level HOT 7
- Add `startClicksCount` to frontmatter options HOT 3
- Notes not displayed in production mode
- The @click are not working
- Shiki Magic Move ignores transformers from ./setup/shiki.ts HOT 2
- Support "incremental" builds? HOT 12
- `generateError` on hot-load HOT 2
- In shiki-magic-move code block display line number HOT 1
- Keyboard shortcut to go back to previous slide or click. HOT 3
- Mix Magic Move with line highlighting has styling issue
- Presenter cursor lacks contrast on dark backgrounds (images)
- globally installed 0.48.8 seems breaking mermaid HOT 2
- Typo in documentation section "Composable Usage" (discussing `useSlideContext` and `useNav`) HOT 3
- Sli
- Dev slide
- Sli_dev HOT 1
- Embedding image(s) in a custom layout results in an unnecessary warning about the `public` folder HOT 3
- Some formatting is lost when exporting a presentation to `.pdf` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slidev.