Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

sasaplus1/nuxt-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

blog module for nuxt

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published