Skip to content

Commit

Permalink
Move headlines to home
Browse files Browse the repository at this point in the history
  • Loading branch information
jahooma committed Jun 25, 2024
1 parent e890e94 commit c25a31f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 1 addition & 25 deletions web/pages/explore.tsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
import { Page } from 'web/components/layout/page'
import { useRedirectIfSignedOut } from 'web/hooks/use-redirect-if-signed-out'
import { useUser } from 'web/hooks/use-user'
import { api } from 'web/lib/firebase/api'
import { Headline } from 'common/news'
import { HeadlineTabs } from 'web/components/dashboard/header'
import { LoadingIndicator } from 'web/components/widgets/loading-indicator'
import { useSaveScroll } from 'web/hooks/use-save-scroll'
import { Col } from 'web/components/layout/col'
import { LiveGeneratedFeed } from 'web/components/feed/live-generated-feed'

export async function getStaticProps() {
try {
const headlines = await api('headlines', {})
return {
props: {
headlines,
revalidate: 30 * 60, // 30 minutes
},
}
} catch (err) {
return { props: { headlines: [] }, revalidate: 60 }
}
}

export default function Explore(props: { headlines: Headline[] }) {
export default function Explore() {
useRedirectIfSignedOut()
const user = useUser()
useSaveScroll('explore')

const { headlines } = props
return (
<Page
trackPageView={'home'}
trackPageProps={{ kind: 'desktop' }}
className=" !mt-0"
banner={null}
>
<HeadlineTabs
endpoint={'news'}
headlines={headlines}
currentSlug={'home'}
hideEmoji
/>
{!user ? (
<LoadingIndicator />
) : (
Expand Down
26 changes: 25 additions & 1 deletion web/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,38 @@ import { useUser } from 'web/hooks/use-user'
import { track } from 'web/lib/service/analytics'
import { GroupPageContent } from '../browse/[[...slug]]'
import { useSaveReferral } from 'web/hooks/use-save-referral'
import { api } from 'web/lib/firebase/api'
import { Headline } from 'common/news'
import { HeadlineTabs } from 'web/components/dashboard/header'

export default function Home() {
export async function getStaticProps() {
try {
const headlines = await api('headlines', {})
return {
props: {
headlines,
revalidate: 30 * 60, // 30 minutes
},
}
} catch (err) {
return { props: { headlines: [] }, revalidate: 60 }
}
}

export default function Home(props: { headlines: Headline[] }) {
const user = useUser()
useSaveReferral(user)
const { headlines } = props

return (
<Page trackPageView={'home'} className="!mt-0">
<SEO title={`Home`} description={`Browse all questions`} url={`/home`} />
<HeadlineTabs
endpoint={'news'}
headlines={headlines}
currentSlug={'home'}
hideEmoji
/>
{user && (
<DailyStats
className="bg-canvas-50 z-50 mb-1 w-full px-2 py-2"
Expand Down

0 comments on commit c25a31f

Please sign in to comment.