mirror of
https://github.com/LemmyNet/joinlemmy-site.git
synced 2024-11-25 13:51:17 +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 {
|
get markdown(): string {
|
||||||
let title = decodeURIComponent(this.props.match.params.title);
|
let title = decodeURIComponent(this.props.match.params.title);
|
||||||
|
title = title.replace(/_/g, " ");
|
||||||
return news_md.find(v => v.title == title).markdown;
|
return news_md.find(v => v.title == title).markdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class News extends Component<any, any> {
|
||||||
<ul>
|
<ul>
|
||||||
{newsReversed.map(v => (
|
{newsReversed.map(v => (
|
||||||
<li>
|
<li>
|
||||||
<Link to={`news_item/${v.title}`}>{v.title}</Link>
|
<Link to={`news/${titleToUrl(v.title)}`}>{v.title}</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</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,
|
component: Releases,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `/news_item/:title`,
|
path: `/news/:title`,
|
||||||
exact: true,
|
exact: true,
|
||||||
component: NewsItem,
|
component: NewsItem,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue