search all territories by default + more intuitive search filters
This commit is contained in:
parent
f2ba61e64b
commit
bfe5edcfe3
|
@ -7,14 +7,16 @@ function queryParts (q) {
|
|||
|
||||
const queryArr = q.replace(regex, '').trim().split(/\s+/)
|
||||
const url = queryArr.find(word => word.startsWith('url:'))
|
||||
const nym = queryArr.find(word => word.startsWith('nym:'))
|
||||
const exclude = [url, nym]
|
||||
const nym = queryArr.find(word => word.startsWith('@'))
|
||||
const territory = queryArr.find(word => word.startsWith('~'))
|
||||
const exclude = [url, nym, territory]
|
||||
const query = queryArr.filter(word => !exclude.includes(word)).join(' ')
|
||||
|
||||
return {
|
||||
quotes: [...q.matchAll(regex)].map(m => m[1]),
|
||||
nym,
|
||||
url,
|
||||
territory,
|
||||
query
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +171,7 @@ export default {
|
|||
items
|
||||
}
|
||||
},
|
||||
search: async (parent, { q, sub, cursor, sort, what, when, from: whenFrom, to: whenTo }, { me, models, search }) => {
|
||||
search: async (parent, { q, cursor, sort, what, when, from: whenFrom, to: whenTo }, { me, models, search }) => {
|
||||
const decodedCursor = decodeCursor(cursor)
|
||||
let sitems = null
|
||||
let termQueries = []
|
||||
|
@ -193,7 +195,7 @@ export default {
|
|||
break
|
||||
}
|
||||
|
||||
const { query: _query, quotes, nym, url } = queryParts(q)
|
||||
const { query: _query, quotes, nym, url, territory } = queryParts(q)
|
||||
let query = _query
|
||||
|
||||
const isUrlSearch = url && query.length === 0 // exclusively searching for an url
|
||||
|
@ -206,11 +208,11 @@ export default {
|
|||
}
|
||||
|
||||
if (nym) {
|
||||
whatArr.push({ wildcard: { 'user.name': `*${nym.slice(4).toLowerCase()}*` } })
|
||||
whatArr.push({ wildcard: { 'user.name': `*${nym.slice(1).toLowerCase()}*` } })
|
||||
}
|
||||
|
||||
if (sub) {
|
||||
whatArr.push({ match: { 'sub.name': sub } })
|
||||
if (territory) {
|
||||
whatArr.push({ match: { 'sub.name': territory.slice(1) } })
|
||||
}
|
||||
|
||||
termQueries.push({
|
||||
|
|
|
@ -16,7 +16,7 @@ export default function HiddenWalletSummary ({ abbreviate, fixedWidth }) {
|
|||
return (
|
||||
<span
|
||||
ref={ref} style={{ width: fixedWidth ? width : undefined }}
|
||||
className='d-inline-block text-monospace' align='right' onPointerEnter={() => setHover(true)} onPointerLeave={() => setHover(false)}
|
||||
className='text-monospace' align='right' onPointerEnter={() => setHover(true)} onPointerLeave={() => setHover(false)}
|
||||
>
|
||||
{hover ? (abbreviate ? abbrNum(me.privates?.sats) : numWithUnits(me.privates?.sats, { abbreviate: false, format: true })) : '******'}
|
||||
</span>
|
||||
|
|
|
@ -70,7 +70,7 @@ export function Back () {
|
|||
|
||||
return (
|
||||
<a
|
||||
role='button' tabIndex='0' className='nav-link p-0 me-3' onClick={() => {
|
||||
role='button' tabIndex='0' className='nav-link p-0 me-2' onClick={() => {
|
||||
if (back) {
|
||||
router.back()
|
||||
} else {
|
||||
|
|
|
@ -21,8 +21,6 @@ export default function StickyBar ({ prefix, sub, path, topNavKey, dropNavKey })
|
|||
}
|
||||
}, [ref?.current, sticky?.current])
|
||||
|
||||
if (path.endsWith('/search')) return null
|
||||
|
||||
return (
|
||||
<>
|
||||
<div ref={ref} style={{ position: 'relative', top: '50px' }} />
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
.searchSection {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
border-bottom: 1px solid var(--theme-toolbarActive);
|
||||
background-color: var(--bs-body-bg);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.searchContainer {
|
||||
position: relative;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.search {
|
||||
|
|
|
@ -177,7 +177,7 @@ module.exports = withPlausibleProxy()({
|
|||
source: '/~:sub/:slug*',
|
||||
destination: '/~/:slug*?sub=:sub'
|
||||
},
|
||||
...['/', '/post', '/search', '/rss', '/recent/:slug*', '/top/:slug*'].map(source => ({ source, destination: '/~' + source }))
|
||||
...['/', '/post', '/rss', '/recent/:slug*', '/top/:slug*'].map(source => ({ source, destination: '/~' + source }))
|
||||
]
|
||||
},
|
||||
async redirects () {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { getGetServerSideProps } from '@/api/ssrApollo'
|
|||
import { useRouter } from 'next/router'
|
||||
import { SUB_SEARCH } from '@/fragments/subs'
|
||||
import Items from '@/components/items'
|
||||
import styles from './search.module.css'
|
||||
import styles from '@/styles/search.module.css'
|
||||
|
||||
export const getServerSideProps = getGetServerSideProps({
|
||||
query: SUB_SEARCH,
|
||||
|
@ -31,16 +31,16 @@ export default function Index ({ ssrData }) {
|
|||
<div className={styles.box}>
|
||||
<div className={styles.header}>
|
||||
<div className='text-muted text-center' style={{ fontFamily: 'lightning', fontSize: '2rem', opacity: '0.75' }}>
|
||||
more filters
|
||||
filters
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.body}>
|
||||
<div className={styles.inner}>
|
||||
<div><b>nym:</b>​<em>sn</em> - limit results by stacker nym</div>
|
||||
<div><b>url:</b>​<em>stacker​.news</em> - limit to specific site</div>
|
||||
<div><b>"</b>exact phrase<b>"</b> - demand results contain exact phrase</div>
|
||||
<div>you are searching <em>{variables.sub || 'home'}</em><br /><em>home</em> searches show results from all</div>
|
||||
</div>
|
||||
<ul className={styles.inner}>
|
||||
<li><b>@</b>​<em>nym</em> - limit to results authored by nym</li>
|
||||
<li><b>~</b>​<em>territory</em> - limit to results from territory</li>
|
||||
<li><b>url:</b>​<em>stacker​.news</em> - limit to link posts from a specific url</li>
|
||||
<li><b>"</b><em>exact phrase</em><b>"</b> - limit to results that contain an exact phrase</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -7,7 +7,6 @@
|
|||
.box {
|
||||
border: 1px solid var(--theme-borderColor);
|
||||
border-radius: 10px;
|
||||
box-shadow: 2px 2px 10px var(--theme-borderColor);
|
||||
min-width: 50%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -20,10 +19,13 @@
|
|||
align-self: center;
|
||||
}
|
||||
.inner {
|
||||
padding: 0.5rem 0;
|
||||
padding-right: 2rem;
|
||||
padding-bottom: 1rem;
|
||||
padding-top: 1rem;
|
||||
padding-inline-start: 3rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.inner > div {
|
||||
padding: 5px 2rem;
|
||||
.inner > li {
|
||||
padding: 0.25rem 0;
|
||||
}
|
Loading…
Reference in New Issue