Skip to content

๐Ÿ“ File-based Routing in WBC-Routes2 โ€‹

With WBC-Routes2, you can render static content such as .md, .pdf, .mp4, .png, etc., directly through routes. This is perfect for building documentation sites, tutorials, or demo platforms with minimal Vue code.


๐Ÿ“„ Load a Markdown File from public/ โ€‹

To load a markdown file located in the public directory (or equivalent):

js
{
  path: "/guide",
  name: "GuideRoute",
  component: WBC,
  props: {
    item: "./docs/guide.md"
  }
}

VuePress will serve this file statically, and WBC will render it as Markdown.


๐Ÿง  Use Subfolders โ€‹

You can structure files into subdirectories. WBC will resolve nested paths:

js
{
  path: "/features/bootstrap",
  name: "WBCBootstrap",
  component: WBC,
  props: {
    item: "./md/wbcBootstrapGit/wbcBootstrapGit.md"
  }
}

๐ŸŒ File Routing with Multi-language Support โ€‹

For multilingual routing based on file content:

js
{
  path: "/features/localfile",
  name: "WBCLocalFiles",
  component: WBC,
  props: {
    item: {
      en: "./md/features-en.md",
      fr: "./md/features-fr.md",
      ar: "./md/features-ar.md"
    }
  }
}

The correct file will be selected based on the app's current language context.


๐Ÿ“ธ Render Images โ€‹

You can render an image as the main content:

js
{
  path: "/image",
  name: "ImageRoute",
  component: WBC,
  props: {
    item: "./assets/logo.png"
  }
}

๐ŸŽฌ Display Videos (MP4) โ€‹

Just pass the video path, and WBC will embed a responsive <video> element:

js
{
  path: "/video",
  name: "VideoRoute",
  component: WBC,
  props: {
    item: "./media/intro.mp4"
  }
}

๐Ÿ“„ Display PDFs โ€‹

For PDFs, WBC provides a built-in PDF viewer wrapper:

js
{
  path: "/docs/whitepaper",
  name: "Whitepaper",
  component: WBC,
  props: {
    item: "./docs/whitepaper.pdf"
  }
}

WBC automatically uses <embed> or a custom viewer to display PDF content.


๐Ÿงช Example: File-based Documentation Routes โ€‹

Here's how you could structure a complete documentation set:

js
const routes = [
  {
    path: "/docs/introduction",
    name: "DocIntro",
    component: WBC,
    props: {
      item: "./md/docs/introduction.md"
    }
  },
  {
    path: "/docs/setup",
    name: "DocSetup",
    component: WBC,
    props: {
      item: "./md/docs/setup.md"
    }
  },
  {
    path: "/docs/features",
    name: "DocFeatures",
    component: WBC,
    props: {
      item: "./md/docs/features.md"
    }
  }
]

โœ… Summary โ€‹

File TypeSupportedNotes
.mdโœ…Rendered as Markdown
.pdfโœ…Embedded PDF viewer
.png/.jpg/.svgโœ…Displayed as image
.mp4โœ…Responsive video playback
.json/.htmlโœ…Rendered as text or styled