Skip to content

Commit

Permalink
Merge pull request #2060 from AshHimself/seo
Browse files Browse the repository at this point in the history
Problem: site cant be indexed by search engines
  • Loading branch information
anbud authored Oct 15, 2018
2 parents 84b9172 + 51e0a81 commit 63c4cfc
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 6 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ ostrio:cookies
email
meteorhacks:kadira
pauldowman:dotenv
ostrio:flow-router-meta
2 changes: 2 additions & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ [email protected]
[email protected]
ostrio:[email protected]
ostrio:[email protected]
ostrio:[email protected]
ostrio:[email protected]
ostrio:[email protected]
ostrio:[email protected]
pauldowman:[email protected]
Expand Down
15 changes: 11 additions & 4 deletions client/root.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<head>
<title>BLOCKRAZOR</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdnjs.cloudflare.com/ajax/libs/simple-line-icons/2.4.1/css/simple-line-icons.min.css" rel="stylesheet">
</head>
<title>BLOCKRAZOR</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdnjs.cloudflare.com/ajax/libs/simple-line-icons/2.4.1/css/simple-line-icons.min.css" rel="stylesheet">
<meta name="description" content="Absolutely all information about every blockchain project, presented in a way that anyone can understand." />
<meta property="og:type" content="website" />
<meta property="og:title" content="BLOCKRAZOR" />
<meta property="og:description" content="Absolutely all information about every blockchain project, presented in a way that anyone can understand." />
<meta property="og:site_name" content="BLOCKRAZOR" />
<meta property="og:url" content="http://blockrazor.org" />
<meta property="og:image" itemprop="image" content="https://pbs.twimg.com/profile_images/972399033506455552/yrJNink3_400x400.jpg" />
</head>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions server/server.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { WebApp } from 'meteor/webapp';
import { Currencies } from '/imports/api/coins/currencies.js'

const serverRendering = (req, res, next) => {
try {

const ua = req.headers['user-agent'];
const pathName = req._parsedUrl.pathname;
if (/bot|WhatsApp|facebook|twitter|pinterest|google|baidu|bing|msn|duckduckgo|teoma|slurp|yandex/i.test(ua)) {

// Send any non matches forward
if (!pathName.includes('/currency')) {
next();
}

var parts = req.url.split("/")

let currency = Currencies.findOne({
slug: parts[2]
})

let count = Currencies.find({
slug: parts[2]
}).count();

let meteorURL = 'https://blockrazor.org/' + parts[2]

if(count){

// Fetch the data you need to build your tags (and htmlContent)
const html = `
<!DOCTYPE html>
<!html>
<head>
<title>BlockRazor</title>
<meta name="description" content="Absolutely all information about every blockchain project, presented in a way that anyone can understand." />
<meta property="og:type" content="website"/>
<meta property="og:title" content="BlockRazor - ${currency.currencyName}"/>
<meta property="og:description" content="Absolutely all information about every blockchain project, presented in a way that anyone can understand."/>
<meta property="og:site_name" content="Saven"/>
<meta property="og:url" content="${meteorURL}"/>
</head>
<body>
Hello Bot, plz index us!
</body>
</html>
`;
res.statusCode = 200;
res.setHeader('Content-Type', 'text/html');
res.end(html);
}else{
console.log('can not get any content for some unknown reason, plz investigate : ( ')
}

} else {

next();
}
} catch (err) {
console.log(err);
}
}

// attach the handler to webapp
WebApp.connectHandlers.use(serverRendering);

0 comments on commit 63c4cfc

Please sign in to comment.