This commit is contained in:
Sergey Yarkov 2023-02-21 22:55:54 +03:00
parent 87ece33516
commit d68a57be41
No known key found for this signature in database
GPG Key ID: E91CE1FABC619B6F
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,7 @@
--- ---
import type { CollectionEntry } from "astro:content"; import type { CollectionEntry } from "astro:content";
import { Icon } from "astro-icon"; import { Icon } from "astro-icon";
import slugify from "@sindresorhus/slugify";
import { createDateFormatter } from "@root/utils"; import { createDateFormatter } from "@root/utils";
import ArticleCover from "@components/ArticleCover.astro"; import ArticleCover from "@components/ArticleCover.astro";
import ArticleComments from "@components/ArticleComments.astro"; import ArticleComments from "@components/ArticleComments.astro";
@ -17,8 +18,8 @@ const pageLang = getLanguageFromURL(Astro.url.pathname);
const canonicalUrl = new URL(Astro.url.pathname, Astro.site); const canonicalUrl = new URL(Astro.url.pathname, Astro.site);
const { const {
data: { coverImage, title, author, description, tags, pubDate }, data: { coverImage, title, author, description, tags, pubDate },
slug,
} = article; } = article;
const slug = slugify(title, { lowercase: true });
const t = useTranslation(Astro); const t = useTranslation(Astro);
--- ---

View File

@ -1,6 +1,6 @@
import type { Component } from "solid-js"; import type { Component } from "solid-js";
import { createSignal, createEffect, For } from "solid-js"; import { createSignal, createEffect, For } from "solid-js";
import { search, selectedTags } from "@stores/searchStore"; import { search, selectedTags, setCount } from "@stores/searchStore";
import SearchInput from "./SearchInput"; import SearchInput from "./SearchInput";
import TagsList from "./TagsList"; import TagsList from "./TagsList";
import ArticleItem from "@components/ArticleItem"; import ArticleItem from "@components/ArticleItem";
@ -39,7 +39,7 @@ const ArticlesList: Component<ArticlesListProps> = (props) => {
params: { search, tags }, params: { search, tags },
}: { }: {
params: { search: string; tags?: string[] }; params: { search: string; tags?: string[] };
}) => { }): ArticlesBlockType => {
const filter = (cb: (year: string) => ArticlesType) => { const filter = (cb: (year: string) => ArticlesType) => {
return Object.fromEntries( return Object.fromEntries(
Object.keys(props.articles) Object.keys(props.articles)
@ -60,7 +60,9 @@ const ArticlesList: Component<ArticlesListProps> = (props) => {
}; };
createEffect(() => { createEffect(() => {
setArticles(searchArticles({ params: { search: search(), tags: selectedTags() } })); const filtered = searchArticles({ params: { search: search(), tags: selectedTags() } });
setArticles(filtered);
setCount(Object.values(filtered).flat().length);
}); });
return ( return (