This Week In Web Design – September 11, 2020
Original Source: http://feedproxy.google.com/~r/1stwebdesigner/~3/uc7WI9GWNj4/
…
Original Source: http://feedproxy.google.com/~r/1stwebdesigner/~3/uc7WI9GWNj4/
…
Original Source: https://www.hongkiat.com/blog/dropbox-tools/
Dropbox is a useful cloud storage, but most users do not realize that it can be way more powerful if you know how to make the most use of it. If combined with the right services, Dropbox can do…
Visit hongkiat.com for full content.
Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/zNcq958WX94/gibberish-illustrations-and-doodles
‘Gibberish’ Illustrations and Doodles
AoiroStudio09.11.20
First of all, these are not ‘gibberish’ but that’s how ori toor humorously calls his playful, creative and beautiful illustration & doodle series. At first, I was even questioning why he calls it ‘Gibberish’ but just by reading his bio, you quickly understand why. Basically, Ori is a master of his craft at doodling sketches without any planning just improvising. This is something I dearly appreciate, it’s fun to just let go of things and let your mind go free to be creative. We are featuring his set titled: ‘Gibberish Dark Mode (And one light)’ but I would totally suggest you visit his Behance for more of his delightful style.
Links
http://www.oritoor.com
https://www.behance.net/oritoor
Original Source: http://feedproxy.google.com/~r/1stwebdesigner/~3/Ox4LMH-rGr4/
In this post, we’ve rounded up a collection of useful pure CSS code snippets for elements that are commonly used when designing and developing a website. We’ve included a few that may be less common, but might be useful for you if you are looking for a way to level up or add interest in your project.
From parallax to animations to tabs and accordions, this list should be helpful for you to refer to any time you are looking for accomplishing something in your web development utilizing only pure CSS and no JavaScript. So be sure to bookmark this page so you can refer to it next time you are looking for some guidance or inspiration.
Unlimited Web Template Downloads Starting at ONLY $16.50 per Month
Site Templates
2,000+ Site Templates
WordPress Themes
1,200+ WP Themes
Landing Pages
600+ Landing Pages
DOWNLOAD NOW
Slide Down Toggle
A clean and simple hidden panel that slides down smoothly when the button is clicked.
See the Pen Pure CSS Slide Down Toggle by Surjith (@surjithctly) on <a href=’https://codepen.io‘>CodePen.dark
Animated Gradient Background
Here’s a subtle animation effect where the background gradient slowly and endlessly changes.
See the Pen Pure CSS Gradient Background Animation by Manuel Pinto (@P1N2O) on <a href=’https://codepen.io‘>CodePen.dark
Parallax Star Background
A mesmerizing background with stars moving slowly through the night sky.
See the Pen Parallax Star background in CSS by Saransh Sinha (@saransh) on <a href=’https://codepen.io‘>CodePen.dark
Parallax Scrolling
Some may say that parallax has come and gone, but this cool pure CSS version makes a statement that you might want to utilize in your next project.
See the Pen Pure CSS Parallax Scrolling by Keith Clark (@keithclark) on <a href=’https://codepen.io‘>CodePen.dark
Form With SVG Radio Buttons
A simple form with radio buttons replaced with SVGs and a subtle animation.
See the Pen Form with SVG radio buttons by Angela Velasquez (@AngelaVelasquez) on <a href=’https://codepen.io‘>CodePen.dark
Hamburger Slide Out Menu
A handy, simple slide out menu that appears when the hamburger icon is clicked.
See the Pen Pure CSS Hamburger fold-out menu by Erik Terwan (@erikterwan) on <a href=’https://codepen.io‘>CodePen.dark
Custom Checkboxes
Nicely styled checkboxes that will give your forms a clean look.
See the Pen Pure CSS custom checkboxes by Glen Cheney (@Vestride) on <a href=’https://codepen.io‘>CodePen.dark
Popup Modal Window
How about a clean popup modal window that doesn’t use any JavaScript? Here’s one.
See the Pen Pure css popup box by Prakash (@imprakash) on <a href=’https://codepen.io‘>CodePen.dark
CSS Slider
A nice looking, smooth operating content slider with animations and navigation, all in pure CSS.
See the Pen Pure CSS Slider by Damian Drygiel (@drygiel) on <a href=’https://codepen.io‘>CodePen.dark
Glitched Text Animation
Here’s a cool glitch text animation effect that could work well for large headings.
See the Pen CSS Glitched Text by Lucas Bebber (@lbebber) on <a href=’https://codepen.io‘>CodePen.dark
Animated Gradient Ghost Button
Want to spruce up your buttons? Try this nice gradient animation.
See the Pen Animated Gradient Ghost Button Concept by Arsen Zbidniakov (@ARS) on <a href=’https://codepen.io‘>CodePen.dark
One Page Navigation Menu
This is a very clean, single page website with left navigation, where each page slides out from the right without refreshing the browser.
See the Pen One Page Navigation CSS Menu by Alberto Hartzet (@hrtzt) on <a href=’https://codepen.io‘>CodePen.dark
One Page Vertical Navigation
Similar to the previous snippet, and by the same author, this variation loads each page as a sliding panel from the bottom, along with keyboard navigation that syncs with the vertical menu.
See the Pen Pure CSS One page vertical navigation by Alberto Hartzet (@hrtzt) on <a href=’https://codepen.io‘>CodePen.dark
Image Slider
Another pure CSS image slider with a nifty animated transition between slides.
See the Pen CSS image slider w/ next/prev btns & nav dots by Avi Kohn (@AMKohn) on <a href=’https://codepen.io‘>CodePen.dark
Tabs
Need some easy to code/use CSS-only tabs in your next project? Here is a good example!
See the Pen Pure CSS Tabs by Wallace Erick (@wallaceerick) on CodePen.dark
Accordion
How about an accordion instead of tabs to display your content? Thought you couldn’t do it without JavaScript? Think again!
See the Pen Pure CSS Accordion by Rau (@raubaca) on <a href=’https://codepen.io‘>CodePen.dark
Direction-Aware Hover
Here’s a neat trick! Hover over the box from any side and it reveals something different based on which side you slid your cursor in from.
See the Pen Direction aware hover pure CSS by Fabrice W. (@FWeinb) on <a href=’https://codepen.io‘>CodePen.dark
Horizontal News Ticker
An old-school news ticker effect without any Javascript? Yes, it can be done!
See the Pen Pure CSS Ticker (Horizontal) by Lewis Carey (@lewismcarey) on <a href=’https://codepen.io‘>CodePen.dark
Multiline Text Cut Off With Ellipsis
This is a little specific, but still useful in the correct context. Perhaps you need equal height blog post excerpts. Do it with this pure CSS snippet.
See the Pen Pure CSS multiline text with ellipsis by Martin Wolf (@martinwolf) on <a href=’https://codepen.io‘>CodePen.dark
Toggle Buttons
Five clean looking animated toggle buttons.
See the Pen Pure CSS toggle buttons by Mauricio Allende (@mallendeo) on <a href=’https://codepen.io‘>CodePen.dark
Swanky Drop Down Menu
This is a really nice vertical drop down menu with great animations.
See the Pen Swanky Pure CSS Drop Down Menu V2.0 by Jamie Coulter (@jcoulterdesign) on <a href=’https://codepen.io‘>CodePen.dark
12 Loader Animations
Here are some useful spinners and loaders you can use for page load animations.
See the Pen Pure CSS Loaders kit by Viduthalai Mani (@viduthalai1947) on <a href=’https://codepen.io‘>CodePen.dark
Content Filter
A very handy, pure CSS content filter with a multitude of possible use cases.
See the Pen Pure CSS content filter by Sam Gordon (@samgordon) on <a href=’https://codepen.io‘>CodePen.dark
Swagtastic UI Stat Pop Out
A beautifully styled layout that could be used for statistics, a pricing table, or whatever your imagination comes up with.
See the Pen UI Statistic Pop Out CSS by Jamie Coulter (@jcoulterdesign) on <a href=’https://codepen.io‘>CodePen.dark
Folder Tree
A simple folder tree without any JavaScript.
See the Pen Pure CSS Tree by Rafael González (@rgg) on <a href=’https://codepen.io‘>CodePen.dark
Fancy Checkbox and Radio Buttons
Another variation on nicer than browser default checkbox and radio buttons.
See the Pen Pure CSS Fancy Checkbox/Radio by Rau (@raubaca) on <a href=’https://codepen.io‘>CodePen.dark
News Cards
This would be great for a blog post listing. Hover over a card to reveal the excerpt and read more link.
See the Pen News Cards – CSS only by Aleksandar Čugurović (@choogoor) on <a href=’https://codepen.io‘>CodePen.dark
Peeling Sticky
Here’s a fun animation of a label that peels off on hover. How could you use this one?
See the Pen Pure CSS Peeling Sticky by patrickkunka (@patrickkunka) on <a href=’https://codepen.io‘>CodePen.dark
Horizontal Hover Accordion
A nifty horizontal accordion that reveals content on hover.
See the Pen Pure CSS Horizontal Accordion by Aysha Anggraini (@rrenula) on <a href=’https://codepen.io‘>CodePen.dark
Funky Vertical Accordion
Another very nicely done vertical accordion with slick animations and zero JavaScript.
See the Pen Funky Pure CSS Accordion by Jamie Coulter (@jcoulterdesign) on CodePen.dark
Animated Toggles
Another set of toggles, this time in flat and 3D versions, with unique animations for each.
See the Pen Pure CSS Toggles by Rafael González (@rgg) on <a href=’https://codepen.io‘>CodePen.dark
Button Hover Animation
Spice up your buttons and links with this neat little hover animation effect.
See the Pen Button Hover by Katherine Kato (@kathykato) on <a href=’https://codepen.io‘>CodePen.dark
How will you use these handy pure CSS code snippets?
We hope you will find these pure CSS code snippets useful in your future projects, and hopefully we will save you some time next time you’re looking for any of these common elements to incorporate into your development.
Original Source: http://feedproxy.google.com/~r/tympanus/~3/0Bki41-yHfI/
Inspirational Website of the Week: MGcream
A fun design with a modern touch and some lovely details. Our pick this week.
Get inspired
This content is sponsored via Syndicate Ads
Website Heatmaps & Behaviour Analytics Tool
Understand how users are really experiencing your site without drowning in numbers!
Try it free
Parsel
Parsel is a tiny, permissive CSS selector parser by Lea Verou.
Check it out
react-three-flex
React-three-flex brings the flexbox spec to react-three-fiber to make it easier to place content. Check out this amazing demo. By Paul Henschel.
Check it out
REST API: Sorting, Filtering, and Pagination
In this great tutorial, Tania Rascia makes an example API endpoint and SQL query for various sort, paginate, and filter APIs.
Read it
Custom, accessible radio/checkbox buttons with perfect alignment
Learn how to create custom, accessible radio and checkbox buttons in CSS that perfectly align with their labels.
Check it out
How to pick more beautiful colors for your data visualizations
Lisa Charlotte Rost explains how to choose the right colors for your charts and visualizations.
Check it out
Alter
A creative 3D typeface exploration by Yuin Chien.
Check it out
AVIF has landed
Jake Archibald introduces the new AVIF image format that is derived from the keyframes of AV1 video.
Read it
Accessible Color Standards – Designing in the Browser
Una Kravets talks about color contrast in this new episode of “Designing in the Browser”.
Watch it
vanilla-colorful
A tiny color picker custom element for modern web apps. By Serhii Kulykov.
Check it out
Designing With Reduced Motion For Motion Sensitivities
An article by Val Head on how to use the prefers-reduced-motion-media feature.
Read it
How to build awesome forms with only HTML & CSS
A great Twitter thread by Arslan Khalid on how to build solid forms in a step-by-step manner.
Check it out
Candy Ring Preloader
A clever faux 3D ring preloader made by Jon Kantner.
Check it out
What is the Value of Browser Diversity?
Dave Rupert tries to answer a very important question.
Read it
DevTools architecture refresh: Migrating to JavaScript modules
The first article in a series of blog posts describing the changes the Chrome DevTools team is making to DevTools’ architecture and how it is built.
Read it
Duo
A really cool Three.js and GSAP demo by ycw. Check out this one, too.
Check it out
Read Me: Magazine
A fantastic Readymag essay (and template) on how to create good content and set it in type.
Check it out
How they test
A curated collection of publicly available resources on how software companies around the world test their software systems and build their quality culture.
Check it out
#s3e36 ALL YOUR HTML, Interactive Ribbon
A really good video tutorial by Yuri Artyukh where he dissects and builds an interactive WebGL ribbon.
Watch it
Education & LMS landing page design
A free landing page designed in Sketch with an educational theme.
Check it out
Responsive “Cool” Steps
Some fantastic step trickery by Jhey Tompkins.
Check it out
BLINK 3D Gallery
In case you haven’t seen this yet: BLINK is an online platform where art collectors, artists, and art lovers can meet and mingle to explore and enjoy art together.
Check it out
Styling Complex Labels
Danielle Romo’s tip on how to deal with more verbose input labels.
Read it
The post Collective #622 appeared first on Codrops.
Original Source: http://feedproxy.google.com/~r/abduzeedo/~3/DTmyxjanGuk/branding-full-visual-identity-la-mala-pub
Branding & Full Visual Identity for La Mala Pub
abduzeedo09.09.20
Estudio Nuar shared a beautiful branding project for La Mala Pub. Right in the heart of Palermo, La Mala Pub leads Buenos Aires nightlife. Only a few months after opening, it became so trending that generated the need for more space. In consequence, an extra space was attached and Malita was created. It was a joint work with the architecture team to design the new identity for this space and then generate all the graphic interventions and signage applications.
La Mala in Spanish means “Bad Girl” and that’s what triggered the visual imaginary, with all these really empowered girls, a bit vintage but updated with the vibrant colors, the contemporary phrases and the spacial mood, meaning she’s from outer space.
We created this multifaceted character who represents La Mala but also every girl who goes there. Apart from the posters, which are one of the main characters, we worked a lot on the neon signs, together with the architecture team, as they were very important taking into consideration it’s a night pub and the lighting is fundamental.
Credits
Creative Direction: Manuela Ventura y Melisa Rivas.
Architecture: Hitzig Militello Arquitectos.
Production: Crista Bernasconi.
Equipment: Krapa.
Design: Manuela Ventura, Melisa Rivas, Crista Bernasconi y Natasha Furst.
Photography: Federico Kulekdjian.
Animation: Malena Sueiro.
Original Source: http://feedproxy.google.com/~r/tympanus/~3/aujgmiRDX8U/
Inspirational Website of the Week: keysshoes
We love the fun layouts and diverse details! Our pick this week.
Get inspired
What is the Small Web?
Aral Balkan has a vision for the future where every person owns and controls their own place on the shared global network. He also introduces Site.js, a Small Web construction set.
Read it
ztext.js
Easy to implement, 3D typography for the web that works with every font.
Check it out
Our Sponsor
The Divi Summer Sale
Only 4 days left! Don’t miss your chance to get a 20% discount on the most powerful WordPress theme in the world.
Check it out
Umami
Umami is a simple, easy to use, self-hosted web analytics solution.
Check it out
The Thing With Leading in CSS
A must-read article by Matthias Ott on why design and implementation can look so different for vertical spaces between texts.
Read it
How to Use AVIF: The New Next-Gen Image Compression Format
Start using next-gen .avif images today progressively with the <picture> element. The format is ~50% smaller in size compared to JPEG, and ~20% smaller than WebP.
Building the Zig-Zag Gradient Lab
Michelle Barker shares the video and transcript of her talk at Vienna Calling about the Zig-Zag Gradient Lab.
Check it out
Use advanced typography with local fonts
Learn all about the Local Fonts API which enumerates the user’s installed local fonts and provides low-level access to the various TrueType/OpenType tables.
Read it
The difference between aria-label and aria-labelledby
Léonie Watson explains the difference between two important accessibility attributes.
Read it
Flume
In case you missed it: Flume is a React-powered node editor and runtime engine
Check it out
Best way to lazy load images for maximum performance
Adrian Bece shows the modern approach of lazy loading images.
Read it
Create blurred fills for images with aspect ratio containers in CSS
A very useful demo by Martijn Cuppens that shows how to automatically create blurred fills as background for images.
Check it out
Codemap
Codemap visualizes function calls in a intuitive way where you can navigate your code in a graph.
Check it out
Gradient Magic
A gallery of stylish and unique CSS gradients.
Check it out
#s3e35 ALL YOUR HTML, Moving through infinite clouds
A great tutorial where Yuri Artyukh shows how to implement the infinite clouds effect from the makingmaiselmarvelous.com site.
Watch it
A Tapestry of Tools
Daniel Eden on the effectiveness of using a variety of design tools.
Read it
Teal
With Teal you can build stateful and portable serverless applications quickly.
Check it out
handwritten.js
With this library you can convert typed text to an image of realistic handwriting.
Check it out
Why CSS Logical Properties Aren’t Ready for Use!
Elad Shechter explains why the new CSS logical properties module is not yet ready for prime time.
Read it
MergeURL
MergeURL helps you merge multiple URLs hassle-free without any user registration.
Check it out
Accordion Icons: Which Signifiers Work Best?
Page Laubheimer and Raluca Budiu looked at several possible icons as signifiers for accordions and found out which one works best.
Read it
Ct.js
In case you didn’t know about it: Ct.js is a free 2D game editor based on web technologies.
Check it out
CSS Shapes Layout Experiment
A funky shapes layout experiment by Kristopher Van Sant.
Check it out
Github Profile Readme Generator
Prettify your GitHub user profile with this readme generator.
Check it out
From Our Blog
Experimental Triangle Image Transitions with WebGL
Some experimental animations using triangles for image transitions with WebGL.
Check it out
From Our Blog
Awesome Demos Roundup #17
A fresh roundup of the most interesting and creative web experiments from the last couple of weeks.
Check it out
The post Collective #620 appeared first on Codrops.
Original Source: https://smashingmagazine.com/2020/09/build-blog-nextjs-mdx/
Next.js is a React framework that enables you to build static and dynamic apps quickly. It is production-ready and supports server-side rendering and static site generation out of the box, making Next.js apps fast and SEO-friendly.
In this tutorial, I will first explain what exactly Next.js is and why you’d use it instead of Create React App or Gatsby. Then, I’ll show you how to build a blog on which you can write and render posts using Next.js and MDX.
To get started, you’ll need some experience with React. Knowledge of Next.js would come handy but is not compulsory. This tutorial would benefit those who want to create a blog (personal or organizational) using Next.js or are still searching for what to use.
Let’s dive in.
What Is Next.js?
Next.js is a React framework created and maintained by Vercel. It’s built with React, Node.js, Babel, and Webpack. It is production-ready because it comes with a lot of great features that would usually be set up in a “vanilla” React app.
The Next.js framework can render apps on the server or export them statically. It doesn’t wait for the browser to load the JavaScript in order to show content, which makes Next.js apps SEO-friendly and blazing fast.
Why Use Next.js Over Create React App?
Create React App is a handy tool that offers a modern build setup with no configuration and without the hassle of having to set up Webpack, Babel, and so on or having to maintain their dependencies. It’s the recommended way to create React apps nowadays. It has a template for TypeScript and also comes with the React Testing Library.
However, if you want to build a multi-page app, then you’ll need to install an extra library, as if you were rendering a React app on the server. The extra setup could be a problem, and any packages installed could increase the final bundle size of your app.
This is exactly the problem that Next.js is intended to solve. It offers the best developer experience, with all of the things you need for production. It comes with several cool features:
Static exporting (pre-rendering)
Next.js allows you to export your Next.js app at build time to static HTML that runs without a server. It is the recommended way to generate your website because it’s done at build time and not at each request.
Server-side rendering (pre-rendering)
It pre-renders pages to HTML on the server upon every request.
Automatic code splitting
Unlike React, Next.js splits code automatically and only loads the JavaScript needed, which makes the app fast.
File-system-based routing
Next.js uses the file system to enable routing in the app, meaning that every file under the pages directory will be treated automatically as a route.
Hot reloading of code
Next.js relies on React Fast Refresh to hot reload your code, offering a great developer experience.
Styling options
The Next.js framework has built-in support for Styled JSX, CSS modules, Sass, LESS, and more.
Next.js Versus Gatsby
Gatsby is a static site generator built on top of React and GraphQL. It is popular and has a huge ecosystem that provides themes, plugins, recipes, and so on.
Gatsby and Next.js websites are super-fast because they are both rendered either on the server or statically, meaning that the JavaScript code does not wait for the browser to load. Let’s compare them according to the developer experience.
Gatsby is easy to start with, especially if you already know React. However, Gatsby uses GraphQL to query local data and pages. Using Gatsby to build this simple blog might be overkill because GraphQL has a learning curve, and the querying and build time of static pages would be a bit longer. If you built this same blog twice, first with Gatsby and then with Next.js, the one built with Next.js would be much faster at build time because it uses regular JavaScript to query local data and pages.
I hope you take advantage of the power of the Next.js framework and see why it’s so much handier than some alternatives. It’s also a great choice if your website relies heavily on SEO because your app will be fast and easy for Google robots to crawl. That’s the reason why we will be using Next.js in this article to build a blog with the MDX library.
Let’s start by setting up a new Next.js app.
Setting Up
There are two ways to create a Next.js app. We can set up a new app manually or use Create Next App. We’ll go for the latter because it’s the recommended way, and it will set up everything automatically for us.
To start a new app, run the following in the command-line interface (CLI):
npx create-next-app
Once the project is initialized, let’s structure the Next.js app as follows:
src
├── components
| ├── BlogPost.js
| ├── Header.js
| ├── HeadPost.js
| ├── Layout.js
| └── Post.js
├── pages
| ├── blog
| | ├── post-1
| | | └── index.mdx
| | ├── post-2
| | | └── index.mdx
| | └── post-3
| | └── index.mdx
| ├── index.js
| └── _app.js
├── getAllPosts.js
├── next.config.js
├── package.json
├── README.md
└── yarn.lock
As you can see, our project has a simple file structure. There are three things to note:
_app.js allows us to append some content to the App.js component in order to make it global.
getAllPosts.js helps us to retrieve the blog posts from the folder pages/blog. By the way, you can name the file whatever you want.
next.config.js is the configuration file for our Next.js app.
I will come back to each file later and explain what it does. For now, let’s see the MDX package.
Installing the MDX Library
MDX is a format that lets us seamlessly write JSX and import components into our Markdown files. It enables us to write regular Markdown and embed React components in our files as well.
To enable MDX in the app, we need to install the @mdx-js/loader library. To do so, let’s first navigate to the root of the project and then run this command in the CLI:
yarn add @mdx-js/loader
Or, if you’re using npm:
npm install @mdx-js/loader
Next, install @next/mdx, which is a library specific to Next.js. Run this command in the CLI:
yarn add @next/mdx
Or, for npm:
npm install @next/mdx
Great! We are done setting up. Let’s get our hands dirty and code something meaningful.
Configuring the next.config.js File
const withMDX = require(“@next/mdx”)({
extension: /.mdx?$/
});
module.exports = withMDX({
pageExtensions: [“js”, “jsx”, “md”, “mdx”]
});
Earlier in this tutorial, I said that files under the pages folder would be treated as pages/routes by Next.js at build time. By default, Next.js will just pick files with .js or .jsx extensions. That’s why we need a config file, to add some customizations to the default behavior of Next.js.
The next.config.js file tells the framework that files with .md or .mdx extensions should also be treated as pages/routes at build time because the blog folder that contains the articles lives in the pages directory.
That being said, we can start fetching the blog posts in the next part.
Fetching Blog Posts
One of the reasons why building a blog with Next.js is easy and simple is that you do not need GraphQL or the like to fetch local posts. You can just use regular JavaScript to get the data.
In getAllPosts.js:
function importAll(r) {
return r.keys().map((fileName) => ({
link: fileName.substr(1).replace(//index.mdx$/, “”),
module: r(fileName)
}));
}
export const posts = importAll(
require.context(“./pages/blog/”, true, /.mdx$/)
);
This file can be intimidating at first. It’s a function that imports all MDX files from the folder pages/blog, and for each post it returns an object with the path of the file, without the extension (/post-1), and the data of the blog post.
With that in place, we can now build the components in order to style and show data in our Next.js app.
Building The Components
In components/Layout.js:
import Head from “next/head”;
import Header from “./Header”;
export default function Layout({ children, pageTitle, description }) {
return (
<>
<Head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″ />
<meta charSet=”utf-8″ />
<meta name=”Description” content={description}></meta>
<title>{pageTitle}</title>
</Head>
<main>
<Header />
<div className=”content”>{children}</div>
</main>
</>
);
}
Here, we have the Layout component, which we’ll be using as a wrapper for the blog. It receives the meta data to show in the head of the page and the component to be displayed.
In components/Post.js:
import Link from ‘next/link’
import { HeadPost } from ‘./HeadPost’
export const Post = ({ post }) => {
const {
link,
module: { meta },
} = post
return (
<article>
<HeadPost meta={meta} />
<Link href={‘/blog’ + link}>
<a>Read more →</a>
</Link>
</article>
)
}
This component is responsible for displaying a preview of a blog post. It receives the post object to show as props. Next, we use destructuring to pull out the link of the post and the meta to show from the object. With that, we can now pass the data to the components and handle the routing with the Link component.
In components/BlogPost.js:
import { HeadPost } from ‘./HeadPost’
export default function BlogPost({ children, meta}) {
return (
<>
<HeadPost meta={meta} isBlogPost />
<article>{children}</article>
</>
)
}
The BlogPost component helps us to render a single article. It receives the post to show and its meta object.
So far, we have covered a lot — but we have no articles to show. Let’s fix that in the next section.
Writing Posts With MDX
import BlogPost from ‘../../../components/BlogPost’
export const meta = {
title: ‘Introduction to Next.js’,
description: ‘Getting started with the Next framework’,
date: ‘Aug 04, 2020’,
readTime: 2
}
export default ({ children }) => <BlogPost meta={meta}>{children}</BlogPost>;
## My Headline
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque maximus pellentesque dolor non egestas. In sed tristique elit. Cras vehicula, nisl vel ultricies gravida, augue nibh laoreet arcu, et tincidunt augue dui non elit. Vestibulum semper posuere magna, quis molestie mauris faucibus ut.
As you can see, we import the BlogPost component, which receives the meta and the body of the post.
The parameter children is the body of the blog post or, to be precise, everything that comes after the meta object. It is the function responsible for rendering the post.
With that change, we can move to the index.js file and display the posts on the home page.
Displaying Posts
import { Post } from “../components/Post”;
import { posts } from “../getAllPosts”;
export default function IndexPage() {
return (
<>
{posts.map((post) => (
<Post key={post.link} post={post} />
))}
</>
);
}
Here, we start by importing the Post component and the posts fetched from the blog folder. Next, we loop through the array of articles, and for each post, we use the Post component to display it. That being done, we are now able to fetch the posts and display them on the page.
We are almost done. However, the Layout component is still not being used. We can use it here and wrap our components with it. But that won’t affect the articles pages. That’s where the _app.js file comes into play. Let’s use that in the next section.
Using the _app.js File
Here, the underscore symbol (_) is really important. If you omit it, Next.js will treat the file as a page/route.
import Layout from “../components/Layout”;
export default function App({ Component, pageProps }) {
return (
<Layout pageTitle=”Blog” description=”My Personal Blog”>
<Component {…pageProps} />
</Layout>
);
}
Next.js uses the App component to initialize pages. The purpose of this file is to override it and add some global styles to the project. If you have styles or data that need to be shared across the project, put them here.
We can now browse the project folder in the CLI and run the following command to preview the blog in the browser:
yarn dev
Or, in npm:
npm run dev
If you open http://localhost:3000 in the browser, you will be able to see this:
Great! Our blog looks good. We are done building the blog app with Next.js and MDX.
Conclusion
In this tutorial, we walked through Next.js by building a blog using the MDX library. The Next.js framework is a handy tool that makes React apps SEO-friendly and fast. It can be used to build static, dynamic JAMstack websites in no time, because it is production-ready and comes with some nice features. Next.js is used widely by big companies, and its performance keeps improving. It’s definitely something to check out for your next project.
You can preview the finished project on CodeSandbox.
Thanks for reading!
Resources
These useful resources will take you beyond the scope of this tutorial.
Next.js documentation
Next.js and MDX documentation
“Create a Next.js App”, Next.js
Original Source: https://www.hongkiat.com/blog/vintage-tech-ads/
Still remember the good ol’ days with joysticks and bulky monitors? 1TB hard disks may now be a common sight, but did you know that people used to be excited over ads promoting 10MB hard disks?…
Visit hongkiat.com for full content.
Original Source: http://feedproxy.google.com/~r/1stwebdesigner/~3/kShm2tzcdrw/
…