Skip to content

Instantly share code, notes, and snippets.

View abedzantout's full-sized avatar
🌍
Hello World!

Abdul Rahman Zantout abedzantout

🌍
Hello World!
View GitHub Profile
@abedzantout
abedzantout / populate-contentful.js
Created September 19, 2019 16:02
Automatically populate Contentful
const authorFields = [
{
id: 'name',
name: 'Name',
type: 'Symbol',
required: true
},
{
id: 'title',
name: 'Job Title',
@abedzantout
abedzantout / contentful.ts
Last active September 24, 2019 18:24
Contentful API Integration
import { createClient } from 'contentful';
export const CONTENT_TYPE_BLOGPOST = 'blogPost';
export const CONTENT_TYPE_PERSON = 'author';
export const CONTENT_TYPE_TAGS = 'tag';
const Space = process.env.CONTENTFUL_SPACE;
const Token = process.env.CONTENTFUL_TOKEN;
export class ContentfulService {
@abedzantout
abedzantout / tag.ts
Last active September 21, 2019 12:03
Meta Tag Type
export enum PageType {
website = 'website',
article = 'article'
}
export enum RobotsContent {
follow = 'follow',
index = 'index',
no_follow = 'nofollow',
no_index = 'noindex'
@abedzantout
abedzantout / meta.tsx
Last active September 21, 2019 11:42
Meta Tag Component
import React, { Fragment, FunctionComponent } from 'react';
import Head from 'next/head';
import { MetaTags } from '../../../interfaces/meta-tags';
type Props = {
tags: MetaTags;
}
const Meta: FunctionComponent<Props> = ({tags}) => {
@abedzantout
abedzantout / layout.tsx
Last active September 21, 2019 11:36
Blog Layout without meta tags
import React, {FunctionComponent, Fragment, ReactNode} from 'react';
type Props = {
children: ReactNode;
}
const Layout: FunctionComponent<Props> = ({children}) => {
return (
<Fragment>
<div className="layout">
@abedzantout
abedzantout / card.tsx
Last active September 22, 2019 18:33
Card Component
import React, {FunctionComponent, Fragment} from 'react';
import Link from 'next/link';
import { getHref, getNavigationLink } from '../../helpers/helper';
import 'styles.css';
type Props = {
info: { id: string, title: string; description: string; heroImage: string; publishedAt: Date; slug: string }
}
.card {
display: flex;
flex-direction: column;
background-color: #fff;
border-radius: 4px;
border: 1px solid #e5e5e5;
overflow: hidden;
@abedzantout
abedzantout / next.config.js
Last active September 20, 2019 20:45
Next Config Final
// next.config.js
const withCSS = require('@zeit/next-css');
const path = require('path');
const Dotenv = require('dotenv-webpack');
const { generateAllArticles } = require('./utils/helpers');
const next_config = {
webpack: config => {
config.plugins = config.plugins || [];
@abedzantout
abedzantout / paginator.tsx
Last active July 27, 2023 01:39
Paginator
import React, {FunctionComponent, Fragment, useState, useEffect} from 'react';
import './styles.css';
type Props = {
skip?: number;
range: number[];
handlePaginationChange: Function;
}
const PaginatorComponent: FunctionComponent<Props> = ({skip, range, handlePaginationChange}) => {
skip = !!skip ? skip : 0;
.paginator {
display: flex;
justify-content: center;
align-content: center;
}
.paginator__page-number {
padding: 0.5rem 1rem;
margin: auto 0.5rem;