10 | Keep up to date with the latest web dev news
11 |
12 |
13 | )
14 | }
15 |
16 | export default Header
17 |
--------------------------------------------------------------------------------
/components/Layout.js:
--------------------------------------------------------------------------------
1 | import Nav from './Nav'
2 | import Meta from './Meta'
3 | import Header from './Header'
4 | import styles from '../styles/Layout.module.css'
5 |
6 | const Layout = ({ children }) => {
7 | return (
8 | <>
9 |
10 |
11 |
12 |
13 |
14 | {children}
15 |
16 |
17 | >
18 | )
19 | }
20 |
21 | export default Layout
22 |
--------------------------------------------------------------------------------
/components/Meta.js:
--------------------------------------------------------------------------------
1 | import Head from 'next/head'
2 |
3 | const Meta = ({ title, keywords, description }) => {
4 | return (
5 |
6 |
7 |
8 |
9 |
10 |
11 | {title}
12 |
13 | )
14 | }
15 |
16 | Meta.defaultProps = {
17 | title: 'WebDev Newz',
18 | keywords: 'web development, programming',
19 | description: 'Get the latest news in web dev',
20 | }
21 |
22 | export default Meta
23 |
--------------------------------------------------------------------------------
/components/Nav.js:
--------------------------------------------------------------------------------
1 | import Link from 'next/link'
2 | import navStyles from '../styles/Nav.module.css'
3 |
4 | const Nav = () => {
5 | return (
6 |
16 | )
17 | }
18 |
19 | export default Nav
20 |
--------------------------------------------------------------------------------
/config/index.js:
--------------------------------------------------------------------------------
1 | const dev = process.env.NODE_ENV !== 'production'
2 |
3 | export const server = dev ? 'http://localhost:3000' : 'https://yourwebsite.com'
4 |
--------------------------------------------------------------------------------
/data.js:
--------------------------------------------------------------------------------
1 | export const articles = [
2 | {
3 | id: '1',
4 | title: 'GitHub introduces dark mode and auto-merge pull request',
5 | excerpt:
6 | 'GitHub today announced a bunch of new features at its virtual GitHub...',
7 | body:
8 | 'GitHub today announced a bunch of new features at its virtual GitHub Universe conference including dark mode, auto-merge pull requests, and Enterprise Server 3.0. In the past couple of years, almost all major apps have rolled out a dark theme for its users, so why not GitHub?',
9 | },
10 | {
11 | id: '2',
12 | title: 'What’s multi-cloud? And why should developers care?',
13 | excerpt: 'Most developers don’t care about multi-cloud. But they should...',
14 | body:
15 | 'Most developers don’t care about multi-cloud. But they should. Whether developers know it or not, their companies likely already have a multi-cloud environment. Multi-cloud is a strategy where a business selects different services from different cloud providers',
16 | },
17 | {
18 | id: '3',
19 | title: 'Here is how to make your website more accessible',
20 | excerpt:
21 | 'An accessible website is one that’s optimized for all people, including those with disabilities...',
22 | body:
23 | 'There are many things to consider when setting up a website, and accessibility is one factor that can sometimes be overlooked. An accessible website is one that’s optimized for all people, including those with impaired vision or hearing, motor difficulties, or learning disabilities',
24 | },
25 | {
26 | id: '4',
27 | title: 'Why open ecosystems are the future of app development',
28 | excerpt:
29 | 'When app stores entered the mainstream tech culture, they exposed developers to an audience of millions...',
30 | body:
31 | 'We can’t get enough of our mobile apps. There were 204 billion apps downloads last year, and that number is rising in 2020. When app stores entered the mainstream tech culture, they exposed developers to an audience of millions who were keen to adopt the innovative capabilities',
32 | },
33 | ]
34 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "next-crash-course",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next dev",
7 | "build": "next build && next export",
8 | "start": "next start"
9 | },
10 | "dependencies": {
11 | "next": "10.0.5",
12 | "react": "17.0.1",
13 | "react-dom": "17.0.1"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/pages/_app.js:
--------------------------------------------------------------------------------
1 | import Layout from '../components/Layout'
2 | import '../styles/globals.css'
3 |
4 | function MyApp({ Component, pageProps }) {
5 | return (
6 |
7 |
8 |
9 | )
10 | }
11 |
12 | export default MyApp
13 |
--------------------------------------------------------------------------------
/pages/_document.js:
--------------------------------------------------------------------------------
1 | import Document, { Html, Head, Main, NextScript } from 'next/document'
2 |
3 | class MyDocument extends Document {
4 | render() {
5 | return (
6 |
7 |
9 |
10 |
11 |
12 |
13 | )
14 | }
15 | }
16 |
17 | export default MyDocument
18 |
--------------------------------------------------------------------------------
/pages/about.js:
--------------------------------------------------------------------------------
1 | import Meta from '../components/Meta'
2 |
3 | const about = () => {
4 | return (
5 |
6 |
7 |
About
8 |
9 | )
10 | }
11 |
12 | export default about
13 |
--------------------------------------------------------------------------------
/pages/api/articles/[id].js:
--------------------------------------------------------------------------------
1 | import { articles } from '../../../data'
2 |
3 | export default function handler({ query: { id } }, res) {
4 | const filtered = articles.filter((article) => article.id === id)
5 |
6 | if (filtered.length > 0) {
7 | res.status(200).json(filtered[0])
8 | } else {
9 | res
10 | .status(404)
11 | .json({ message: `Article with the id of ${id} is not found` })
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/pages/api/articles/index.js:
--------------------------------------------------------------------------------
1 | import { articles } from '../../../data'
2 |
3 | export default function handler(req, res) {
4 | res.status(200).json(articles)
5 | }
6 |
--------------------------------------------------------------------------------
/pages/article/[id]/index.js:
--------------------------------------------------------------------------------
1 | import { server } from '../../../config'
2 | import Link from 'next/link'
3 | import { useRouter } from 'next/router'
4 | import Meta from '../../../components/Meta'
5 |
6 | const article = ({ article }) => {
7 | // const router = useRouter()
8 | // const { id } = router.query
9 |
10 | return (
11 | <>
12 |
13 |