From dc16c13ca849ed4be5b4d1a539c3ab95f2c6c3b1 Mon Sep 17 00:00:00 2001 From: Vinay Puppal <me@vinaypuppal.com> Date: Mon, 6 Nov 2017 01:09:51 +0530 Subject: [PATCH 1/2] add proper metadata --- components/head.js | 13 ++++++++----- components/header.js | 14 ++++++++++---- config/meta-info.json | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 config/meta-info.json diff --git a/components/head.js b/components/head.js index b8d6d9505..c85ae2430 100644 --- a/components/head.js +++ b/components/head.js @@ -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 @@ -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> ); diff --git a/components/header.js b/components/header.js index af24d76c8..435715eae 100644 --- a/components/header.js +++ b/components/header.js @@ -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'; @@ -26,9 +27,10 @@ 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]; + console.log(title); + const metaData = MetaInfo[title]; + console.log(metaData); const navItems = [ { title: 'Home', @@ -64,7 +66,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> diff --git a/config/meta-info.json b/config/meta-info.json new file mode 100644 index 000000000..578de1dd0 --- /dev/null +++ b/config/meta-info.json @@ -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": "" + } +} From f5c55c14df655bc787b18991d69b1f35e6ed276e Mon Sep 17 00:00:00 2001 From: Vinay Puppal <me@vinaypuppal.com> Date: Mon, 6 Nov 2017 01:11:53 +0530 Subject: [PATCH 2/2] remove debug statements --- components/header.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/header.js b/components/header.js index 435715eae..fd37ad251 100644 --- a/components/header.js +++ b/components/header.js @@ -28,9 +28,7 @@ Router.onRouteChangeError = () => { export default props => { const title = props.url.pathname === '/' ? 'home' : props.url.pathname.split('/')[1]; - console.log(title); const metaData = MetaInfo[title]; - console.log(metaData); const navItems = [ { title: 'Home',