├── .gitignore
├── components
├── README.md
├── Posts.vue
└── AppLogo.vue
├── layouts
├── README.md
└── default.vue
├── pages
├── README.md
├── index.vue
├── about.vue
└── post
│ └── _id
│ └── index.vue
├── .eslintrc.js
├── package.json
├── nuxt.config.js
├── README.md
└── posts.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 |
4 | # logs
5 | npm-debug.log
6 |
7 | # Nuxt build
8 | .nuxt
9 |
10 | # Nuxt generate
11 | dist
12 |
--------------------------------------------------------------------------------
/components/README.md:
--------------------------------------------------------------------------------
1 | # COMPONENTS
2 |
3 | The components directory contains your Vue.js Components.
4 | Nuxt.js doesn't supercharge these components.
5 |
6 | **This directory is not required, you can delete it if you don't want to use it.**
7 |
8 |
--------------------------------------------------------------------------------
/layouts/README.md:
--------------------------------------------------------------------------------
1 | # LAYOUTS
2 |
3 | This directory contains your Application Layouts.
4 |
5 | More information about the usage of this directory in the documentation:
6 | https://nuxtjs.org/guide/views#layouts
7 |
8 | **This directory is not required, you can delete it if you don't want to use it.**
9 |
10 |
--------------------------------------------------------------------------------
/pages/README.md:
--------------------------------------------------------------------------------
1 | # PAGES
2 |
3 | This directory contains your Application Views and Routes.
4 | The framework reads all the .vue files inside this directory and creates the router of your application.
5 |
6 | More information about the usage of this directory in the documentation:
7 | https://nuxtjs.org/guide/routing
8 |
9 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | browser: true,
5 | node: true
6 | },
7 | parserOptions: {
8 | parser: 'babel-eslint'
9 | },
10 | extends: [
11 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
12 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
13 | 'plugin:vue/essential'
14 | ],
15 | // required to lint *.vue files
16 | plugins: [
17 | 'vue'
18 | ],
19 | // add your custom rules here
20 | rules: {}
21 | }
22 |
--------------------------------------------------------------------------------
/pages/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Welcome to the JavaScript SSR Blog.
8 |
9 |
10 | Hope you find something you like.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
32 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ssr-blog",
3 | "version": "1.0.0",
4 | "description": "Nuxt.js project",
5 | "author": "James Hibbard <1940994+jameshibbard@users.noreply.github.com>",
6 | "private": true,
7 | "scripts": {
8 | "dev": "nuxt",
9 | "build": "nuxt build",
10 | "start": "nuxt start",
11 | "generate": "nuxt generate",
12 | "lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
13 | "precommit": "npm run lint"
14 | },
15 | "dependencies": {
16 | "nuxt": "^2.0.0"
17 | },
18 | "devDependencies": {
19 | "babel-eslint": "^10.0.1",
20 | "eslint": "^4.19.1",
21 | "eslint-friendly-formatter": "^4.0.1",
22 | "eslint-loader": "^2.1.1",
23 | "eslint-plugin-vue": "^4.0.0"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/layouts/default.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Awesome JS SSR Blog!
9 |
10 | Home
11 | About
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
27 |
28 |
--------------------------------------------------------------------------------
/pages/about.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
About this website.
5 |
Curabitur accumsan turpis pharetra augue tincidunt blandit. Quisque condimentum maximus mi, sit amet commodo arcu rutrum id. Proin pretium urna vel cursus venenatis. Suspendisse potenti. Etiam mattis sem rhoncus lacus dapibus facilisis. Donec at dignissim dui. Ut et neque nisl.
6 |
7 |
What we hope to achieve:
8 |
9 | In fermentum leo eu lectus mollis, quis dictum mi aliquet.
10 | Morbi eu nulla lobortis, lobortis est in, fringilla felis.
11 | Aliquam nec felis in sapien venenatis viverra fermentum nec lectus.
12 | Ut non enim metus.
13 |
14 |
15 |
16 |
17 |
18 |
25 |
--------------------------------------------------------------------------------
/pages/post/_id/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
{{ post.title }}
5 |
6 |
7 |
by {{ post.author }} at {{ post.published }}
8 |
9 |
10 |
11 |
12 |
42 |
--------------------------------------------------------------------------------
/components/Posts.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Recent Posts.
6 |
7 |
8 |
9 |
10 |
15 |
16 |
17 | {{ post.summary }}
18 |
19 |
20 | by {{ post.author}}
21 | \\ {{ post.published }}
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
48 |
--------------------------------------------------------------------------------
/nuxt.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | /*
3 | ** Headers of the page
4 | */
5 | head: {
6 | title: 'ssr-blog',
7 | titleTemplate: '%s | Awesome JS SSR Blog',
8 | meta: [
9 | { charset: 'utf-8' },
10 | { name: 'viewport', content: 'width=device-width, initial-scale=1' },
11 | { hid: 'description', name: 'description', content: 'Nuxt.js project' }
12 | ],
13 | link: [
14 | { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
15 | {
16 | rel: 'stylesheet',
17 | href: 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css'
18 | }
19 | ]
20 | },
21 | /*
22 | ** Customize the progress bar color
23 | */
24 | loading: { color: '#3B8070' },
25 | /*
26 | ** Build configuration
27 | */
28 | build: {
29 | /*
30 | ** Run ESLint on save
31 | */
32 | extend (config, { isDev, isClient }) {
33 | if (isDev && isClient) {
34 | config.module.rules.push({
35 | enforce: 'pre',
36 | test: /\.(js|vue)$/,
37 | loader: 'eslint-loader',
38 | exclude: /(node_modules)/
39 | })
40 | }
41 | }
42 | },
43 | generate: {
44 | routes(callback) {
45 | const posts = require('./posts.json')
46 | let routes = posts.map(post => `/post/${post.id}`)
47 | callback(null, routes)
48 | }
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/components/AppLogo.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
80 |
81 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Nuxt.js: A Universal Vue.js Application Framework
2 |
3 | Improve the loading performance and SEO of your Vue.js apps with Server-side rendering (SSR). Learn to build a universal Vue app with the Nuxt.js framework.
4 |
5 | Article on SitePoint: https://www.sitepoint.com/nuxt-js-universal-vue-js/
6 |
7 | You can see the demo app here: https://nuxt-ssr-blog.firebaseapp.com/
8 |
9 | ## Requirements
10 |
11 | * [Node.js](http://nodejs.org/)
12 |
13 | ## Installation Steps (if applicable)
14 |
15 | 1. Clone repo
16 | 2. Run `npm install`
17 | 3. Run `npm run dev` to serve with hot reload at http://localhost:3000
18 | 4. Run `npm run build` then `npm start` to build for production and launch server
19 | 5. Run `npm run generate` to generate the static project
20 |
21 | ## License
22 |
23 | SitePoint's code archives and code examples are licensed under the MIT license.
24 |
25 | Copyright © 2017 SitePoint
26 |
27 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
28 |
29 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 |
33 |
--------------------------------------------------------------------------------
/posts.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": 4,
4 | "title": "Building universal JS apps with Nuxt.js",
5 | "summary": "Get introduced to Nuxt.js, and build great SSR Apps with Vue.js.",
6 | "content": "
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
",
7 | "author": "Jane Doe",
8 | "published": "08:00 - 07/06/2017"
9 | },
10 | {
11 | "id": 3,
12 | "title": "Great SSR Use cases",
13 | "summary": "See simple and rich server rendered JavaScript apps.",
14 | "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
",
15 | "author": "Jane Doe",
16 | "published": "17:00 - 06/06/2017"
17 | },
18 | {
19 | "id": 2,
20 | "title": "SSR in Vue.js",
21 | "summary": "Learn about SSR in Vue.js, and where Nuxt.js can make it all faster.",
22 | "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
",
23 | "author": "Jane Doe",
24 | "published": "13:00 - 06/06/2017"
25 | },
26 | {
27 | "id": 1,
28 | "title": "Introduction to SSR",
29 | "summary": "Learn about SSR in JavaScript and how it can be super cool.",
30 | "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
",
31 | "author": "John Doe",
32 | "published": "11:00 - 06/06/2017"
33 | }
34 | ]
35 |
--------------------------------------------------------------------------------