From 1e248151d5bd60e8c94ab26f272e5e9cf900ca7a Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Fri, 11 Oct 2019 19:08:14 +0200 Subject: Add folder structure parser --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 8c6652c..83c10f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +kronika + # Created by .ignore support plugin (hsz.mobi) ### Node template # Logs -- cgit 1.4.1 From d92f1a2a1bac3039434a16c504cc1d54c6d0409a Mon Sep 17 00:00:00 2001 From: Patryk Niedźwiedziński Date: Sat, 12 Oct 2019 15:40:51 +0200 Subject: Change posts location --- .gitignore | 2 +- api/api.js | 21 ++++---- nuxt.config.js | 2 +- pages/kronika/_year/_month/_day/_title/index.vue | 65 ++++++++++++++++++++++++ scripts/prebuild.sh | 6 +-- 5 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 pages/kronika/_year/_month/_day/_title/index.vue (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 83c10f2..53c3292 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -kronika +content # Created by .ignore support plugin (hsz.mobi) ### Node template diff --git a/api/api.js b/api/api.js index a704912..1675d7e 100644 --- a/api/api.js +++ b/api/api.js @@ -1,12 +1,12 @@ const fs = require('fs') const frontmatter = require('front-matter') -const POSTS_PATH = './kronika/wpisy' +const POSTS_PATH = './content/wpisy' function getPostAttributes(filePath) { - const fileContent = fs.readFileSync(filePath, "utf-8") + const fileContent = fs.readFileSync(filePath, 'utf-8') - const post = frontmatter(fileContent); + const post = frontmatter(fileContent) return post.attributes } @@ -14,15 +14,15 @@ function getPosts() { const routesArray = [] try { const years = fs.readdirSync(`${POSTS_PATH}`) - years.forEach((year) => { + years.forEach(year => { const months = fs.readdirSync(`${POSTS_PATH}/${year}`) - months.forEach((month) => { + months.forEach(month => { const days = fs.readdirSync(`${POSTS_PATH}/${year}/${month}`) - days.forEach((day) => { + days.forEach(day => { const files = fs.readdirSync(`${POSTS_PATH}/${year}/${month}/${day}`) - files.forEach((file) => { + files.forEach(file => { const title = file.substr(0, file.lastIndexOf('.')) - const route = `/kronika/${year}/${month}/${day}/${title}` + const route = `/kronika/${year}/${month}/${day}/${title}/` const fsRoute = `${POSTS_PATH}/${year}/${month}/${day}/${file}` const attributes = getPostAttributes(fsRoute) @@ -41,8 +41,7 @@ function getPosts() { }) }) }) - } - finally { + } finally { return routesArray } } @@ -55,4 +54,4 @@ function createRoutesArray() { module.exports = { getPosts, createRoutesArray -} \ No newline at end of file +} diff --git a/nuxt.config.js b/nuxt.config.js index a98a7c7..7f66b21 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -34,7 +34,7 @@ export default { ] }, generate: { - routes: createRoutesArray + routes: createRoutesArray() }, /* ** Customize the progress-bar color diff --git a/pages/kronika/_year/_month/_day/_title/index.vue b/pages/kronika/_year/_month/_day/_title/index.vue new file mode 100644 index 0000000..1148f61 --- /dev/null +++ b/pages/kronika/_year/_month/_day/_title/index.vue @@ -0,0 +1,65 @@ + + + + + \ No newline at end of file diff --git a/scripts/prebuild.sh b/scripts/prebuild.sh index 22d8e00..937bf5f 100755 --- a/scripts/prebuild.sh +++ b/scripts/prebuild.sh @@ -3,10 +3,10 @@ set -x set -eou pipefail -if [ -d ./kronika ]; then - cd kronika +if [ -d ./content ]; then + cd content git pull cd .. else - git clone https://github.com/19pdh/kronika + git clone https://github.com/19pdh/kronika content fi -- cgit 1.4.1