mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-22 04:11:15 +00:00
Change news item urls to /news, replace space with underscore
This commit is contained in:
parent
88c381712d
commit
8c056cfc10
3 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,7 @@ export class NewsItem extends Component<any, any> {
|
|||
|
||||
get markdown(): string {
|
||||
let title = decodeURIComponent(this.props.match.params.title);
|
||||
title = title.replace(/_/g, " ");
|
||||
return news_md.find(v => v.title == title).markdown;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ export class News extends Component<any, any> {
|
|||
<ul>
|
||||
{newsReversed.map(v => (
|
||||
<li>
|
||||
<Link to={`news_item/${v.title}`}>{v.title}</Link>
|
||||
<Link to={`news/${titleToUrl(v.title)}`}>{v.title}</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
@ -39,3 +39,7 @@ export class News extends Component<any, any> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
function titleToUrl(title: string): string {
|
||||
return title.replace(/ /g, "_");
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ export const routes: IRouteProps[] = [
|
|||
component: Releases,
|
||||
},
|
||||
{
|
||||
path: `/news_item/:title`,
|
||||
path: `/news/:title`,
|
||||
exact: true,
|
||||
component: NewsItem,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue