This commit is contained in:
Igor Lobanov 2022-10-05 13:13:15 +02:00
parent 9350aee23f
commit 9a78c859ae
6 changed files with 15 additions and 16 deletions

View File

@ -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) =>

View File

@ -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<Author[]>([])
const { sortedAuthors } = useAuthorsStore({ authors: props.authors })
const [sortedKeys, setSortedKeys] = createSignal<string[]>([])
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 (
<div class="all-topics-page">
@ -86,7 +90,7 @@ export const AllAuthorsView = (props: Props) => {
fallback={() => (
<div class="stats">
<For each={sortedAuthors()}>
{(author: Author) => (
{(author) => (
<AuthorCard
author={author}
compact={false}
@ -99,7 +103,7 @@ export const AllAuthorsView = (props: Props) => {
)}
>
<For each={sortedKeys()}>
{(letter: string) => (
{(letter) => (
<div class="group">
<h2>{letter}</h2>
<div class="container">

View File

@ -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)
---

View File

@ -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')
---
<Zine>

View File

@ -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)
---

View File

@ -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
}