GithubHelp home page GithubHelp logo

Comments (5)

hannoeru avatar hannoeru commented on September 14, 2024 3

With vite-plugin-md v0.5.0, now you can write route custom block inside markdown file!!

markdown:

# Hello World

<route lang="yaml">
meta:
  layout: home
</route>

from vitesse.

hannoeru avatar hannoeru commented on September 14, 2024 1

You can't just write custom block to markdown file because it will transform into <template>/* here */</template>,
there is a option in vite-plugin-pages call extendRoute, which can add some custom meta using:

// vite.config.js plugin
Pages({
  extendRoute: (route) => {
    if (route.component.endsWith('pages/test.md')) {
      route.meta.layout = 'home'
    }
  }
})

from vitesse.

Ynewtime avatar Ynewtime commented on September 14, 2024

@hannoeru Yah I got it, thanks. So is there another way to specify custom layout directly inside of a markdown file? I tried YAML meta head just like how jekyll does, and it doesn't work as expected. Maybe I should check out the markdown plugin source code.

from vitesse.

JohnCampionJr avatar JohnCampionJr commented on September 14, 2024

Would it be a big change for the vite-markdown plugin to strip out the route block?

from vitesse.

Hebilicious avatar Hebilicious commented on September 14, 2024

I had to slightly modify @hannoeru snippet to get things working, hopefully this helps someone else :

//vite.config.ts
        Pages({
            extensions: ['vue', 'md'],
            extendRoute: (route) => {
                if (/.*\/mydirname\/.*\.md/.test(route.component)) {
                    route.meta = { layout: 'mylayout' }
                }
            },
        }),

from vitesse.

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.