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 / pages.index.tsx
Last active April 6, 2022 04:29
Pages/index.tsx without the meta tags
import React, {useEffect, useState} from 'react';
import {NextPage} from 'next';
import {useRouter} from 'next/router'
import {ContentfulService} from '../core/contentful';
import {BlogPost} from '../interfaces/post';
import Layout from '../shared/components/layout';
import Card from '../shared/components/card';
@abedzantout
abedzantout / next.config.js
Created September 20, 2019 20:55
Next Config Initial File
// next.config.js
const withCSS = require('@zeit/next-css');
module.exports = withCSS({});
@abedzantout
abedzantout / next.config.js
Created September 20, 2019 20:30
Allowing next to read from our .env file
const path = require('path');
const Dotenv = require('dotenv-webpack');
const next_config = {
webpack: config => {
config.plugins = config.plugins || [];
config.plugins = [
...config.plugins,
// Read the .env file
import App from 'next/app';
import React from 'react';
import Router from 'next/router';
import {trackPageView} from '../core/gtag';
Router.events.on('routeChangeComplete', url => trackPageView(url));
class MyApp extends App {
render() {
import React, { Fragment } from 'react';
import Document, { Head, Main, NextScript } from 'next/document';
import { GA_TRACKING_ID } from '../core/gtag';
type Props = {
isProduction: boolean,
}
export default class extends Document<Props> {
static async getInitialProps(ctx) {
@abedzantout
abedzantout / gtag.ts
Created September 20, 2019 14:57
G tag page and event track
// Add your GA tracking id here
export const GA_TRACKING_ID = '';
const isProduction = process.env.NODE_ENV.toLowerCase() === 'production';
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
export const trackPageView = url => {
if (isProduction) {
// @ts-ignore
window.gtag('config', GA_TRACKING_ID, {
.paginator {
display: flex;
justify-content: center;
align-content: center;
}
.paginator__page-number {
padding: 0.5rem 1rem;
margin: auto 0.5rem;
@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;
@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 || [];
.card {
display: flex;
flex-direction: column;
background-color: #fff;
border-radius: 4px;
border: 1px solid #e5e5e5;
overflow: hidden;