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) .slice(filename.indexOf(PATH_PREFIX) + PATH_PREFIX.length)
.replace('.module.scss', '') .replace('.module.scss', '')
.replace(/[/?\\]/g, '-') .replace(/[/?\\]/g, '-')
.replace('?', '-')
} }
const devGenerateScopedName = (name: string, filename: string, css: string) => 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 { useAuthorsStore } from '../../stores/zine/authors'
import { handleClientRouteLinkClick, useRouter } from '../../stores/router' import { handleClientRouteLinkClick, useRouter } from '../../stores/router'
import { useAuthStore } from '../../stores/auth' import { useAuthStore } from '../../stores/auth'
import { getLogger } from '../../utils/logger'
import '../../styles/AllTopics.scss' import '../../styles/AllTopics.scss'
const log = getLogger('AllAuthorsView')
type AllAuthorsPageSearchParams = { type AllAuthorsPageSearchParams = {
by: '' | 'name' | 'shouts' | 'rating' by: '' | 'name' | 'shouts' | 'rating'
} }
@ -19,8 +22,7 @@ type Props = {
} }
export const AllAuthorsView = (props: Props) => { export const AllAuthorsView = (props: Props) => {
const { sortedAuthors: authorList } = useAuthorsStore({ authors: props.authors }) const { sortedAuthors } = useAuthorsStore({ authors: props.authors })
const [sortedAuthors, setSortedAuthors] = createSignal<Author[]>([])
const [sortedKeys, setSortedKeys] = createSignal<string[]>([]) const [sortedKeys, setSortedKeys] = createSignal<string[]>([])
const [abc, setAbc] = createSignal([]) const [abc, setAbc] = createSignal([])
@ -33,17 +35,19 @@ export const AllAuthorsView = (props: Props) => {
createEffect(() => { createEffect(() => {
if ((!getSearchParams().by || getSearchParams().by === 'name') && abc().length === 0) { if ((!getSearchParams().by || getSearchParams().by === 'name') && abc().length === 0) {
console.log('[authors] default grouping by abc') console.log('[authors] default grouping by abc')
const grouped = { ...groupByName(authorList()) } const grouped = { ...groupByName(sortedAuthors()) }
grouped['A-Z'] = sortBy(grouped['A-Z'], byFirstChar) grouped['A-Z'] = sortBy(grouped['A-Z'], byFirstChar)
setAbc(grouped) setAbc(grouped)
const keys = Object.keys(abc) const keys = Object.keys(abc)
keys.sort() keys.sort()
setSortedKeys(keys as string[]) setSortedKeys(keys)
} else { } else {
console.log('[authors] sorting by ' + getSearchParams().by) console.log('[authors] sorting by ' + getSearchParams().by)
setSortedAuthors(sortBy(authorList(), getSearchParams().by)) ///setSortedAuthors(sortBy(authorList(), getSearchParams().by))
} }
}, [authorList(), getSearchParams().by]) })
log.debug(getSearchParams())
return ( return (
<div class="all-topics-page"> <div class="all-topics-page">
@ -86,7 +90,7 @@ export const AllAuthorsView = (props: Props) => {
fallback={() => ( fallback={() => (
<div class="stats"> <div class="stats">
<For each={sortedAuthors()}> <For each={sortedAuthors()}>
{(author: Author) => ( {(author) => (
<AuthorCard <AuthorCard
author={author} author={author}
compact={false} compact={false}
@ -99,7 +103,7 @@ export const AllAuthorsView = (props: Props) => {
)} )}
> >
<For each={sortedKeys()}> <For each={sortedKeys()}>
{(letter: string) => ( {(letter) => (
<div class="group"> <div class="group">
<h2>{letter}</h2> <h2>{letter}</h2>
<div class="container"> <div class="container">

View File

@ -4,7 +4,7 @@ import '../styles/app.scss'
import { t } from '../utils/intl' import { t } from '../utils/intl'
const lang = Astro.url.searchParams.get('lang') || 'ru' const lang = Astro.url.searchParams.get('lang') || 'ru'
// console.log('[layout] server locale is', lang) console.log('[layout] server locale is', lang)
setLocale(lang) setLocale(lang)
--- ---

View File

@ -8,8 +8,6 @@ const authors = await apiClient.getAllAuthors()
const { pathname, search } = Astro.url const { pathname, search } = Astro.url
initRouter(pathname, search) initRouter(pathname, search)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
--- ---
<Zine> <Zine>

View File

@ -6,8 +6,6 @@ import { initRouter } from '../stores/router'
const topics = await apiClient.getAllTopics() const topics = await apiClient.getAllTopics()
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')
const { pathname, search } = Astro.url const { pathname, search } = Astro.url
initRouter(pathname, search) initRouter(pathname, search)
--- ---

View File

@ -19,12 +19,12 @@ const sortedAuthors = createLazyMemo(() => {
const authors = Object.values(authorEntities()) const authors = Object.values(authorEntities())
switch (sortAllBy()) { switch (sortAllBy()) {
case 'created': { case 'created': {
// log.debug('sorted by created') log.debug('sorted by created')
authors.sort(byCreated) authors.sort(byCreated)
break break
} }
case 'name': { case 'name': {
// log.debug('sorted by name') log.debug('sorted by name')
authors.sort((a, b) => a.name.localeCompare(b.name)) authors.sort((a, b) => a.name.localeCompare(b.name))
break break
} }