newjs-md
A lightweight tool to convert Markdown and JSON files into Vue Single File Components (SFC).
Installation
Install newjs-md globally:
npm install -g newjs-md
Alternatively, you can use it locally via npx:
npx newjs-md
Usage
Initialize a new project
# Global usage:
newjs-md init
# Local usage:
npx newjs-md init
Convert a single file
# Global usage:
newjs-md template.md
# Local usage:
npx newjs-md template.md
Watch mode
# Global usage:
newjs-md watch
# Local usage:
npx newjs-md watch
Get Help
# Global usage:
newjs-md help
# Local usage:
npx newjs-md help
File Structure
your-project/
├── templates/ # Your markdown/JSON templates
├── pages/ # Generated Vue components
└── src/
└── components/ # Your Vue components
Template Format
Markdown
@TitleBar
# My Page Title
Content goes here...
JSON
{
"component": "PageLayout",
"content": "My page content"
}
Configuration
Create newjsTemplate.config.json
in your project root:
{
"templatesDir": "./templates",
"pagesDir": "./pages",
"componentPaths": ["./src/components"]
}
Integration with Vite
To integrate with Vite, update your package.json scripts. For example, using npm-run-all:
{
"scripts": {
"dev": "run-p dev:vite dev:watch",
"dev:vite": "vite",
"dev:watch": "newjs-md watch",
"build": "vite build",
"preview": "vite preview"
}
}
This configuration will run both Vite’s dev server and newjs-md’s watch mode concurrently.
License
MIT