Skip to content

Commit

Permalink
feat: define customFilter based on tt_publish_at data in fsxa.config
Browse files Browse the repository at this point in the history
  • Loading branch information
p-runge committed Mar 15, 2022
1 parent e7f1fc1 commit d31d2a0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion fsxa.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CustomFilter } from 'fsxa-api/dist/types'

export default {
devMode: false,
defaultLocale: 'de_DE',
Expand All @@ -9,5 +11,18 @@ export default {
loader: '~/components/fsxa/Loader',
page404: '~/components/fsxa/Page404'
},
customRoutes: '~/customRoutes'
customRoutes: '~/customRoutes',
customFilter: ((items) =>
items.filter((item) => {
if (typeof item === 'object' && 'data' in (item as object)) {
const publishAt: string | undefined = (item as Record<'data', any>).data
.tt_publish_at
const published =
!publishAt || new Date(publishAt).getTime() - Date.now() <= 0

return published
}

return true
})) as CustomFilter
}

0 comments on commit d31d2a0

Please sign in to comment.