mirror of
https://github.com/zyachel/quetre.git
synced 2025-04-03 04:57:37 +03:00
89 lines
5.1 KiB
Text
89 lines
5.1 KiB
Text
//-//////////////////////////////////////////////////////
|
|
//- INCLUDES/EXTENDS
|
|
//-//////////////////////////////////////////////////////
|
|
extends ../base
|
|
include ../mixins/_formatText
|
|
include ../mixins/_utils
|
|
include ../mixins/_answer
|
|
include ../mixins/_question
|
|
include ../mixins/_post
|
|
include ../mixins/_metadata
|
|
|
|
|
|
//-//////////////////////////////////////////////////////
|
|
//- MAIN CONTENT
|
|
//-//////////////////////////////////////////////////////
|
|
block content
|
|
main#main(class=`main search ${data.searchData ? '' :'search--no-results'}`)
|
|
-
|
|
const typesArr = [{key: 'question', text: 'Questions'}, {key: 'answer', text: 'Answers'}, {key: 'post', text: 'Posts'}, {key: 'profile', text: 'Profiles'}, {key: 'topic', text: 'Topics'}, {key: 'tribe', text: 'Spaces'}]
|
|
const timesArr = [{key: 'hour', text: 'Hour'}, {key: 'day', text: 'Day'}, {key: 'week', text: 'Week'}, {key: 'month', text: 'Month'}, {key: 'year', text: 'Year'}]
|
|
const languagesArr = ['en','es','fr','de','it','jp','id','pt','hi','nl','da','fi','nb','sv','mr','bn','ta','ar','he','gu','kn','ml','te','po'];
|
|
|
|
form.search__form.search-form(action="/search", method='get', autocomplete='off', name='search')
|
|
.search-form__search-container
|
|
input.search-form__searchbar(type="search", name="q", placeholder='Enter your query...', minlength='3', aria-label='search for anything')
|
|
button.search-form__button.search-form__button--reset(type="reset", aria-label='clear searchbar and filters'): svg.icon: use(href='/misc/sprite.svg#icon-cross')
|
|
button.search-form__button.search-form__button--submit(type="submit", aria-label='search'): svg.icon: use(href='/misc/sprite.svg#icon-search')
|
|
.search-form__filters-container.search-form__filters-container--type
|
|
p.search-form__filters-heading Filter by Type
|
|
each item in typesArr
|
|
.search-form__filters-group
|
|
input.search-form__radio.visually-hidden(type="radio", name="type", value=item.key, id=`type--${item.key}`)
|
|
label.search-form__label(for=`type--${item.key}`)= item.text
|
|
|
|
.search-form__filters-container.search-form__filters-container--time
|
|
p.search-form__filters-heading Filter by Time
|
|
each item in timesArr
|
|
.search-form__filters-group
|
|
input.search-form__radio.visually-hidden(type="radio", name='time', value=item.key, id=`time--${item.key}`)
|
|
label.search-form__label(for=`time--${item.key}`)= item.text
|
|
|
|
.search-form__filters-container.search-form__filters-container--lang
|
|
p.search-form__filters-heading Filter by Language
|
|
each lang in languagesArr
|
|
.search-form__filters-group
|
|
input.search-form__radio.visually-hidden(type="radio", name='lang', value=lang, id=`lang--${lang}`)
|
|
label.search-form__label(for=`lang--${lang}`)= lang.toUpperCase()
|
|
|
|
//- TODO: refactor 'profile', 'topic', and 'space' into resusable mixins.
|
|
- if (data.searchData?.results)
|
|
section.search__results.search-results
|
|
h1.heading.heading__primary= `Results for '${data.searchText}'`
|
|
- if (data.searchData.results.length === 0)
|
|
p No results found for the query. Try being less specific and/or removing filters.
|
|
- else
|
|
.search-results__container
|
|
each item in data.searchData.results
|
|
.search-results__item
|
|
- if (item.type === 'answer')
|
|
+addAnswer(item, true)
|
|
- else if (item.type === 'question')
|
|
+addQuestion(item)
|
|
- else if (item.type === 'post')
|
|
+addPost(item)
|
|
- else if (item.type === 'profile')
|
|
.metadata-primary
|
|
p.metadata-primary__heading
|
|
if item.isAnon
|
|
span Anonymous
|
|
else
|
|
a.link.metadata-primary__link(href=item.url)= item.name
|
|
if item.isVerified
|
|
svg.icon.metadata-primary__icon
|
|
title verified
|
|
use(href='/misc/sprite.svg#icon-verified')
|
|
+proxifyImg(item.image)(class='metadata-primary__image', alt='', aria-hidden='true')
|
|
p.metadata-primary__misc(aria-label=`${item.name}'s credentials`)= item.credential || ''
|
|
- else if (item.type === 'topic')
|
|
.metadata-primary
|
|
a.link.metadata-primary__heading(href=item.url)= item.name
|
|
+proxifyImg(item.image)(class='metadata-primary__image', aria-hidden='true', alt='')
|
|
p.metadata-primary__misc
|
|
+formatNumber(item.numFollowers)
|
|
| Followers
|
|
- else if (item.type === 'space')
|
|
.metadata-primary.profile-spaces__list-item
|
|
+proxifyImg(item.image)(class='metadata-primary__image', alt='', aria-hidden='true')
|
|
a.link.metadata-primary__heading(href=item.url)= item.name
|
|
p.metadata-primary__misc= item.description
|