Skip to content

How to define a button automatically appears on every slide #471

Answered by yhatt
ChiMaoShuPhy asked this question in Q&A
Discussion options

You must be logged in to vote

You can write a plugin for Marp CLI's bespoke template, to add controller buttons to each slide:

// controllerPlugin.mjs
const controllerHtml = (previousPage, nextPage) => `
  <div>
    <button type="button" ${previousPage === null ? 'disabled' : `onClick="location.hash='${previousPage}'"`}>Prev</Button>
    <button type="button" ${nextPage === null ? 'disabled' : `onClick="location.hash='${nextPage}'"`}>Next</Button>
  </div>
`

const marpCliBespokeControllerPlugin = (md) => {
  const originalRenderer = md.renderer.rules.marpit_slide_close;

  md.renderer.rules.marpit_slide_close = function (tokens, i, options, env, self) {
    const originalResult = originalRenderer(tokens, i, options, env

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ChiMaoShuPhy
Comment options

Answer selected by ChiMaoShuPhy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants