This package has been deprecated

Author message:

unmaintained

nuxt-blog

1.0.0 • Public • Published

nuxt-blog

Build Status Dependency Status NPM version Try nuxt-blog on RunKit

blog module for nuxt

Installation

$ npm install nuxt-blog

if you don't want to install optional modules, execute below:

$ npm install --no-optional nuxt-blog

Setup

nuxt.config.js

const path = require('path');
 
module.exports = {
  modules: [
    [
      'nuxt-blog', {
        dirname: path.join(__dirname, 'posts'),
      },
    ],
  ],
};

pages/_yyyy/_mm/_dd/_no.vue

<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> 

Options

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

dirname

required option

type: string

post's directory path.

markdown.options

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().

example

{
  markdown: {
    options: {
      linkify: true,
      typographer: true,
    },
  },
}

markdown.parser

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().

example

if you want to use marked:

{
  markdown: {
    parser: require('marked'),
  },
}

prefix

type: string

default: /api

API URL prefix.

Debug

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

License

The MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i nuxt-blog

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

10.2 kB

Total Files

6

Last publish

Collaborators

  • sasaplus1