Skip to content

codingstark-dev/nuxt-content-example

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

28 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

A quick and easy example of the new Nuxt Content and Components library

Made with Nuxt PRs Welcome GitHub Buy Me A Coffee

Check out the live demo at nuxt-content-example.surge.sh and the tutorial here.

Relevant documentation:

๐Ÿš€ Features

  • Using Nuxt content
  • Using Nuxt components
  • Index and about pages
  • Posts page, which lists out posts
  • Separate page for each post
  • Custom components for page layouts
  • Style with normalize.css and custom styles
  • SEO with meta tags
  • Include components in markdown

๐Ÿ›  Build setup

Clone or fork this repository then download it, then run this command to start the development server:

npm run dev

Make changes in components and markdown files and see them reflected live in your website.

To generate a full static site, run

npm run generate

This will generate the static site in the dist/ directory

Pages

Any markdown file in the content/ folder directory will create a new page. For example, try creating the page privacy-policy.md with the following content:

---
title: Privacy policy
description: How our services value your privacy
---

This is the privacy policy for my company.

Save the file, and head over to localhost:3000/privacy-policy to view the page.

This page is being generated by pages/_slug.vue:

<template>
  <Default :title="doc.title">
    <!-- rendering markdown-->
    <nuxt-content :document="doc" />
  </Default>
</template>


<script>
export default {
  ...,
  async asyncData({$content, params}) {
    // getting document based on URL
    // if you're on localhost:300/abc, params.slug is "abc"
    const doc = await $content(params.slug).fetch();
    return { doc }
  }
}
</script>

View the tutorial for pages and posts here.

Hosting

Statically generate the site by running

npm run generate

This will create a dist/ folder with the site. I decided to host the site using Surge.sh. Install surge with

npm install --global surge

(Mac users may have to run sudo npm install --global surge)

To host the dist/ folder, run

surge dist

If you haven't yet created an account, the CLI will guide you through the steps. You can choose a custom *.surge.sh domain.

Check out the live demo for this site at nuxt-content-example.surge.sh.

โ™ฅ๏ธ Support

If you liked this project, consider supporting by

  • โญ๏ธ Starring the repository
  • ๐ŸŽ’ Checking out my other projects
  • โ˜•๏ธ Buying me coffee

๐Ÿ“œ License

MIT

About

๐Ÿ““ A blog example/boilerplate made with Nuxt Content

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vue 76.1%
  • JavaScript 15.4%
  • SCSS 8.5%