From 9a78c859ae05271eb5d42e13e38bf4becb5bfd91 Mon Sep 17 00:00:00 2001 From: Igor Lobanov Date: Wed, 5 Oct 2022 13:13:15 +0200 Subject: [PATCH] WIP --- astro.config.ts | 1 - src/components/Views/AllAuthors.tsx | 20 ++++++++++++-------- src/layouts/zine.astro | 2 +- src/pages/authors.astro | 2 -- src/pages/topics.astro | 2 -- src/stores/zine/authors.ts | 4 ++-- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/astro.config.ts b/astro.config.ts index d6edf5f6..fb57d0b1 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -18,7 +18,6 @@ const getDevCssClassPrefix = (filename: string): string => { .slice(filename.indexOf(PATH_PREFIX) + PATH_PREFIX.length) .replace('.module.scss', '') .replace(/[/?\\]/g, '-') - .replace('?', '-') } const devGenerateScopedName = (name: string, filename: string, css: string) => diff --git a/src/components/Views/AllAuthors.tsx b/src/components/Views/AllAuthors.tsx index dbe5ddc4..f6bad799 100644 --- a/src/components/Views/AllAuthors.tsx +++ b/src/components/Views/AllAuthors.tsx @@ -8,8 +8,11 @@ import { t } from '../../utils/intl' import { useAuthorsStore } from '../../stores/zine/authors' import { handleClientRouteLinkClick, useRouter } from '../../stores/router' import { useAuthStore } from '../../stores/auth' +import { getLogger } from '../../utils/logger' import '../../styles/AllTopics.scss' +const log = getLogger('AllAuthorsView') + type AllAuthorsPageSearchParams = { by: '' | 'name' | 'shouts' | 'rating' } @@ -19,8 +22,7 @@ type Props = { } export const AllAuthorsView = (props: Props) => { - const { sortedAuthors: authorList } = useAuthorsStore({ authors: props.authors }) - const [sortedAuthors, setSortedAuthors] = createSignal([]) + const { sortedAuthors } = useAuthorsStore({ authors: props.authors }) const [sortedKeys, setSortedKeys] = createSignal([]) const [abc, setAbc] = createSignal([]) @@ -33,17 +35,19 @@ export const AllAuthorsView = (props: Props) => { createEffect(() => { if ((!getSearchParams().by || getSearchParams().by === 'name') && abc().length === 0) { console.log('[authors] default grouping by abc') - const grouped = { ...groupByName(authorList()) } + const grouped = { ...groupByName(sortedAuthors()) } grouped['A-Z'] = sortBy(grouped['A-Z'], byFirstChar) setAbc(grouped) const keys = Object.keys(abc) keys.sort() - setSortedKeys(keys as string[]) + setSortedKeys(keys) } else { console.log('[authors] sorting by ' + getSearchParams().by) - setSortedAuthors(sortBy(authorList(), getSearchParams().by)) + ///setSortedAuthors(sortBy(authorList(), getSearchParams().by)) } - }, [authorList(), getSearchParams().by]) + }) + + log.debug(getSearchParams()) return (
@@ -86,7 +90,7 @@ export const AllAuthorsView = (props: Props) => { fallback={() => (
- {(author: Author) => ( + {(author) => ( { )} > - {(letter: string) => ( + {(letter) => (

{letter}

diff --git a/src/layouts/zine.astro b/src/layouts/zine.astro index e4ce1d99..41be19e4 100644 --- a/src/layouts/zine.astro +++ b/src/layouts/zine.astro @@ -4,7 +4,7 @@ import '../styles/app.scss' import { t } from '../utils/intl' const lang = Astro.url.searchParams.get('lang') || 'ru' -// console.log('[layout] server locale is', lang) +console.log('[layout] server locale is', lang) setLocale(lang) --- diff --git a/src/pages/authors.astro b/src/pages/authors.astro index f3cd2131..2cb49a90 100644 --- a/src/pages/authors.astro +++ b/src/pages/authors.astro @@ -8,8 +8,6 @@ const authors = await apiClient.getAllAuthors() const { pathname, search } = Astro.url initRouter(pathname, search) - -Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate') --- diff --git a/src/pages/topics.astro b/src/pages/topics.astro index 633ca6b3..0ab55341 100644 --- a/src/pages/topics.astro +++ b/src/pages/topics.astro @@ -6,8 +6,6 @@ import { initRouter } from '../stores/router' const topics = await apiClient.getAllTopics() -Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate') - const { pathname, search } = Astro.url initRouter(pathname, search) --- diff --git a/src/stores/zine/authors.ts b/src/stores/zine/authors.ts index c09604dc..567f70a1 100644 --- a/src/stores/zine/authors.ts +++ b/src/stores/zine/authors.ts @@ -19,12 +19,12 @@ const sortedAuthors = createLazyMemo(() => { const authors = Object.values(authorEntities()) switch (sortAllBy()) { case 'created': { - // log.debug('sorted by created') + log.debug('sorted by created') authors.sort(byCreated) break } case 'name': { - // log.debug('sorted by name') + log.debug('sorted by name') authors.sort((a, b) => a.name.localeCompare(b.name)) break }