1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-13 00:10:37 +02:00

Chore: Fix website build (#11359)

This commit is contained in:
Henry Heino
2024-11-09 04:44:12 -08:00
committed by GitHub
parent 4a88d6ff7a
commit 3894c05217
5 changed files with 40 additions and 2 deletions

View File

@ -1,3 +1,4 @@
import { substrWithEllipsis } from '@joplin/lib/string-utils';
import { msleep } from '@joplin/utils/time';
import fetch from 'node-fetch';
@ -141,3 +142,16 @@ export const createPost = async (topicId: number, post: any): Promise<ForumTopic
export const updatePost = async (postId: number, content: any): Promise<void> => {
await execApi(HttpMethod.PUT, `posts/${postId}.json`, content);
};
export const trimPostToMaximumLength = (postBody: string) => {
// Discourse has a maximum post length of 65_000:
const maximumLength = 65_000;
if (postBody.length > maximumLength) {
return [
substrWithEllipsis(postBody, 0, maximumLength - 150),
'**Note**: The full content of this post is longer than permitted by Discourse.',
].join('\n\n');
}
return postBody;
};