Skip to content

Commit

Permalink
feat(postlist): calculate postlist height according to pageSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Octobug committed Nov 30, 2023
1 parent 2776f45 commit 532c253
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .vitepress/theme/components/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const { theme } = useData();
}
.frame {
padding: 1.5rem 0;
padding: 0 0 1.5rem;
}
}
</style>
2 changes: 1 addition & 1 deletion .vitepress/theme/components/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<style module scoped>
.container {
justify-content: center;
padding: 1rem 2.5rem 0;
padding: 2rem 2rem 0;
}
@media (min-width: 640px) {
Expand Down
19 changes: 16 additions & 3 deletions .vitepress/theme/components/HomeFeed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<script lang="ts" setup>
import type { ContentData } from "vitepress";
import { useData } from "vitepress";
import { onContentUpdated, useData } from "vitepress";
import { ref } from "vue";
import { data as allPosts } from "../posts.data";
import PostList from "./PostList.vue";
Expand All @@ -53,15 +53,28 @@ function turnTo(n: number) {
const start = (n - 1) * page.size;
postList.value = allPosts.slice(start, start + page.size);
}
function setPostListMinHeight() {
const root = document.querySelector(":root");
const h = theme.value.pageSize * 2.9;
(<HTMLElement>root).style.setProperty("--post-list-min-height", `${h}rem`);
}
onContentUpdated(() => {
setPostListMinHeight();
});
</script>

<style module scope>
:root {
--post-list-min-height: 29rem;
}
.postListBox {
min-height: 29rem;
min-height: var(--post-list-min-height);
}
.pagination {
padding-top: 1rem;
display: flex;
align-items: center;
justify-content: center;
Expand Down

0 comments on commit 532c253

Please sign in to comment.