Browse Source

Feature/resolve blog post titles (#1539)

* Resolve blog post titles

* Update changelog
pull/1541/head
Thomas Kaul 2 years ago
committed by GitHub
parent
commit
c22733db56
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 18
      apps/api/src/app/frontend.middleware.ts
  3. 19
      apps/client/src/index.html

1
CHANGELOG.md

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added support to manage the tags in the create or edit activity dialog - Added support to manage the tags in the create or edit activity dialog
- Added the tags to the admin control panel - Added the tags to the admin control panel
- Added a blog post: _The importance of tracking your personal finances_ - Added a blog post: _The importance of tracking your personal finances_
- Resolved the title of the blog post
### Changed ### Changed

18
apps/api/src/app/frontend.middleware.ts

@ -3,8 +3,10 @@ import * as path from 'path';
import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; import { ConfigurationService } from '@ghostfolio/api/services/configuration.service';
import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config';
import { DATE_FORMAT } from '@ghostfolio/common/helper';
import { Injectable, NestMiddleware } from '@nestjs/common'; import { Injectable, NestMiddleware } from '@nestjs/common';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { format } from 'date-fns';
import { NextFunction, Request, Response } from 'express'; import { NextFunction, Request, Response } from 'express';
@Injectable() @Injectable()
@ -51,20 +53,26 @@ export class FrontendMiddleware implements NestMiddleware {
} }
public use(request: Request, response: Response, next: NextFunction) { public use(request: Request, response: Response, next: NextFunction) {
const currentDate = format(new Date(), DATE_FORMAT);
let featureGraphicPath = 'assets/cover.png'; let featureGraphicPath = 'assets/cover.png';
let title = 'Ghostfolio – Open Source Wealth Management Software';
if (request.path.startsWith('/en/blog/2022/08/500-stars-on-github')) { if (request.path.startsWith('/en/blog/2022/08/500-stars-on-github')) {
featureGraphicPath = 'assets/images/blog/500-stars-on-github.jpg'; featureGraphicPath = 'assets/images/blog/500-stars-on-github.jpg';
title = `500 Stars - ${title}`;
} else if (request.path.startsWith('/en/blog/2022/10/hacktoberfest-2022')) { } else if (request.path.startsWith('/en/blog/2022/10/hacktoberfest-2022')) {
featureGraphicPath = 'assets/images/blog/hacktoberfest-2022.png'; featureGraphicPath = 'assets/images/blog/hacktoberfest-2022.png';
title = `Hacktoberfest 2022 - ${title}`;
} else if (request.path.startsWith('/en/blog/2022/11/black-friday-2022')) { } else if (request.path.startsWith('/en/blog/2022/11/black-friday-2022')) {
featureGraphicPath = 'assets/images/blog/black-friday-2022.jpg'; featureGraphicPath = 'assets/images/blog/black-friday-2022.jpg';
title = `Black Friday 2022 - ${title}`;
} else if ( } else if (
request.path.startsWith( request.path.startsWith(
'/en/blog/2022/12/the-importance-of-tracking-your-personal-finances' '/en/blog/2022/12/the-importance-of-tracking-your-personal-finances'
) )
) { ) {
featureGraphicPath = 'assets/images/blog/20221226.jpg'; featureGraphicPath = 'assets/images/blog/20221226.jpg';
title = `The importance of tracking your personal finances - ${title}`;
} }
if ( if (
@ -77,7 +85,9 @@ export class FrontendMiddleware implements NestMiddleware {
} else if (request.path === '/de' || request.path.startsWith('/de/')) { } else if (request.path === '/de' || request.path.startsWith('/de/')) {
response.send( response.send(
this.interpolate(this.indexHtmlDe, { this.interpolate(this.indexHtmlDe, {
currentDate,
featureGraphicPath, featureGraphicPath,
title,
languageCode: 'de', languageCode: 'de',
path: request.path, path: request.path,
rootUrl: this.configurationService.get('ROOT_URL') rootUrl: this.configurationService.get('ROOT_URL')
@ -86,7 +96,9 @@ export class FrontendMiddleware implements NestMiddleware {
} else if (request.path === '/es' || request.path.startsWith('/es/')) { } else if (request.path === '/es' || request.path.startsWith('/es/')) {
response.send( response.send(
this.interpolate(this.indexHtmlEs, { this.interpolate(this.indexHtmlEs, {
currentDate,
featureGraphicPath, featureGraphicPath,
title,
languageCode: 'es', languageCode: 'es',
path: request.path, path: request.path,
rootUrl: this.configurationService.get('ROOT_URL') rootUrl: this.configurationService.get('ROOT_URL')
@ -95,7 +107,9 @@ export class FrontendMiddleware implements NestMiddleware {
} else if (request.path === '/it' || request.path.startsWith('/it/')) { } else if (request.path === '/it' || request.path.startsWith('/it/')) {
response.send( response.send(
this.interpolate(this.indexHtmlIt, { this.interpolate(this.indexHtmlIt, {
currentDate,
featureGraphicPath, featureGraphicPath,
title,
languageCode: 'it', languageCode: 'it',
path: request.path, path: request.path,
rootUrl: this.configurationService.get('ROOT_URL') rootUrl: this.configurationService.get('ROOT_URL')
@ -104,7 +118,9 @@ export class FrontendMiddleware implements NestMiddleware {
} else if (request.path === '/nl' || request.path.startsWith('/nl/')) { } else if (request.path === '/nl' || request.path.startsWith('/nl/')) {
response.send( response.send(
this.interpolate(this.indexHtmlNl, { this.interpolate(this.indexHtmlNl, {
currentDate,
featureGraphicPath, featureGraphicPath,
title,
languageCode: 'nl', languageCode: 'nl',
path: request.path, path: request.path,
rootUrl: this.configurationService.get('ROOT_URL') rootUrl: this.configurationService.get('ROOT_URL')
@ -113,7 +129,9 @@ export class FrontendMiddleware implements NestMiddleware {
} else { } else {
response.send( response.send(
this.interpolate(this.indexHtmlEn, { this.interpolate(this.indexHtmlEn, {
currentDate,
featureGraphicPath, featureGraphicPath,
title,
languageCode: DEFAULT_LANGUAGE_CODE, languageCode: DEFAULT_LANGUAGE_CODE,
path: request.path, path: request.path,
rootUrl: this.configurationService.get('ROOT_URL') rootUrl: this.configurationService.get('ROOT_URL')

19
apps/client/src/index.html

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html class="h-100 position-relative" lang="${languageCode}"> <html class="h-100 position-relative" lang="${languageCode}">
<head> <head>
<title>Ghostfolio – Open Source Wealth Management Software</title> <title>${title}</title>
<base href="/" /> <base href="/" />
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta content="yes" name="apple-mobile-web-app-capable" /> <meta content="yes" name="apple-mobile-web-app-capable" />
@ -20,28 +20,19 @@
name="twitter:description" name="twitter:description"
/> />
<meta content="${rootUrl}/${featureGraphicPath}" name="twitter:image" /> <meta content="${rootUrl}/${featureGraphicPath}" name="twitter:image" />
<meta <meta content="${title}" name="twitter:title" />
content="Ghostfolio – Open Source Wealth Management Software"
name="twitter:title"
/>
<meta <meta
content="initial-scale=1, viewport-fit=cover, width=device-width" content="initial-scale=1, viewport-fit=cover, width=device-width"
name="viewport" name="viewport"
/> />
<meta content="#FFFFFF" name="theme-color" /> <meta content="#FFFFFF" name="theme-color" />
<meta content="" property="og:description" /> <meta content="" property="og:description" />
<meta <meta content="${title}" property="og:title" />
content="Ghostfolio – Open Source Wealth Management Software"
property="og:title"
/>
<meta content="website" property="og:type" /> <meta content="website" property="og:type" />
<meta content="${rootUrl}${path}" property="og:url" /> <meta content="${rootUrl}${path}" property="og:url" />
<meta content="${rootUrl}/${featureGraphicPath}" property="og:image" /> <meta content="${rootUrl}/${featureGraphicPath}" property="og:image" />
<meta content="2022-10-16T00:00:00+00:00" property="og:updated_time" /> <meta content="${currentDate}T00:00:00+00:00" property="og:updated_time" />
<meta <meta content="${title}" property="og:site_name" />
content="Ghostfolio – Open Source Wealth Management Software"
property="og:site_name"
/>
<link <link
href="../assets/apple-touch-icon.png" href="../assets/apple-touch-icon.png"

Loading…
Cancel
Save