Defining artists per page with env variable
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
PORT=3000
|
||||
API_URL=http://localhost:1337
|
||||
NEXT_PUBLIC_API_URL=$API_URL
|
||||
|
||||
NEXT_PUBLIC_AWTIS_POU_CHAK_PAJ=6
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const OKI_API = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:1337'
|
||||
const AWTIS_POU_CHAK_PAJ = process.env.NEXT_PUBLIC_AWTIS_POU_CHAK_PAJ || 6
|
||||
|
||||
export async function getAwtis() {
|
||||
const response = await axios.get(`${OKI_API}/awtis`)
|
||||
@@ -13,8 +14,8 @@ export async function jwennAwtisKantite() {
|
||||
}
|
||||
|
||||
export async function jwennAwtisPajinasyon(paj) {
|
||||
const start = 8 * (paj - 1)
|
||||
const query = `_sort=alias:ASC&_start=${start}&_limit=8`
|
||||
const start = AWTIS_POU_CHAK_PAJ * (paj - 1)
|
||||
const query = `_sort=alias:ASC&_start=${start}&_limit=${AWTIS_POU_CHAK_PAJ}`
|
||||
|
||||
const response = await axios.get(`${OKI_API}/awtis?${query}`)
|
||||
return response.data
|
||||
|
||||
+3
-1
@@ -7,6 +7,8 @@ import Navigasyon from '../components/navigasyon'
|
||||
import AwtisKat from '../components/awtis/awtis-kat'
|
||||
import Pajinasyon from '../components/awtis/pajinasyon'
|
||||
|
||||
const AWTIS_POU_CHAK_PAJ = process.env.NEXT_PUBLIC_AWTIS_POU_CHAK_PAJ || 6
|
||||
|
||||
export default function Awtis({pajTotal, awtisPouChakPaj, paj}) {
|
||||
return (
|
||||
<>
|
||||
@@ -34,7 +36,7 @@ export async function getServerSideProps({query}) {
|
||||
const awtisPouChakPaj = await jwennAwtisPajinasyon(pajParsed)
|
||||
const awtisCountRequest = await jwennAwtisKantite()
|
||||
const awtisCount = Number.parseInt(awtisCountRequest, 10)
|
||||
const pajTotal = Math.ceil(awtisCount / 8)
|
||||
const pajTotal = Math.ceil(awtisCount / AWTIS_POU_CHAK_PAJ)
|
||||
|
||||
if (pajParsed > pajTotal) {
|
||||
throw new Error('Pa twouvé paj-la')
|
||||
|
||||
Reference in New Issue
Block a user