Appearance
๐ 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 Type | Supported | Notes |
|---|---|---|
.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 |