From 8c056cfc10f46f25d3bf2114fa4c8def5300f322 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 7 Mar 2022 19:37:22 +0100 Subject: [PATCH] Change news item urls to /news, replace space with underscore --- src/shared/components/news-item.tsx | 1 + src/shared/components/news.tsx | 6 +++++- src/shared/routes.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/shared/components/news-item.tsx b/src/shared/components/news-item.tsx index 09e5b58..2cb0c68 100644 --- a/src/shared/components/news-item.tsx +++ b/src/shared/components/news-item.tsx @@ -19,6 +19,7 @@ export class NewsItem extends Component { get markdown(): string { let title = decodeURIComponent(this.props.match.params.title); + title = title.replace(/_/g, " "); return news_md.find(v => v.title == title).markdown; } diff --git a/src/shared/components/news.tsx b/src/shared/components/news.tsx index 84b1c78..7139da2 100644 --- a/src/shared/components/news.tsx +++ b/src/shared/components/news.tsx @@ -30,7 +30,7 @@ export class News extends Component {
    {newsReversed.map(v => (
  • - {v.title} + {v.title}
  • ))}
@@ -39,3 +39,7 @@ export class News extends Component { ); } } + +function titleToUrl(title: string): string { + return title.replace(/ /g, "_"); +} diff --git a/src/shared/routes.ts b/src/shared/routes.ts index 610ddcf..8d664a4 100644 --- a/src/shared/routes.ts +++ b/src/shared/routes.ts @@ -31,7 +31,7 @@ export const routes: IRouteProps[] = [ component: Releases, }, { - path: `/news_item/:title`, + path: `/news/:title`, exact: true, component: NewsItem, },