resolve conflicts and add readme and correct pathnames

This commit is contained in:
ismailsosic
2023-03-09 18:16:23 +01:00
parent 38ce721f52
commit b6ef397899
31 changed files with 50 additions and 27 deletions

View File

@@ -1,24 +1,23 @@
import { AiOutlineLeft, AiOutlineRight } from 'react-icons/ai'
import Link from "next/link"
import { useRouter } from 'next/router'
import { ENV_VAR } from '../../../envconfig'
import { ENV_VAR } from '../../../../envconfig'
const result = ({data}) => {
const router = useRouter()
console.log(data)
const {book, writer, text} = data._source
const nextPageHandler = () => {
if(Number(data._id) + 1 === Number(data._source.numOfPages) + 1) return
if(Number(data._id) + 1 === Number(data._source.pages) + 1) return
router.push(`/${book.toLowerCase()}/${Number(data._id) + 1}`)
router.push(`/${data._index}/${data._type}/${Number(data._id) + 1}`)
}
const prevPageHandler = () => {
if(data._id - 1 === 0) return
router.push(`/${book.toLowerCase()}/${Number(data._id) - 1}`)
router.push(`/${data._index}/${data._type}/${Number(data._id) - 1}`)
}
return (
@@ -47,7 +46,7 @@ const result = ({data}) => {
"
>
<i className='rounded-3xl text-[#fff] px-3 py-auto' onClick={() => prevPageHandler()}><AiOutlineLeft size={25} /></i>
<p className="text-base tablet:text-2xl laptop:text-2xl text-[#fff] font-serif text-center">"{book}", {writer}, str.{data._id}</p>
<p className="text-base tablet:text-2xl laptop:text-2xl text-[#fff] font-serif text-center">"{book}", {writer}, str. {data._id}</p>
<i className='rounded-3xl text-[#fff] px-3 py-auto' onClick={() => nextPageHandler()}><AiOutlineRight size={25} /></i>
</div>
<div className='page flex laptop:justify-center laptop:min-w-[100%]'>
@@ -82,9 +81,8 @@ export default result
export async function getServerSideProps (context) {
try{
const res = await fetch(`${ENV_VAR}library${context.resolvedUrl}`)
const res = await fetch(`${ENV_VAR}${context.resolvedUrl}`)
const data = await res.json()
return { props: {data} }
}
catch{err => console.log(err)}

View File

@@ -57,7 +57,7 @@ const SearchPage = ({data}) => {
export async function getServerSideProps(context) {
// Fetch data from external API
const res = await fetch(`${ENV_VAR}_search?q=${context.query.term}`)
const res = await fetch(`${ENV_VAR}/_search?q=${context.query.term}`)
const data = await res.json()
// Pass data to the page via props