Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recommendations to landing page #91

Merged
merged 3 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pages/admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import Head from 'next/head'
import Link from 'next/link'
import { postData } from '../lib/utils'
import { useSession } from 'next-auth/react'
import { getColumns } from '../lib/db/columns'
import { Column } from '../types/Column'
import { Item } from '../types/Item'
import type { Column } from '../types/Column'
import type { Item } from '../types/Item'
import ItemBoard from '../components/boards/ItemBoard'
import { screenshotExists } from '../lib/db/itemScreenshots'
import DataBadge from '../components/data/DataBadge'
Expand Down Expand Up @@ -174,7 +173,7 @@ export async function getServerSideProps() {
)
return {
props: {
columns: await getColumns(),
columns: await getAllCache(Types.column),
itemsWithNoScreenshots: missingScreenshots.filter((s) => s !== null),
items: items,
popular: popular,
Expand Down
2 changes: 1 addition & 1 deletion pages/admin/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import UserBoard from '../../components/boards/UserBoard'
import { getAllCache } from '../../lib/db/cache'
import { Types } from '../../types/Components'
import useSWR from 'swr'
import { User } from '../../types/User'
import type { User } from '../../types/User'
import { faUsers } from '@fortawesome/free-solid-svg-icons/faUsers'

const Users = ({ users }: { users: User[] }) => {
Expand Down
15 changes: 7 additions & 8 deletions pages/collection/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { getCollections } from '../../lib/db/collections'
import Head from 'next/head'
import Link from 'next/link'
import Image from 'next/image'
import { useSession } from 'next-auth/react'
import { canEdit } from '../../lib/session'
import IconEdit from '../../components/icons/IconEdit'
import ItemBoard from '../../components/boards/ItemBoard'
import { getByUrlId } from '../../lib/db/db'
import ViewAllButton from '../../components/buttons/ViewAllButton'
import IconCollection from '../../components/icons/IconCollection'
import IconNSFW from '../../components/icons/IconNSFW'
Expand All @@ -15,11 +13,12 @@ import React, { FC } from 'react'
import { getAllCache } from '../../lib/db/cache'
import { Types } from '../../types/Components'
import useSWR from 'swr'
import { Collection } from '../../types/Collection'
import { Library } from '../../types/Library'
import { Item } from '../../types/Item'
import { Column } from '../../types/Column'
import type { Collection } from '../../types/Collection'
import type { Library } from '../../types/Library'
import type { Item } from '../../types/Item'
import type { Column } from '../../types/Column'
import DeleteButton from '../../components/buttons/DeleteButton'
import { getByUrlIdTyped } from '../../lib/db/dbTyped'

type Props = {
collection: Collection
Expand Down Expand Up @@ -163,7 +162,7 @@ const Collection: FC<Props> = ({
export default Collection

export async function getStaticPaths() {
const collections = await getCollections()
const collections = await getAllCache(Types.collection) as Collection[]
const paths = collections.map((collection) => {
return {
params: {
Expand All @@ -179,7 +178,7 @@ export async function getStaticPaths() {
}

export async function getStaticProps({ params }) {
const collection = await getByUrlId('collections', params.id)
const collection = await getByUrlIdTyped(Types.collection, params.id) as Collection
if (!collection) {
return {
notFound: true,
Expand Down
2 changes: 1 addition & 1 deletion pages/collections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Meta from '../components/layout/Meta'
import { getAllCache } from '../lib/db/cache'
import { Types } from '../types/Components'
import useSWR from 'swr'
import { Collection } from '../types/Collection'
import type { Collection } from '../types/Collection'

const title = 'Collections on ' + process.env.NEXT_PUBLIC_SITE_NAME
const description =
Expand Down
8 changes: 4 additions & 4 deletions pages/column/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Head from 'next/head'
import Link from 'next/link'
import { useSession } from 'next-auth/react'
import { canEdit } from '../../lib/session'
import { getByUrlId } from '../../lib/db/db'
import { getColumns } from '../../lib/db/columns'
import ItemCard from '../../components/cards/ItemCard'
import IconEdit from '../../components/icons/IconEdit'
Expand All @@ -16,10 +15,11 @@ import Meta from '../../components/layout/Meta'
import { getAllCache } from '../../lib/db/cache'
import useSWR from 'swr'
import { Types } from '../../types/Components'
import { Column, ColumnType } from '../../types/Column'
import { Item } from '../../types/Item'
import { type Column, ColumnType } from '../../types/Column'
import type { Item } from '../../types/Item'
import DeleteButton from '../../components/buttons/DeleteButton'
import { faFilter } from '@fortawesome/free-solid-svg-icons/faFilter'
import { getByUrlIdTyped } from '../../lib/db/dbTyped'

type Props = {
column: Column
Expand Down Expand Up @@ -160,7 +160,7 @@ export async function getStaticPaths() {
}

export async function getStaticProps({ params }) {
const column = await getByUrlId('columns', params.id)
const column = await getByUrlIdTyped(Types.column, params.id) as Column
if (!column) {
return {
notFound: true,
Expand Down
2 changes: 1 addition & 1 deletion pages/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Meta from '../components/layout/Meta'
import { getAllCache } from '../lib/db/cache'
import { Types } from '../types/Components'
import useSWR from 'swr'
import { Column } from '../types/Column'
import type { Column } from '../types/Column'

const title = 'All columns on ' + process.env.NEXT_PUBLIC_SITE_NAME
const description =
Expand Down
40 changes: 16 additions & 24 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@ import Link from 'next/link'
import { getLastViews } from '../lib/db/views'
import ItemCard from '../components/cards/ItemCard'
import CollectionCard from '../components/cards/CollectionCard'
import LibraryCard from '../components/cards/LibraryCard'
import Meta from '../components/layout/Meta'
import { getAllCache } from '../lib/db/cache'
import { Types } from '../types/Components'
import ViewAllButton from '../components/buttons/ViewAllButton'
import { Item } from '../types/Item'
import LibraryBoard from '../components/boards/LibraryBoard'
import { getAllTyped } from '../lib/db/dbTyped'

const description =
'The best places to stream your favorite anime shows online or download them for free and watch in sub or dub. Supports manga, light novels, hentai, and apps.'

export default function Home({ libraries }) {

export default function Home({ libraries, sponsors, columns }) {
try {
return (
<>
Expand All @@ -40,49 +37,43 @@ export default function Home({ libraries }) {
<div className={'row'}>
<div className={'col'}>
<h2 className={'mb-0'}>
Currently popular <Link href={'/libraries'}>libraries</Link>
Recommended <Link href={'/libraries'}>Libraries</Link>
</h2>
<div className={'mb-3 text-muted'}>
According to recent view counts
</div>
</div>

<div className={'col-auto'}>
<ViewAllButton type={Types.library} />
</div>
</div>
<div
className={'d-flex flex-wrap mb-4'}
style={{ marginRight: '-0.5rem' }}
>
{libraries.map((library) => {
return <LibraryCard library={library} key={library._id} />
})}
</div>
<LibraryBoard
contentOf={null}
libraries={libraries}
allLibraries={libraries}
canEdit={true}
/>


<div className={'row'}>
<div className={'col'}>
<h2 className={'mb-0'}>
Currently popular <Link href={'/items'}>items</Link>
Recommended <Link href={'/items'}>items</Link>
</h2>
<div className={'mb-3 text-muted'}>
According to recent view counts
</div>
</div>

<div className={'col-auto'}>
<ViewAllButton type={Types.item} />
</div>
</div>
<div
className={'d-flex flex-wrap mb-4'}
className='d-flex flex-wrap mb-4'
style={{ marginRight: '-0.5rem' }}
>
{items.map((item) => {
{sponsors.map((item) => {
return <ItemCard item={item} columns={columns} key={item._id} />
})}
</div>

{/*
<div className={'row'}>
<div className={'col'}>
<h2 className={'mb-0'}>
Expand Down Expand Up @@ -160,11 +151,12 @@ export async function getStaticProps() {

return {
props: {
libraries: await getAllTyped(Types.library)
libraries: await getAllCache(Types.library),
sponsors: sponsors,
//libraries: (await getLastViews(Types.library, 1000)).slice(0, 6),
//items: popular.slice(0, 9),
//collections: (await getLastViews(Types.collection, 1000)).slice(0, 9),
//columns: await getAllCache(Types.column),
columns: await getAllCache(Types.column),
},
revalidate: 600,
}
Expand Down
8 changes: 3 additions & 5 deletions pages/item/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Link from 'next/link'
import Image from 'next/image'
import { useSession } from 'next-auth/react'
import { canEdit, isAdmin, isEditor } from '../../lib/session'
import { getItem, getItems } from '../../lib/db/items'
import DataItem from '../../components/data/DataItem'
import IconEdit from '../../components/icons/IconEdit'
import DataBadge from '../../components/data/DataBadge'
Expand All @@ -19,15 +18,14 @@ import UrlBadge from '../../components/data/UrlBadge'
import { postData } from '../../lib/utils'
import Meta from '../../components/layout/Meta'
import React, { FC } from 'react'
import { getAllCache } from '../../lib/db/cache'
import { getAllCache, getSingleCache } from '../../lib/db/cache'
import { Types } from '../../types/Components'
import useSWR from 'swr'
import { Item } from '../../types/Item'
import { Column } from '../../types/Column'
import { Collection } from '../../types/Collection'
import DeleteButton from '../../components/buttons/DeleteButton'
import { faStar } from '@fortawesome/free-solid-svg-icons/faStar'
import { findOneTyped, getAllTyped } from '../../lib/db/dbTyped'

type Props = {
item: Item
Expand Down Expand Up @@ -360,7 +358,7 @@ const Item: FC<Props> = ({ item, columns, collections }) => {
export default Item

export async function getStaticPaths() {
const items = await getAllTyped(Types.item)
const items = await getAllCache(Types.item) as Item[]
const paths = items.map((i) => {
return {
params: {
Expand All @@ -376,7 +374,7 @@ export async function getStaticPaths() {
}

export async function getStaticProps({ params }) {
const item = await findOneTyped(Types.item, params.id) as Item
const item = await getSingleCache(Types.item, params.id) as Item
if (!item) {
return {
notFound: true,
Expand Down
4 changes: 2 additions & 2 deletions pages/items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Meta from '../components/layout/Meta'
import { getAllCache } from '../lib/db/cache'
import { Types } from '../types/Components'
import useSWR from 'swr'
import { Item } from '../types/Item'
import { Column } from '../types/Column'
import type { Item } from '../types/Item'
import type { Column } from '../types/Column'

const title = 'Items on ' + process.env.NEXT_PUBLIC_SITE_NAME
const description =
Expand Down
2 changes: 1 addition & 1 deletion pages/libraries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Meta from '../components/layout/Meta'
import { getAllCache } from '../lib/db/cache'
import { Types } from '../types/Components'
import useSWR from 'swr'
import { Library } from '../types/Library'
import type { Library } from '../types/Library'

const title = 'Libraries on ' + process.env.NEXT_PUBLIC_SITE_NAME
const description =
Expand Down
7 changes: 3 additions & 4 deletions pages/library/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import Head from 'next/head'
import Link from 'next/link'
import Image from 'next/image'
import { getLibraries } from '../../lib/db/libraries'
import { useSession } from 'next-auth/react'
import { canEdit, isEditor } from '../../lib/session'
import IconEdit from '../../components/icons/IconEdit'
import CollectionBoard from '../../components/boards/CollectionBoard'
import { getByUrlId } from '../../lib/db/db'
import { getByUrlIdTyped } from '../../lib/db/dbTyped'
import IconLibrary from '../../components/icons/IconLibrary'
import ViewAllButton from '../../components/buttons/ViewAllButton'
import IconNSFW from '../../components/icons/IconNSFW'
Expand Down Expand Up @@ -173,7 +172,7 @@ const Library: FC<Props> = ({ library, collections, items, columns }) => {
export default Library

export async function getStaticPaths() {
const libraries = await getLibraries()
const libraries = await getAllCache(Types.library) as Library[]
const paths = libraries.map((library) => {
return {
params: {
Expand All @@ -189,7 +188,7 @@ export async function getStaticPaths() {
}

export async function getStaticProps({ params }) {
const library = (await getByUrlId('libraries', params.id)) as Library
const library = (await getByUrlIdTyped(Types.library, params.id)) as Library
if (!library) {
return {
notFound: true,
Expand Down
11 changes: 5 additions & 6 deletions pages/list/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useSession } from 'next-auth/react'
import { canEdit, isAdmin, isCurrentUser } from '../../lib/session'
import IconEdit from '../../components/icons/IconEdit'
import ItemBoard from '../../components/boards/ItemBoard'
import { getList } from '../../lib/db/lists'
import IconList from '../../components/icons/IconList'
import ViewAllButton from '../../components/buttons/ViewAllButton'
import IconNSFW from '../../components/icons/IconNSFW'
Expand All @@ -13,10 +12,10 @@ import React, { FC } from 'react'
import { getAllCache, getSingleCache } from '../../lib/db/cache'
import { Types } from '../../types/Components'
import useSWR from 'swr'
import { List } from '../../types/List'
import { User } from '../../types/User'
import { Item } from '../../types/Item'
import { Column } from '../../types/Column'
import type { List } from '../../types/List'
import type { User } from '../../types/User'
import type { Item } from '../../types/Item'
import type { Column } from '../../types/Column'
import DeleteButton from '../../components/buttons/DeleteButton'

type Props = {
Expand Down Expand Up @@ -127,7 +126,7 @@ const List: FC<Props> = ({ list, owner, allItems, columns }) => {
export default List

export async function getServerSideProps({ params }) {
const list = await getList(params.id)
const list = await getSingleCache(Types.list, params.id) as List
if (list === null) {
return {
notFound: true,
Expand Down
2 changes: 1 addition & 1 deletion pages/lists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Meta from '../components/layout/Meta'
import { getAllCache } from '../lib/db/cache'
import { Types } from '../types/Components'
import useSWR from 'swr'
import { List } from '../types/List'
import type { List } from '../types/List'

const title = 'All user lists on ' + process.env.NEXT_PUBLIC_SITE_NAME
const description =
Expand Down
5 changes: 2 additions & 3 deletions pages/user/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import ItemBoard from '../../components/boards/ItemBoard'
import Meta from '../../components/layout/Meta'
import React, { FC } from 'react'
import useSWR from 'swr'
import { getAllCache } from '../../lib/db/cache'
import { getAllCache, getSingleCache } from '../../lib/db/cache'
import { Types } from '../../types/Components'
import type { User } from '../../types/User'
import type { List } from '../../types/List'
import type { Item } from '../../types/Item'
import type { Column } from '../../types/Column'
import { faCog } from '@fortawesome/free-solid-svg-icons/faCog'
import AccountTypeBadge from '../../components/badge/AccountTypeBadge'
import { findOneTyped } from '../../lib/db/dbTyped'

type Props = {
user: User
Expand Down Expand Up @@ -217,7 +216,7 @@ const User: FC<Props> = ({ user, lists, items, columns }) => {
export default User

export async function getServerSideProps({ params }) {
const user = await findOneTyped(Types.user, params.id) as User
const user = await getSingleCache(Types.user, params.id) as User

if (!user) {
return {
Expand Down
Loading