-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add hooks * add isMounted * add Head * update text * fix image * fix props * fix head * fix image extension * fix url * update url
- Loading branch information
Showing
8 changed files
with
39 additions
and
23 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
import React from 'react' | ||
import { default as NextHead } from 'next/head' | ||
import { SITE_DESCRIPTION, SITE_NAME } from '../../utils/config' | ||
import { SITE_URL } from '../../utils/config' | ||
|
||
interface Props { | ||
title?: string | ||
description?: string | ||
} | ||
|
||
export function Head(props: Props) { | ||
export function Head({ title, description }: Props) { | ||
const origin = typeof window !== 'undefined' && window.location.origin ? window.location.origin : SITE_URL | ||
const img = `${origin}/huangshan.png` | ||
|
||
return ( | ||
<NextHead> | ||
<title>{props.title ?? SITE_NAME} </title> | ||
<meta property="og:url" content="https://genji.netlify.app/" /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="og:title" content={props.title ?? SITE_NAME} /> | ||
<meta name="twitter:card" content={SITE_DESCRIPTION} /> | ||
<meta property="og:description" content={props.description ?? SITE_DESCRIPTION} /> | ||
<meta property="og:image" content={'./public/huangshan.jpeg'} /> | ||
<meta name="description" content={props.description ?? SITE_DESCRIPTION} /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta property="og:title" content={title} /> | ||
<meta property="og:description" content={description} /> | ||
<meta property="og:image" content={img} /> | ||
<meta property="og:url" content={origin} /> | ||
<meta name="twitter:card" content={img} /> | ||
<meta name="twitter:site" content="@W3HC8" /> | ||
<meta name="twitter:title" content="Genji" /> | ||
<meta name="twitter:description" content={description} /> | ||
<meta name="twitter:image" content={img} /> | ||
</NextHead> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useState, useEffect } from 'react' | ||
|
||
export function useIsMounted(): boolean { | ||
let [isMounted, setIsMounted] = useState(false) | ||
|
||
useEffect(() => { | ||
setIsMounted(true) | ||
}, []) | ||
|
||
return isMounted | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
import type { AppProps } from 'next/app' | ||
import Layout from '../components/layout' | ||
import { useEffect, useState } from 'react' | ||
import { useEffect } from 'react' | ||
import { ChakraProvider } from '@chakra-ui/react' | ||
import { Seo } from '../components/layout/Seo' | ||
import { ERC20_CONTRACT_ADDRESS } from '../utils/erc20' | ||
import { useIsMounted } from '../hooks/useIsMounted' | ||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
const [ready, setReady] = useState(false) | ||
|
||
useEffect(() => { | ||
setReady(true) | ||
console.log('contract address:', ERC20_CONTRACT_ADDRESS) | ||
}, []) | ||
const isMounted = useIsMounted() | ||
|
||
return ( | ||
<> | ||
{ready ? ( | ||
<ChakraProvider> | ||
<Seo /> | ||
<ChakraProvider> | ||
<Seo /> | ||
{isMounted && ( | ||
<Layout> | ||
<Component {...pageProps} /> | ||
</Layout> | ||
</ChakraProvider> | ||
) : null} | ||
)} | ||
</ChakraProvider> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters