diff --git a/next.config.js b/next.config.js index a843cbe..dbb1049 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,9 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, -} + images: { + domains: ["beta.mejorconsalud.com"], + }, +}; module.exports = nextConfig diff --git a/pages/index.jsx b/pages/index.jsx index 619a237..bcabde0 100644 --- a/pages/index.jsx +++ b/pages/index.jsx @@ -1,17 +1,21 @@ +import Image from "next/image"; import Link from "next/link"; import { useState, useEffect } from "react"; import { useForm } from "react-hook-form"; -const statusFetch={ - pending:"pending", - resolved:"resolved", - idle:"idle", - found:"found", - notfound:"notfound", -} +const statusFetch = { + pending: "pending", + resolved: "resolved", + idle: "idle", + found: "found", + notfound: "notfound", +}; export default function Home() { - const [articles, setArticles] = useState({data:[], found: statusFetch.idle }); + const [articles, setArticles] = useState({ + data: [], + found: statusFetch.idle, + }); const [page, setPage] = useState(1); const { register, @@ -31,7 +35,9 @@ export default function Home() { let response = await fetch( `https://beta.mejorconsalud.com/wp-json/mc/v3/posts?search=${getValues( "article" - )}&orderby=relevance&page=${page}` + )}${ + getValues("relevant") ? `&orderby=${dataForm.relevant}` : "" + }&page=${page}` ); let data = await response.json(); setArticles({ ...data, found: statusFetch.found }); @@ -128,20 +134,43 @@ export default function Home() {

Ultimos articulos publicados

)} - {articles?.data && - articles.data.map((article) => { - return ( - - {article.title} - - ); - })} - - {/* {getValues("article").length > 0 && articles.found !== "pending" ? ( */} +
+ {articles?.data && + articles.data.map((article) => { + return ( +
+ + + +
+
+ {article.title} +
+

+ Some quick example text to build on the card title and make + up the bulk of the cards content. +

+ + Visitar + +
+
+ ); + })} +
{articles?.data.length > 0 && (