-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: blog index done, dark-theme WIP
- Loading branch information
Showing
16 changed files
with
640 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,64 @@ | ||
<script setup lang="ts"> | ||
import { useData } from 'vitepress' | ||
import Article from './Article.vue' | ||
import { data } from './blog.data' | ||
import {ref, computed} from 'vue' | ||
const { frontmatter } = useData() | ||
const PRE_PAGE = 15 | ||
const pageTotal = Math.ceil(data.length/PRE_PAGE) | ||
const pageCurrent = ref(1) | ||
const currentPagePosts = computed(() => data.slice((pageCurrent.value - 1) * PRE_PAGE, pageCurrent.value * PRE_PAGE)) | ||
const changePage = (page:number|'prev'|'next') => { | ||
if (page === 'prev') { | ||
if (pageCurrent.value !== 1) { | ||
pageCurrent.value = pageCurrent.value - 1 | ||
} | ||
} else if (page === 'next') { | ||
if (pageCurrent.value !== pageTotal) { | ||
pageCurrent.value = pageCurrent.value + 1 | ||
} | ||
} else { | ||
pageCurrent.value = page | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="antialiased dark:bg-slate-900"> | ||
<main class="max-w-3xl mx-auto px-4 sm:px-6 xl:max-w-5xl xl:px-0"> | ||
<Article /> | ||
<main class="max-w-3xl mx-auto px-4 sm:px-6 xl:max-w-5xl xl:px-0 pt-10"> | ||
<ul> | ||
<li v-for="item in currentPagePosts" :key="item.url" class="mb-4 hover:scale-105 cursor-pointer overflow-hidden duration-150"> | ||
<a :href="item.url" class="flex gap-x-4 h-44 rounded-lg border overflow-hidden blog-index-list-item line-clamp-6 no-underline"> | ||
<img :src="'./images/' + item.image" alt="" class="flex-[1_4] object-center object-cover"> | ||
<div v-html="item.excerpt" class="prose dark:prose-invert flex-[3_4] py-2 pr-2 h-full overflow-hidden"></div> | ||
</a> | ||
</li> | ||
</ul> | ||
<div class="pagination my-8 select-none" v-if="pageTotal > 1"> | ||
<ul class="flex gap-x-4 justify-center items-center"> | ||
<li class="bordered rounded w-8 h-8 bg-slate-100 flex justify-center items-center cursor-pointer hover:text-sky-400" @click="changePage('prev')"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z" fill="currentColor" /></svg> | ||
</li> | ||
<li v-for="index in pageTotal" class="bordered rounded w-8 h-8 bg-slate-100 flex justify-center items-center cursor-pointer" :class="[pageCurrent === index ? ' bg-sky-300 text-white' : 'text-black hover:text-sky-300']" @click="changePage(index)">{{ index }}</li> | ||
<li class="bordered rounded w-8 h-8 bg-slate-100 flex justify-center items-center cursor-pointer hover:text-sky-400" @click="changePage('next')"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z" fill="currentColor" /></svg> | ||
</li> | ||
</ul> | ||
</div> | ||
</main> | ||
</div> | ||
</template> | ||
</template> | ||
|
||
<style> | ||
.blog-index-list-item.no-underline { | ||
text-decoration: none; | ||
} | ||
.vp-doc .header-anchor:before { | ||
content: '' | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<div>blog index</div> | ||
<!-- <ul> | ||
<li v-for=""></li> | ||
</ul> --> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
* { | ||
scrollbar-width: thin; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.