Skip to content

Commit

Permalink
Add some <meta name="description" ...> to pages (#214)
Browse files Browse the repository at this point in the history
Not the best but probably better than the default (a good first iteration)

Part of #202
  • Loading branch information
MadLittleMods committed May 5, 2023
1 parent b108845 commit aeceb19
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions server/hydrogen-render/render-page-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function renderPageHtml({
assert(vmRenderContext);
assert(pageOptions);
assert(pageOptions.title);
assert(pageOptions.description);
assert(pageOptions.entryPoint);
assert(pageOptions.cspNonce);

Expand Down Expand Up @@ -45,6 +46,7 @@ function renderPageHtml({
<meta name="viewport" content="width=device-width, initial-scale=1">
${maybeNoIndexHtml}
${sanitizeHtml(`<title>${pageOptions.title}</title>`)}
${sanitizeHtml(`<meta name="description" content="${pageOptions.description}">`)}
<link rel="icon" href="${faviconMap.ico}" sizes="any">
<link rel="icon" href="${faviconMap.svg}" type="image/svg+xml">
${styles
Expand Down
1 change: 1 addition & 0 deletions server/middleware/timeout-middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ async function timeoutMiddleware(req, res, next) {

const pageOptions = {
title: `Server timeout - Matrix Public Archive`,
description: `Unable to respond in time (${requestTimeoutMs / 1000}s)`,
entryPoint: 'client/js/entry-client-timeout.js',
locationHref: urlJoin(basePath, req.originalUrl),
// We don't have a Matrix room so we don't know whether or not to index. Just choose
Expand Down
3 changes: 2 additions & 1 deletion server/routes/client-side-room-alias-hash-redirect-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ assert(basePath);
function clientSideRoomAliasHashRedirectRoute(req, res) {
const pageOptions = {
title: `Page not found - Matrix Public Archive`,
description: `This page does not exist but we may be able to redirect you to the right place.`,
entryPoint: 'client/js/entry-client-room-alias-hash-redirect.js',
locationHref: urlJoin(basePath, req.originalUrl),
// We don't have a Matrix room so we don't know whether or not to index. Just choose
Expand All @@ -30,7 +31,7 @@ function clientSideRoomAliasHashRedirectRoute(req, res) {
404: Page not found.
<span class="js-try-redirect-message" style="display: none">One sec while we try to redirect you to the right place.</span>
</h1>
<p>If there was a #room_alias:server hash in the URL, we tried redirecting you to the right place.</p>
<p>If there was a #room_alias:server hash in the URL, we tried redirecting you to the right place.</p>
<p>
Otherwise, you're simply in a place that does not exist.
You can ${sanitizeHtml(`<a href="${basePath}">go back to the homepage</a>.`)}
Expand Down
2 changes: 2 additions & 0 deletions server/routes/room-directory-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ router.get(

const pageOptions = {
title: `Matrix Public Archive`,
description:
'Browse thousands of rooms using Matrix. The new portal into the Matrix ecosystem.',
entryPoint: 'client/js/entry-client-room-directory.js',
locationHref: urlJoin(basePath, req.originalUrl),
shouldIndex,
Expand Down
1 change: 1 addition & 0 deletions server/routes/room-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ router.get(

const pageOptions = {
title: `${roomData.name} - Matrix Public Archive`,
description: `View the history of ${roomData.name} in the Matrix Public Archive`,
entryPoint: 'client/js/entry-client-hydrogen.js',
locationHref: urlJoin(basePath, req.originalUrl),
shouldIndex,
Expand Down

0 comments on commit aeceb19

Please sign in to comment.