Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix #1909, add a better title to search results
Browse files Browse the repository at this point in the history
Update reactruntime so that changes to the model.title automatically get reflected in document.title
  • Loading branch information
ianb committed Nov 16, 2016
1 parent ce00f42 commit 09d0e6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/src/pages/shotindex/model.js
@@ -1,9 +1,14 @@
const { createProxyUrl } = require("../../proxy-url");

exports.createModel = function (req) {
let query = req.query.q;
let title = "My Shots";
if (query) {
title = `My Shots: search for ${query}`;
}
let serverModel = {
title: "My Shots",
defaultSearch: req.query.q || null
title,
defaultSearch: query || null
};
serverModel.shots = req.shots;
for (let shot of req.shots) {
Expand Down
4 changes: 4 additions & 0 deletions server/src/reactruntime.js
Expand Up @@ -82,6 +82,10 @@ exports.Page = class Page {
});
}
let body = this.BodyFactory(model);
let curTitle = document.title;
if (model.title && model.title != curTitle) {
document.title = model.title;
}
ReactDOM.render(
body,
document.getElementById("react-body-container"));
Expand Down

0 comments on commit 09d0e6e

Please sign in to comment.