Updated data-generator to create lexical rather than mobiledoc posts

closes https://linear.app/tryghost/issue/ONC-96

- better matches Ghost's current usage
- avoids mismatch in expected data when `post_revisions` is populated in future
This commit is contained in:
Kevin Ansfield 2024-06-17 11:43:04 +01:00
parent f85656460f
commit 428e10f147

View File

@ -62,23 +62,34 @@ class PostsImporter extends TableImporter {
slug: `${slugify(title)}-${faker.random.numeric(3)}`,
status,
visibility,
mobiledoc: JSON.stringify({
version: '0.3.1',
atoms: [],
cards: [],
markups: [['em']],
sections: content.map(paragraph => [
1,
'p',
[
[
0,
[],
0,
paragraph
]
]
])
lexical: JSON.stringify({
root: {
children: content.map(paragraph => (
{
children: [
{
detail: 0,
format: 0,
mode: 'normal',
style: '',
text: paragraph,
type: 'extended-text',
version: 1
}
],
direction: 'ltr',
format: '',
indent: 0,
type: 'paragraph',
version: 1
}
)),
direction: 'ltr',
format: '',
indent: 0,
type: 'root',
version: 1
}
}),
html: content.map(paragraph => `<p>${paragraph}</p>`).join(''),
plaintext: content.join('\n\n'),