@@ -49,6 +49,7 @@ export default function TopHeader ({ sub, cat }) {
onChange={(formik, e) => top({ ...formik?.values, what: e.target.value })}
name='what'
size='sm'
+ overrideValue={what}
items={router?.query?.sub ? ['posts', 'comments'] : ['posts', 'comments', 'stackers', 'cowboys']}
/>
{cat !== 'cowboys' &&
@@ -59,6 +60,7 @@ export default function TopHeader ({ sub, cat }) {
onChange={(formik, e) => top({ ...formik?.values, by: e.target.value })}
name='by'
size='sm'
+ overrideValue={by}
items={cat === 'stackers' ? USER_SORTS : ITEM_SORTS}
/>
for
@@ -67,6 +69,7 @@ export default function TopHeader ({ sub, cat }) {
onChange={(formik, e) => top({ ...formik?.values, when: e.target.value })}
name='when'
size='sm'
+ overrideValue={when}
items={WHENS}
/>
>}
diff --git a/components/usage-header.js b/components/usage-header.js
index adf1b448..ae9200de 100644
--- a/components/usage-header.js
+++ b/components/usage-header.js
@@ -1,27 +1,23 @@
import { useRouter } from 'next/router'
-import { Form, Select } from './form'
+import { Select } from './form'
import { WHENS } from '../lib/constants'
export function UsageHeader () {
const router = useRouter()
return (
-
+
+ stacker analytics for
+
)
}
diff --git a/components/user-list.js b/components/user-list.js
index 3a79a433..582da750 100644
--- a/components/user-list.js
+++ b/components/user-list.js
@@ -40,12 +40,12 @@ export default function UserList ({ ssrData, query, variables, destructureData }
const [statComps, setStatComps] = useState(seperate(STAT_COMPONENTS, Seperator))
useEffect(() => {
- if (variables.by) {
+ if (variables?.by) {
// shift the stat we are sorting by to the front
const comps = [...STAT_COMPONENTS]
setStatComps(seperate([...comps.splice(STAT_POS[variables.by], 1), ...comps], Seperator))
}
- }, [variables.by])
+ }, [variables?.by])
const { users, cursor } = useMemo(() => {
if (!data && !ssrData) return {}
diff --git a/lib/md.js b/lib/md.js
index 3fec8173..1084e274 100644
--- a/lib/md.js
+++ b/lib/md.js
@@ -26,8 +26,6 @@ export function extractUrls (md) {
mdastExtensions: [gfmFromMarkdown()]
})
- console.log('tree', tree)
-
const urls = new Set()
visit(tree, ({ type }) => {
return type === 'link' || type === 'image'
diff --git a/pages/[name]/[type].js b/pages/[name]/[type].js
index 32f14d61..7612642c 100644
--- a/pages/[name]/[type].js
+++ b/pages/[name]/[type].js
@@ -41,9 +41,9 @@ function UserItemsHeader ({ type, name }) {
async function select (values) {
let { type, ...query } = values
- if (!type || !ITEM_TYPES('user').includes(type)) type = 'all'
- if (!query.by || !ITEM_SORTS.includes(query.by)) delete query.by
- if (!query.when || !WHENS.includes(query.when) || query.when === 'forever') delete query.when
+ if (!type || type === 'all' || !ITEM_TYPES('user').includes(type)) type = 'all'
+ if (!query.by || query.by === 'recent' || !ITEM_SORTS.includes(query.by)) delete query.by
+ if (!query.when || query.when === 'forever' || !WHENS.includes(query.when) || query.when === 'forever') delete query.when
await router.push({
pathname: `/${name}/${type}`,
@@ -51,13 +51,13 @@ function UserItemsHeader ({ type, name }) {
})
}
+ type ||= router.query.type || 'all'
+ const by = router.query.by || 'recent'
+ const when = router.query.when || 'forever'
+
return (