blog module for nuxt
$ npm install nuxt-blog
if you don't want to install optional modules, execute below:
$ npm install --no-optional nuxt-blog
const path = require('path');
module.exports = {
modules: [
[
'nuxt-blog', {
dirname: path.join(__dirname, 'posts'),
},
],
],
};
<template>
<div>
<h1>{{ title }}</h1>
<div>{{ body }}</div>
</div>
</template>
<script>
import axios from 'axios';
export default {
async asyncData(context) {
const {
route,
} = context;
return JSON.parse(
await axios.get(`http://localhost:3000/api/${route.fullPath}`)
);
},
}
</script>
how to set options:
module.exports = {
modules: [
[
'nuxt-blog', {
// nuxt-blog options...
},
],
],
};
or
module.exports = {
modules: [
'nuxt-blog',
],
blog: {
// nuxt-blog options...
},
};
more details: Modules
required option
type: string
post's directory path.
type: Object
default: syntax highlight with highlight.js
options for markdown-it.
if markdown.parser
is set, this option is ignore.
default value can get from require('nuxt-blog').getDefaultMarkdownOptions()
.
{
markdown: {
options: {
linkify: true,
typographer: true,
},
},
}
type: Function
default: commonmark mode's markdown-it with highlight.js
Markdown parser function.
this option is higher priority than markdown.options
.
if it is set, markdown.options
not pass to Markdown parser.
default value can get from require('nuxt-blog').getDefaultMarkdownParser()
.
if you want to use marked:
{
markdown: {
parser: require('marked'),
},
}
type: string
default: /api
API URL prefix.
nuxt-blog uses debug in internal.
output debug info, set nuxt:blog
and/or nuxt:blog:utils
to DEBUG
environment variable.
$ DEBUG=nuxt:blog,nuxt:blog:utils ./node_modules/.bin/nuxt start
The MIT license.