I'm busy working on a website – somewhat new to this – and I don't quite know where I should store static data: in the public folder as a separate json file, or within the .js file as an object.
In the json file, it would look something like this:
{ "navLinks": [ {"title": "Home", "path": "/", "number":"one"}, {"title": "Projects", "path": "/projects", "number":"two"}, {"title": "Education", "path": "/education", "number":"three"}, {"title": "Blog", "path": "/blog", "number":"four"}, {"title": "Contact", "path": "/contact", "number":"five"} ] }
While in the .js file, it would be stored as an object somewhere outside of the React component:
import React from 'react'; import NavLink from './navlink'; import Burger from './burger'; import Link from 'next/link'; import { useState } from 'react'; import classNames from 'classnames'; const navLinks = { ... } function Logo({ children }) { return <div className="logo"> <Link href="/"> <a className="logo-link" href="">{children}</a> </Link> </div> } export default function Navbar({ navLinks }){ const [isShowNavList, setIsShowNavList] = useState(false); const toggleIsShowNavList = () => setIsShowNavList(!isShowNavList); const navListClassNames = classNames("nav-list"); return ( <nav className="navbar"> <Logo>Alé Pouroullis</Logo> <Burger isShowNavList={isShowNavList} toggleIsShowNavList={toggleIsShowNavList}/> <ul className={navListClassNames}> {navLinks.map((link, index) => { /* order will be used to stagger the animation of link content when in mobile view. It will be stored as an inline style variable in the <li> tags.*/ const order = index+1; return ( <NavLink onClick={toggleIsShowNavList} key={link.title} style={{"--order": order}} exact href={link.path} className="nav-link"> {link.title} </NavLink>) } )} </ul> </nav> ); }
module.exports = [...]
in'./navlist'
andimport navList from './navlist'
in your main file?