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