aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/content/blog/2020-04-30-hello-world.json6
-rw-r--r--layouts/error.vue4
-rw-r--r--nuxt.config.js32
-rw-r--r--package.json1
-rw-r--r--pages/blog/_blog.vue33
-rw-r--r--pages/blog/index.vue17
-rw-r--r--static/admin/config.yml2
-rw-r--r--store/index.js21
-rw-r--r--yarn.lock60
9 files changed, 153 insertions, 23 deletions
diff --git a/assets/content/blog/2020-04-30-hello-world.json b/assets/content/blog/2020-04-30-hello-world.json
deleted file mode 100644
index a373862..0000000
--- a/assets/content/blog/2020-04-30-hello-world.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "date": "2020-04-30T23:58:35.304Z",
- "title": "Hello World",
- "description": "This is a test",
- "body": "**123344444**\n\n**d**\n\n**dddddd**"
-} \ No newline at end of file
diff --git a/layouts/error.vue b/layouts/error.vue
index 7a14d29..27b44b9 100644
--- a/layouts/error.vue
+++ b/layouts/error.vue
@@ -1,8 +1,8 @@
<template>
<v-container>
- <h1 v-if="error.statusCode">{{error.statusCode}} Error</h1>
+ <h1 v-if="error.statusCode = 404">404 Error</h1>
<h1 v-else>An error occurred</h1>
- <p>Hmm. Seems like this page either didn't exist or you weren't allowed to access this page.</p>
+ <p>Hmm. Seems like this page either didn't exist...</p>
<nuxt-link to="/">Home page</nuxt-link>
</v-container>
</template>
diff --git a/nuxt.config.js b/nuxt.config.js
index 7881a99..39370d1 100644
--- a/nuxt.config.js
+++ b/nuxt.config.js
@@ -11,12 +11,12 @@ module.exports = {
{ hid: 'description', name: 'description', content: 'Andrew\'s Personal Website' }
],
link: [
- {
- rel: 'icon',
- type: 'image/x-icon',
- href: 'favicon.ico',
- }
- ]
+ {
+ rel: 'icon',
+ type: 'image/x-icon',
+ href: 'favicon.ico'
+ }
+ ]
},
/*
** Customize the progress-bar color
@@ -41,7 +41,25 @@ module.exports = {
/*
** Nuxt.js modules
*/
- modules: ['@nuxtjs/pwa'],
+ modules: ['@nuxtjs/pwa', '@nuxtjs/markdownit'],
+
+ markdownit: {
+ injected: true
+ },
+
+ generate: {
+ routes: function () {
+ const fs = require('fs')
+ const path = require('path')
+ return fs.readdirSync('static/content/blog').map(file => {
+ return {
+ route: `/blog/${path.parse(file).name}`, // Return the slug
+ payload: require(`static/content/blog/${file}`)
+ }
+ })
+ }
+ },
+
/*
** vuetify module configuration
** https://github.com/nuxt-community/vuetify-module
diff --git a/package.json b/package.json
index 27644d4..5e6b73d 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},
"dependencies": {
+ "@nuxtjs/markdownit": "^1.2.9",
"@nuxtjs/pwa": "^3.0.0-0",
"node-sass": "^4.13.1",
"nuxt": "^2.12.2",
diff --git a/pages/blog/_blog.vue b/pages/blog/_blog.vue
new file mode 100644
index 0000000..3f328eb
--- /dev/null
+++ b/pages/blog/_blog.vue
@@ -0,0 +1,33 @@
+<template>
+ <v-container>
+ <v-card>
+ <v-card-title>{{blogPost.title}}</v-card-title>
+ <v-card-subtitle>{{blogPost.description}}</v-card-subtitle>
+ <v-card-text :to="'/blog'">Back to posts</v-card-text>
+ <v-divider/>
+ <br/>
+ <v-card-text v-html="$md.render(blogPost.body)" />
+ </v-card>
+ </v-container>
+</template>
+
+<script>
+export default {
+ name: '_blog',
+ head: {
+ title: '{{blogpost.title}}'
+ },
+ async asyncData ({ params, payload }) {
+ if (payload) return { blogPost: payload }
+ else {
+ return {
+ blogPost: await require(`~/assets/content/blog/${params.blog}.json`)
+ }
+ }
+ }
+}
+</script>
+
+<style scoped>
+
+</style>
diff --git a/pages/blog/index.vue b/pages/blog/index.vue
index 2e10eba..5619e6b 100644
--- a/pages/blog/index.vue
+++ b/pages/blog/index.vue
@@ -7,13 +7,13 @@
</header>
</v-card>
<v-container>
- <v-col cols="6">
- <v-card to="/">
- <v-card-title>Blog Post Title</v-card-title>
- <v-card-text>Content</v-card-text>
+ <div v-for="post in blogPosts" :key="post.title">
+ <v-card :to="'/blog/' + post.slug">
+ <v-card-title>{{ post.title }}</v-card-title>
+ <v-card-subtitle>Created on {{post.date}}</v-card-subtitle>
+ <v-card-text>{{ post.description }}</v-card-text>
</v-card>
- <br>
- </v-col>
+ </div>
</v-container>
</div>
</template>
@@ -23,6 +23,11 @@ export default {
name: 'blog',
head: {
title: 'Blog'
+ },
+ computed: {
+ blogPosts () {
+ return this.$store.state.blogPosts
+ }
}
}
diff --git a/static/admin/config.yml b/static/admin/config.yml
index 93a737a..da15de0 100644
--- a/static/admin/config.yml
+++ b/static/admin/config.yml
@@ -2,7 +2,7 @@ backend:
name: git-gateway
branch: master
repo: Alee14/personal-website
-logo_url: ../../assets/img/Alee.png
+logo_url: /assets/img/Alee.png
media_folder: "static/uploads"
public_folder: "/uploads"
collections:
diff --git a/store/index.js b/store/index.js
new file mode 100644
index 0000000..cb8a915
--- /dev/null
+++ b/store/index.js
@@ -0,0 +1,21 @@
+export const state = () => ({
+ blogPosts: []
+})
+
+export const mutations = {
+ setBlogPosts (state, list) {
+ state.blogPosts = list
+ }
+}
+
+export const actions = {
+ async nuxtServerInit ({ commit }) {
+ const files = await require.context('../assets/content/blog/', false, /\.json$/)
+ const blogPosts = files.keys().map(key => {
+ const res = files(key)
+ res.slug = key.slice(2, -5)
+ return res
+ })
+ await commit('setBlogPosts', blogPosts)
+ }
+}
diff --git a/yarn.lock b/yarn.lock
index ec07848..7a32dcb 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1070,6 +1070,23 @@
consola "^2.11.3"
eslint-loader "^4.0.2"
+"@nuxtjs/markdownit-loader@^1.1.1":
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/@nuxtjs/markdownit-loader/-/markdownit-loader-1.1.1.tgz#7223b49064a176394f6f82aad3bf622069004799"
+ integrity sha512-ijbEL5QOTRGuykwpikxaanxv5QntRiGYPtBDFvvdhoVNpsfbvROk1QnxCd2tMaYo6zKtpjFQS1RXcluwn5oTXg==
+ dependencies:
+ highlight.js "^9.12.0"
+ loader-utils "^1.1.0"
+ markdown-it "^8.3.1"
+
+"@nuxtjs/markdownit@^1.2.9":
+ version "1.2.9"
+ resolved "https://registry.yarnpkg.com/@nuxtjs/markdownit/-/markdownit-1.2.9.tgz#c347fcb68c80bfd608d90af4b5a1665c3786c52f"
+ integrity sha512-zysuv6Kp0BJv7V3fD4NJW/6OExFPg0XWAnr6pTQkF7c7w3fx0j4O993faehh4OCCIxf5cD2HO74FnC6v2sPsdw==
+ dependencies:
+ "@nuxtjs/markdownit-loader" "^1.1.1"
+ raw-loader "^4.0.0"
+
"@nuxtjs/pwa@^3.0.0-0":
version "3.0.0-beta.20"
resolved "https://registry.yarnpkg.com/@nuxtjs/pwa/-/pwa-3.0.0-beta.20.tgz#56766da5485c09cb73307285292203f4a4417d5d"
@@ -3141,7 +3158,7 @@ enhanced-resolve@^4.1.0, enhanced-resolve@^4.1.1:
memory-fs "^0.5.0"
tapable "^1.0.0"
-entities@^1.1.1:
+entities@^1.1.1, entities@~1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56"
integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==
@@ -4227,6 +4244,11 @@ hex-color-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==
+highlight.js@^9.12.0:
+ version "9.18.1"
+ resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.1.tgz#ed21aa001fe6252bb10a3d76d47573c6539fe13c"
+ integrity sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg==
+
hmac-drbg@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
@@ -5013,6 +5035,13 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=
+linkify-it@^2.0.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf"
+ integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==
+ dependencies:
+ uc.micro "^1.0.1"
+
load-json-file@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0"
@@ -5239,6 +5268,17 @@ map-visit@^1.0.0:
dependencies:
object-visit "^1.0.0"
+markdown-it@^8.3.1:
+ version "8.4.2"
+ resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
+ integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==
+ dependencies:
+ argparse "^1.0.7"
+ entities "~1.1.1"
+ linkify-it "^2.0.0"
+ mdurl "^1.0.1"
+ uc.micro "^1.0.5"
+
md5.js@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
@@ -5258,6 +5298,11 @@ mdn-data@2.0.6:
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.6.tgz#852dc60fcaa5daa2e8cf6c9189c440ed3e042978"
integrity sha512-rQvjv71olwNHgiTbfPZFkJtjNMciWgswYeciZhtvWLO8bmX3TnhyA62I6sTWOyZssWHJJjY6/KiWwqQsWWsqOA==
+mdurl@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
+ integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=
+
media-typer@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
@@ -7077,6 +7122,14 @@ raw-body@2.4.0:
iconv-lite "0.4.24"
unpipe "1.0.0"
+raw-loader@^4.0.0:
+ version "4.0.1"
+ resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-4.0.1.tgz#14e1f726a359b68437e183d5a5b7d33a3eba6933"
+ integrity sha512-baolhQBSi3iNh1cglJjA0mYzga+wePk7vdEX//1dTFd+v4TsQlQE0jitJSNF1OIP82rdYulH7otaVmdlDaJ64A==
+ dependencies:
+ loader-utils "^2.0.0"
+ schema-utils "^2.6.5"
+
read-cache@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/read-cache/-/read-cache-1.0.0.tgz#e664ef31161166c9751cdbe8dbcf86b5fb58f774"
@@ -8413,6 +8466,11 @@ ua-parser-js@^0.7.21:
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777"
integrity sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ==
+uc.micro@^1.0.1, uc.micro@^1.0.5:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
+ integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
+
uglify-js@3.4.x:
version "3.4.10"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"