0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 14:22:52 +00:00

Changed page title to show homebrew title whenever possible

This commit is contained in:
Rodrigo Kuerten
2020-10-25 13:52:02 -03:00
parent 6309ec0bfa
commit b908cd7cbd
2 changed files with 21 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
module.exports = async (name, props={})=>{ module.exports = async(name, title = "", props = {}) => {
return ` return `
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@@ -7,7 +7,7 @@ module.exports = async (name, props={})=>{
<link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" /> <link href="//fonts.googleapis.com/css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css" />
<link href=${`/${name}/bundle.css`} rel='stylesheet'></link> <link href=${`/${name}/bundle.css`} rel='stylesheet'></link>
<link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" /> <link rel="icon" href="/assets/homebrew/favicon.ico" type="image/x-icon" />
<title>The Homebrewery - NaturalCrit</title> <title>${title.length ? title + " - The Homebrewery": "The Homebrewery - NaturalCrit"}</title>
</head> </head>
<body> <body>
<main id="reactRoot">${require(`../build/${name}/ssr.js`)(props)}</main> <main id="reactRoot">${require(`../build/${name}/ssr.js`)(props)}</main>
@@ -16,4 +16,4 @@ module.exports = async (name, props={})=>{
<script>start_app(${JSON.stringify(props)})</script> <script>start_app(${JSON.stringify(props)})</script>
</html> </html>
`; `;
}; };

View File

@@ -208,23 +208,23 @@ app.get('/source/:id', (req, res)=>{
//Render the page //Render the page
//const render = require('.build/render'); //const render = require('.build/render');
const templateFn = require('./client/template.js'); const templateFn = require('./client/template.js');
app.use((req, res)=>{ app.use((req, res) => {
const props = { const props = {
version : require('./package.json').version, version: require('./package.json').version,
url : req.originalUrl, url: req.originalUrl,
welcomeText : welcomeText, welcomeText: welcomeText,
changelog : changelogText, changelog: changelogText,
brew : req.brew, brew: req.brew,
brews : req.brews, brews: req.brews,
googleBrews : req.googleBrews, googleBrews: req.googleBrews,
account : req.account, account: req.account,
}; };
templateFn('homebrew', props) templateFn('homebrew', title = req.brew ? req.brew.title : "", props)
.then((page)=>{res.send(page);}) .then((page) => { res.send(page); })
.catch((err)=>{ .catch((err) => {
console.log(err); console.log(err);
return res.sendStatus(500); return res.sendStatus(500);
}); });
}); });