Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Add proper metadata #74

Merged
merged 2 commits into from
Nov 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions components/head.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Head from 'next/head';

export default ({ title }) => (
export default ({ title, description, image }) => (
<Head>
<meta charSet="utf-8" />
<meta
Expand Down Expand Up @@ -46,15 +46,18 @@ export default ({ title }) => (
href="https://cdn.rawgit.com/konpa/devicon/df6431e323547add1b4cf45992913f15286456d3/devicon.min.css"
/>
<title>{title}</title>
<meta name="description" content="coderplex" />
<meta name="description" content={description} />
<meta property="og:type" content="website" />
<meta property="og:title" content={title} />
<meta property="og:url" content="https://coderplex.org" />
<meta
property="og:image"
content="https://coderplex.org/static/favicons/android-chrome-512x512.png"
content={
image ||
'https://coderplex.org/static/favicons/android-chrome-512x512.png'
}
/>
<meta property="og:site_name" content="coderplex" />
<meta property="og:description" content="coderplex" />
<meta property="og:site_name" content="coderplex.org" />
<meta property="og:description" content={description} />
</Head>
);
12 changes: 8 additions & 4 deletions components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import GoStar from 'react-icons/lib/md/library-books';
import GoCalender from 'react-icons/lib/go/calendar';
import GoOrg from 'react-icons/lib/go/organization';

import MetaInfo from '../config/meta-info';
import GlobalStyles from './global-styles';
import Head from './head';

Expand All @@ -26,9 +27,8 @@ Router.onRouteChangeError = () => {

export default props => {
const title =
props.url.pathname === '/'
? 'Home'
: props.url.pathname.split('/')[1].toUpperCase();
props.url.pathname === '/' ? 'home' : props.url.pathname.split('/')[1];
const metaData = MetaInfo[title];
const navItems = [
{
title: 'Home',
Expand Down Expand Up @@ -64,7 +64,11 @@ export default props => {
return (
<Headroom>
<header>
<Head title={`${title} | Coderplex`} />
<Head
title={metaData.title}
description={metaData.description}
image={metaData.image}
/>
<GlobalStyles />
<div className="header__container">
<nav>
Expand Down
25 changes: 25 additions & 0 deletions config/meta-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"home": {
"title": "Coderplex | Learn, Collaborate and Create with a Community",
"description":
"We're a non-profit startup on a mission to improve the state of tech across India",
"image": ""
},
"learn": {
"title": "Free and Open Source Learning Guides | Coderplex",
"description":
"Curated guides with crowd-sourced recommendations of the best free online resources to learn various modern technologies",
"image": ""
},
"space": {
"title": "Offline Co-learning Spaces | Coderplex",
"description":
"A network of off-learning spaces for autodidacts to come and engage in peer-learning and collaboration",
"image": ""
},
"events": {
"title": "Online and Offline Tech Events | Coderplex",
"description": "We host frequent online and offline events, from sessions to competitions",
"image": ""
}
}