GithubHelp home page GithubHelp logo

Slide export doesn't handle `v-if` in `global-top` or `global-bottom` based on conditional using `currentPage`, `currentLayout` about slidev HOT 5 OPEN

ani-per avatar ani-per commented on May 29, 2024
Slide export doesn't handle `v-if` in `global-top` or `global-bottom` based on conditional using `currentPage`, `currentLayout`

from slidev.

Comments (5)

ani-per avatar ani-per commented on May 29, 2024 1

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 in global-top/bottom in the conditional without importing from useSlideContext(). I tried without and the conditional failed like before. Is there an exception for root-level files like global-top/bottom?
  • Even when I ignore this and use $page and $nav in global-top/bottom imported from useSlideContext() 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.

KermanX avatar KermanX commented on May 29, 2024 1

I can't use $page and $nav in global-top/bottom in the conditional without importing from useSlideContext(). I tried without and the conditional failed like before. Is there an exception for root-level files like global-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 in global-top/bottom imported from useSlideContext() 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.

KermanX avatar KermanX commented on May 29, 2024

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.

ani-per avatar ani-per commented on May 29, 2024

I can't use $page and $nav in global-top/bottom in the conditional without importing from useSlideContext(). I tried without and the conditional failed like before. Is there an exception for root-level files like global-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 in global-top/bottom imported from useSlideContext() 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.

Thank you for the very quick response! I really appreciate your help, and I'm glad to have helped identify the bugs.

from slidev.

KermanX avatar KermanX commented on May 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.