mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-11 09:51:47 +00:00
Moves prettier and lint to root of the project (#143)
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
{
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"dev": "next dev",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -16,5 +13,8 @@
|
||||
"react-dom": "18.2.0",
|
||||
"react-modal": "^3.16.1",
|
||||
"react-syntax-highlighter": "^15.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "../styles/globals.css";
|
||||
import '../styles/globals.css';
|
||||
|
||||
export default function MyApp({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { useState } from "react"
|
||||
import Head from "next/head"
|
||||
import dynamic from "next/dynamic"
|
||||
import { useState } from 'react';
|
||||
import Head from 'next/head';
|
||||
import dynamic from 'next/dynamic';
|
||||
|
||||
import styles from "../styles/Home.module.css"
|
||||
import Image from "next/image"
|
||||
import styles from '../styles/Home.module.css';
|
||||
import Image from 'next/image';
|
||||
|
||||
const CodeSampleModal = dynamic(() => import("../components/CodeSampleModal"), {
|
||||
ssr: false
|
||||
})
|
||||
const CodeSampleModal = dynamic(() => import('../components/CodeSampleModal'), {
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
export default function Start({ countries }) {
|
||||
const [results, setResults] = useState(countries)
|
||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
||||
const [results, setResults] = useState(countries);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -46,29 +46,29 @@ export default function Start({ countries }) {
|
||||
placeholder="Country search..."
|
||||
className={styles.input}
|
||||
onChange={async (e) => {
|
||||
const { value } = e.currentTarget
|
||||
const { value } = e.currentTarget;
|
||||
// Dynamically load libraries
|
||||
const Fuse = (await import("fuse.js")).default
|
||||
const _ = (await import("lodash")).default
|
||||
const Fuse = (await import('fuse.js')).default;
|
||||
const _ = (await import('lodash')).default;
|
||||
|
||||
const fuse = new Fuse(countries, {
|
||||
keys: ["name"],
|
||||
threshold: 0.3
|
||||
})
|
||||
keys: ['name'],
|
||||
threshold: 0.3,
|
||||
});
|
||||
|
||||
const searchResult = fuse
|
||||
.search(value)
|
||||
.map((result) => result.item)
|
||||
.map((result) => result.item);
|
||||
|
||||
const updatedResults = searchResult.length
|
||||
? searchResult
|
||||
: countries
|
||||
setResults(updatedResults)
|
||||
: countries;
|
||||
setResults(updatedResults);
|
||||
|
||||
// Fake analytics hit
|
||||
console.info({
|
||||
searchedAt: _.now()
|
||||
})
|
||||
searchedAt: _.now(),
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -109,12 +109,12 @@ export default function Start({ countries }) {
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
const response = await fetch("https://restcountries.com/v3.1/all")
|
||||
const countries = await response.json()
|
||||
const response = await fetch('https://restcountries.com/v3.1/all');
|
||||
const countries = await response.json();
|
||||
|
||||
return {
|
||||
props: {
|
||||
@@ -123,6 +123,6 @@ export async function getServerSideProps() {
|
||||
cca2: country.cca2,
|
||||
population: country.population,
|
||||
})),
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,8 +2,19 @@ html,
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
|
||||
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||
font-family:
|
||||
Inter,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
Segoe UI,
|
||||
Roboto,
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
Fira Sans,
|
||||
Droid Sans,
|
||||
Helvetica Neue,
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
{
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"dev": "next dev",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -16,5 +13,8 @@
|
||||
"react-dom": "18.2.0",
|
||||
"react-modal": "^3.16.1",
|
||||
"react-syntax-highlighter": "^15.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "../styles/globals.css";
|
||||
import '../styles/globals.css';
|
||||
|
||||
export default function MyApp({ Component, pageProps }) {
|
||||
return <Component {...pageProps} />;
|
||||
|
||||
@@ -112,4 +112,4 @@ export async function getServerSideProps() {
|
||||
})),
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,19 @@ html,
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: Inter, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
|
||||
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||
font-family:
|
||||
Inter,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
Segoe UI,
|
||||
Roboto,
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
Fira Sans,
|
||||
Droid Sans,
|
||||
Helvetica Neue,
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
Reference in New Issue
Block a user