mirror of
https://github.com/uetchy/namae.git
synced 2025-03-18 04:50:32 +09:00
fix: limit 10 items
This commit is contained in:
parent
1031a70b0f
commit
d480d14100
@ -8,12 +8,12 @@ module.exports = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const term = encodeURIComponent(query)
|
const term = encodeURIComponent(query)
|
||||||
// const country = 'us'
|
const countryCode = country || 'us'
|
||||||
const limit = 3
|
const limit = 10
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://itunes.apple.com/search?media=software&entity=software,iPadSoftware,macSoftware&country=${country}&limit=${limit}&term=${term}`,
|
`https://itunes.apple.com/search?media=software&entity=software,iPadSoftware,macSoftware&country=${countryCode}&limit=${limit}&term=${term}`,
|
||||||
'GET'
|
'GET'
|
||||||
)
|
)
|
||||||
const body = await response.json()
|
const body = await response.json()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import useFetch from 'fetch-suspense'
|
import useFetch from 'fetch-suspense'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { FaAppStore } from 'react-icons/fa'
|
import { FaAppStore, FaInfoCircle } from 'react-icons/fa'
|
||||||
|
|
||||||
import { Card, Result } from '../Cards'
|
import { Card, Result } from '../Cards'
|
||||||
|
|
||||||
@ -15,15 +15,19 @@ function Search({ query }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{apps.map((app) => (
|
{apps.length > 0 ? (
|
||||||
<Result
|
apps.map((app) => (
|
||||||
title={app.name}
|
<Result
|
||||||
message={`Price: ${app.price}`}
|
title={app.name}
|
||||||
link={app.viewURL}
|
message={`Price: ${app.price}`}
|
||||||
icon={<FaAppStore />}
|
link={app.viewURL}
|
||||||
key={app.id}
|
icon={<FaAppStore />}
|
||||||
/>
|
key={app.id}
|
||||||
))}
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<Result title="No Result" icon={<FaInfoCircle />} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,33 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import useFetch from 'fetch-suspense'
|
import useFetch from 'fetch-suspense'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { FaGithub } from 'react-icons/fa'
|
import { FaGithub, FaInfoCircle } from 'react-icons/fa'
|
||||||
|
|
||||||
import { Card, Result } from '../Cards'
|
import { Card, Result } from '../Cards'
|
||||||
|
|
||||||
function Search({ query }) {
|
function Search({ query }) {
|
||||||
const searchQuery = encodeURIComponent(`${query} in:name`)
|
const searchQuery = encodeURIComponent(`${query} in:name`)
|
||||||
|
const limit = 10
|
||||||
const response = useFetch(
|
const response = useFetch(
|
||||||
`https://api.github.com/search/repositories?q=${searchQuery}&per_page=3`
|
`https://api.github.com/search/repositories?q=${searchQuery}&per_page=${limit}`
|
||||||
)
|
)
|
||||||
const repos = response.items
|
const repos = response.items
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{repos.map((repo) => (
|
{repos.length > 0 ? (
|
||||||
<Result
|
repos.map((repo) => (
|
||||||
title={repo.full_name}
|
<Result
|
||||||
message={`Star: ${repo.stargazers_count}`}
|
title={repo.full_name}
|
||||||
link={repo.html_url}
|
message={`Star: ${repo.stargazers_count}`}
|
||||||
icon={<FaGithub />}
|
link={repo.html_url}
|
||||||
key={repo.id}
|
icon={<FaGithub />}
|
||||||
/>
|
key={repo.id}
|
||||||
))}
|
/>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<Result title="No Result" icon={<FaInfoCircle />} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user