mirror of
https://github.com/sendevia/website.git
synced 2026-03-05 23:32:45 +08:00
rename: postsRef to articlesRef
This commit is contained in:
@@ -13,7 +13,7 @@ const { isSearchActive, isSearchTyping, deactivateSearch, setSearchFocus, setSea
|
||||
const { isAboveBreakpoint } = useScreenWidth(840);
|
||||
|
||||
const isHome = computed(() => frontmatter.value.home === true);
|
||||
const postsRef = useAllPosts(true);
|
||||
const articlesRef = useAllPosts(true);
|
||||
const query = ref("");
|
||||
const appbar = ref<HTMLElement | null>(null);
|
||||
const searchInput = ref<HTMLInputElement | null>(null);
|
||||
@@ -22,9 +22,9 @@ const isTabFocusable = computed(() => !isAboveBreakpoint.value);
|
||||
// 计算过滤后的文章
|
||||
const filteredPosts = computed<Post[]>(() => {
|
||||
const q = query.value.trim().toLowerCase();
|
||||
if (!q || !postsRef.value) return [];
|
||||
if (!q || !articlesRef.value) return [];
|
||||
|
||||
return postsRef.value.filter((post) => {
|
||||
return articlesRef.value.filter((post) => {
|
||||
const { title = "", description = "", content = "", date = "" } = post;
|
||||
return (
|
||||
title.toLowerCase().includes(q) ||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { useAllPosts } from "../composables/useAllPosts";
|
||||
|
||||
const { page } = useGlobalData();
|
||||
|
||||
const postsRef = useAllPosts(true);
|
||||
const articlesRef = useAllPosts(true);
|
||||
|
||||
function normalize(u: string | undefined | null) {
|
||||
if (!u) return "";
|
||||
@@ -48,7 +48,7 @@ const currentCandidates = computed(() => {
|
||||
});
|
||||
|
||||
const currentIndex = computed(() => {
|
||||
const posts = postsRef.value || [];
|
||||
const posts = articlesRef.value || [];
|
||||
|
||||
for (let i = 0; i < posts.length; i++) {
|
||||
const post = posts[i];
|
||||
@@ -68,14 +68,14 @@ const currentIndex = computed(() => {
|
||||
});
|
||||
|
||||
const prev = computed(() => {
|
||||
const posts = postsRef.value || [];
|
||||
const posts = articlesRef.value || [];
|
||||
const idx = currentIndex.value;
|
||||
if (idx > 0) return posts[idx - 1];
|
||||
return null;
|
||||
});
|
||||
|
||||
const next = computed(() => {
|
||||
const posts = postsRef.value || [];
|
||||
const posts = articlesRef.value || [];
|
||||
const idx = currentIndex.value;
|
||||
if (idx >= 0 && idx < posts.length - 1) return posts[idx + 1];
|
||||
return null;
|
||||
|
||||
@@ -87,9 +87,9 @@ export function useAllPosts(asRef = false) {
|
||||
return 0;
|
||||
});
|
||||
|
||||
const postsRef = ref<Data[]>(posts);
|
||||
const articlesRef = ref<Data[]>(posts);
|
||||
|
||||
return asRef ? postsRef : postsRef.value;
|
||||
return asRef ? articlesRef : articlesRef.value;
|
||||
}
|
||||
|
||||
export type { Data as Post };
|
||||
|
||||
Reference in New Issue
Block a user