mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
formatting comment text
This commit is contained in:
parent
1990783fa3
commit
59993f5beb
5 changed files with 27 additions and 4 deletions
|
@ -55,4 +55,13 @@ export const describeArc = (
|
|||
export const getURL = url => `${process.env.API_HOST}${url}`;
|
||||
|
||||
export const getImageSize = (image: string, size?: string): string =>
|
||||
`${process.env.API_HOST}${image}`;
|
||||
`${process.env.API_HOST}${image}`.replace('{size}', size);
|
||||
|
||||
export const formatCommentText = (author, text: string) =>
|
||||
text
|
||||
.replace(/(\n{2,})/gi, '\n')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.split('\n')
|
||||
.map((el, index) => (index === 0 ? `<p><b>${author}</b>: ${el}</p>` : `<p>${el}</p>`))
|
||||
.join('');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue