Skip to content

Commit df0093c

Browse files
committed
🛠 - Add route generation, update config, set templates
1 parent e0f3bf6 commit df0093c

File tree

12 files changed

+170
-53
lines changed

12 files changed

+170
-53
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.formatOnSave": true
3+
}

content/README.md

-5
This file was deleted.

content/blog/2019-08-27-sunt-libero-eaque-fu.md

-12
This file was deleted.

netlify.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build]
2+
publish = "dist/"
3+
command = "npm run generate"

nuxt.config.js

+41-31
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,62 @@
1-
21
export default {
32
mode: 'universal',
43
/*
5-
** Headers of the page
6-
*/
4+
** Headers of the page
5+
*/
76
head: {
87
title: process.env.npm_package_name || '',
98
meta: [
109
{ charset: 'utf-8' },
1110
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
12-
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
11+
{
12+
hid: 'description',
13+
name: 'description',
14+
content: process.env.npm_package_description || ''
15+
}
1316
],
14-
link: [
15-
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
16-
]
17+
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
18+
},
19+
generate: {
20+
routes: function() {
21+
const fs = require('fs')
22+
return fs.readdirSync('./assets/content/blog').map(file => {
23+
return {
24+
route: `/blog/${file.slice(2, -5)}`,
25+
payload: require(`./assets/content/blog/${file}`)
26+
}
27+
})
28+
}
1729
},
1830
/*
19-
** Customize the progress-bar color
20-
*/
31+
** Customize the progress-bar color
32+
*/
2133
loading: { color: '#fff' },
2234
/*
23-
** Global CSS
24-
*/
25-
css: [
26-
],
35+
** Global CSS
36+
*/
37+
css: [],
2738
/*
28-
** Plugins to load before mounting the App
29-
*/
30-
plugins: [
31-
],
39+
** Plugins to load before mounting the App
40+
*/
41+
plugins: [],
3242
/*
33-
** Nuxt.js dev-modules
34-
*/
35-
buildModules: [
36-
],
43+
** Nuxt.js dev-modules
44+
*/
45+
buildModules: [],
3746
/*
38-
** Nuxt.js modules
39-
*/
40-
modules: [
41-
],
47+
** Nuxt.js modules
48+
*/
49+
modules: ['@nuxtjs/markdownit'],
50+
markdownit: {
51+
injected: true
52+
},
4253
/*
43-
** Build configuration
44-
*/
54+
** Build configuration
55+
*/
4556
build: {
4657
/*
47-
** You can extend webpack config here
48-
*/
49-
extend (config, ctx) {
50-
}
58+
** You can extend webpack config here
59+
*/
60+
extend(config, ctx) {}
5161
}
5262
}

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
"generate": "nuxt generate"
1212
},
1313
"dependencies": {
14+
"@nuxtjs/markdownit": "^1.2.6",
1415
"nuxt": "^2.0.0"
1516
},
1617
"devDependencies": {
1718
"eslint-config-prettier": "^4.1.0",
1819
"eslint-plugin-prettier": "^3.0.1",
1920
"prettier": "^1.16.4"
2021
}
21-
}
22+
}

pages/blog/_blog.vue

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<article>
3+
<h1>{{blogPost.title}}</h1>
4+
<div v-html="$md.render(blogPost.body)" />
5+
</article>
6+
</template>
7+
<script>
8+
export default {
9+
async asyncData({ params, payload }) {
10+
if (payload) return { blogPost: payload }
11+
else
12+
return {
13+
blogPost: await require(`~/assets/content/blog/${params.blog}.json`)
14+
}
15+
}
16+
}
17+
</script>

pages/blog/index.vue

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<div>
3+
<ul v-for="(blogPost, index) in blogPosts" :key="index">
4+
<nuxt-link :to="`blog/${blogPost.slug}`">{{blogPost.title}}</nuxt-link>
5+
<p>{{blogPost.description}}</p>
6+
</ul>
7+
</div>
8+
</template>
9+
<script>
10+
export default {
11+
computed: {
12+
blogPosts() {
13+
return this.$store.state.blogPosts
14+
}
15+
}
16+
}
17+
</script>

static/admin/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public_folder: /img
88
collections:
99
- name: 'blog'
1010
label: 'Blog'
11-
folder: 'content/blog'
11+
folder: 'assets/content/blog'
1212
create: true
1313
format: 'json'
1414
slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
@@ -18,4 +18,4 @@ collections:
1818
- { label: 'Title', name: 'title', widget: 'string' }
1919
- { label: 'Publish Date', name: 'date', widget: 'datetime' }
2020
- { label: 'Description', name: 'description', widget: 'string' }
21-
- { label: 'Body', name: 'body', widget: 'markdown' }
21+
- { label: 'Body', name: 'body', widget: 'markdown' }

store/index.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const state = () => ({
2+
blogPosts: []
3+
})
4+
5+
export const mutations = {
6+
setBlogPosts(state, list) {
7+
state.blogPosts = list
8+
}
9+
}
10+
11+
export const actions = {
12+
async nuxtServerInit({ commit }) {
13+
let files = await require.context(
14+
'~/assets/content/blog/',
15+
false,
16+
/\.json$/
17+
)
18+
let blogPosts = files.keys().map(key => {
19+
let res = files(key)
20+
res.slug = key.slice(2, -5)
21+
return res
22+
})
23+
await commit('setBlogPosts', blogPosts)
24+
}
25+
}

yarn.lock

+60-2
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,23 @@
942942
webpack-node-externals "^1.7.2"
943943
webpackbar "^4.0.0"
944944

945+
"@nuxtjs/markdownit-loader@^1.1.1":
946+
version "1.1.1"
947+
resolved "https://registry.yarnpkg.com/@nuxtjs/markdownit-loader/-/markdownit-loader-1.1.1.tgz#7223b49064a176394f6f82aad3bf622069004799"
948+
integrity sha512-ijbEL5QOTRGuykwpikxaanxv5QntRiGYPtBDFvvdhoVNpsfbvROk1QnxCd2tMaYo6zKtpjFQS1RXcluwn5oTXg==
949+
dependencies:
950+
highlight.js "^9.12.0"
951+
loader-utils "^1.1.0"
952+
markdown-it "^8.3.1"
953+
954+
"@nuxtjs/markdownit@^1.2.6":
955+
version "1.2.6"
956+
resolved "https://registry.yarnpkg.com/@nuxtjs/markdownit/-/markdownit-1.2.6.tgz#489de5529d3d7eb71006c3032f086ebf3de745b2"
957+
integrity sha512-mogE6lXoQghZMkJoXj7TfWrlvmVrB/2s5FfFsSv23s4vJt0ZgmPSqI1X+qaAFuP1BSVPpQOoFtesZUA6n8bFmQ==
958+
dependencies:
959+
"@nuxtjs/markdownit-loader" "^1.1.1"
960+
raw-loader "^3.0.0"
961+
945962
"@nuxtjs/youch@^4.2.3":
946963
version "4.2.3"
947964
resolved "https://registry.yarnpkg.com/@nuxtjs/youch/-/youch-4.2.3.tgz#36f8b22df5a0efaa81373109851e1d857aca6bed"
@@ -2695,7 +2712,7 @@ enhanced-resolve@^4.1.0:
26952712
memory-fs "^0.4.0"
26962713
tapable "^1.0.0"
26972714

2698-
entities@^1.1.1:
2715+
entities@^1.1.1, entities@~1.1.1:
26992716
version "1.1.2"
27002717
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56"
27012718
integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==
@@ -3329,6 +3346,11 @@ hex-color-regex@^1.1.0:
33293346
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
33303347
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==
33313348

3349+
highlight.js@^9.12.0:
3350+
version "9.15.10"
3351+
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.15.10.tgz#7b18ed75c90348c045eef9ed08ca1319a2219ad2"
3352+
integrity sha512-RoV7OkQm0T3os3Dd2VHLNMoaoDVx77Wygln3n9l5YV172XonWG6rgQD3XnF/BuFFZw9A0TJgmMSO8FEWQgvcXw==
3353+
33323354
hmac-drbg@^1.0.0:
33333355
version "1.0.1"
33343356
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
@@ -3932,6 +3954,13 @@ launch-editor@^2.2.1:
39323954
chalk "^2.3.0"
39333955
shell-quote "^1.6.1"
39343956

3957+
linkify-it@^2.0.0:
3958+
version "2.2.0"
3959+
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf"
3960+
integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==
3961+
dependencies:
3962+
uc.micro "^1.0.1"
3963+
39353964
loader-runner@^2.3.1, loader-runner@^2.4.0:
39363965
version "2.4.0"
39373966
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357"
@@ -4077,6 +4106,17 @@ map-visit@^1.0.0:
40774106
dependencies:
40784107
object-visit "^1.0.0"
40794108

4109+
markdown-it@^8.3.1:
4110+
version "8.4.2"
4111+
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
4112+
integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==
4113+
dependencies:
4114+
argparse "^1.0.7"
4115+
entities "~1.1.1"
4116+
linkify-it "^2.0.0"
4117+
mdurl "^1.0.1"
4118+
uc.micro "^1.0.5"
4119+
40804120
md5.js@^1.3.4:
40814121
version "1.3.5"
40824122
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
@@ -4096,6 +4136,11 @@ mdn-data@~1.1.0:
40964136
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-1.1.4.tgz#50b5d4ffc4575276573c4eedb8780812a8419f01"
40974137
integrity sha512-FSYbp3lyKjyj3E7fMl6rYvUdX0FBXaluGqlFoYESWQlyUTq8R+wp0rkFxoYFqZlHCvsUXGjyJmLQSnXToYhOSA==
40984138

4139+
mdurl@^1.0.1:
4140+
version "1.0.1"
4141+
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
4142+
integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=
4143+
40994144
41004145
version "0.3.0"
41014146
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
@@ -5662,6 +5707,14 @@ [email protected]:
56625707
iconv-lite "0.4.24"
56635708
unpipe "1.0.0"
56645709

5710+
raw-loader@^3.0.0:
5711+
version "3.1.0"
5712+
resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-3.1.0.tgz#5e9d399a5a222cc0de18f42c3bc5e49677532b3f"
5713+
integrity sha512-lzUVMuJ06HF4rYveaz9Tv0WRlUMxJ0Y1hgSkkgg+50iEdaI0TthyEDe08KIHb0XsF6rn8WYTqPCaGTZg3sX+qA==
5714+
dependencies:
5715+
loader-utils "^1.1.0"
5716+
schema-utils "^2.0.1"
5717+
56655718
rc@^1.2.7:
56665719
version "1.2.8"
56675720
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
@@ -5909,7 +5962,7 @@ schema-utils@^1.0.0:
59095962
ajv-errors "^1.0.0"
59105963
ajv-keywords "^3.1.0"
59115964

5912-
schema-utils@^2.0.0:
5965+
schema-utils@^2.0.0, schema-utils@^2.0.1:
59135966
version "2.1.0"
59145967
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-2.1.0.tgz#940363b6b1ec407800a22951bdcc23363c039393"
59155968
integrity sha512-g6SViEZAfGNrToD82ZPUjq52KUPDYc+fN5+g6Euo5mLokl/9Yx14z0Cu4RR1m55HtBXejO0sBt+qw79axN+Fiw==
@@ -6553,6 +6606,11 @@ ua-parser-js@^0.7.20:
65536606
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.20.tgz#7527178b82f6a62a0f243d1f94fd30e3e3c21098"
65546607
integrity sha512-8OaIKfzL5cpx8eCMAhhvTlft8GYF8b2eQr6JkCyVdrgjcytyOmPCXrqXFcUnhonRpLlh5yxEZVohm6mzaowUOw==
65556608

6609+
uc.micro@^1.0.1, uc.micro@^1.0.5:
6610+
version "1.0.6"
6611+
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
6612+
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
6613+
65566614
65576615
version "3.4.10"
65586616
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"

0 commit comments

Comments
 (0)