Adding initial nuxt version for static page.
This commit is contained in:
parent
0f7094c61a
commit
1671d19134
28 changed files with 2744 additions and 102 deletions
43
2022/01/nuxt_demo1/pages/blog/index.vue
Normal file
43
2022/01/nuxt_demo1/pages/blog/index.vue
Normal file
|
@ -0,0 +1,43 @@
|
|||
<template>
|
||||
<div>
|
||||
<Navigation></Navigation>
|
||||
<div class="blog">
|
||||
<div class="wallpaper">
|
||||
<div class="container">
|
||||
<div class="bcontent">
|
||||
<Post :key="post.info.slug" v-for="post of posts" :template="post" />
|
||||
End of Index
|
||||
<div id="disqus_thread"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export default {
|
||||
name: 'Blog',
|
||||
async asyncData({params, redirect}) {
|
||||
let listOfPosts = JSON.parse(fs.readFileSync(
|
||||
path.join('.', 'data', 'posts', 'index.json')));
|
||||
|
||||
let posts = listOfPosts.map((post) => {
|
||||
let data = fs.readFileSync(
|
||||
path.join('.', 'data', 'posts', post.slug + ".md"), "utf-8");
|
||||
return {info: post, data: data};
|
||||
});
|
||||
|
||||
console.log('Posts: ', posts);
|
||||
|
||||
return {posts: posts};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
@import "~assets/main.scss";
|
||||
</style>
|
Loading…
Add table
Add a link
Reference in a new issue