Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output list items with only text and a nested list as tight list items in fields.markdoc/fields.mdx #1237

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/five-years-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystatic/core': patch
---

Output list items with only text and a nested list as tight list items in `fields.markdoc`/`fields.mdx`
2 changes: 0 additions & 2 deletions docs/src/content/pages/reader-api.mdoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ import keystaticConfig from 'relative/path/to/your/keystatic.config';
You can then create a new `reader` by calling `createGitHubReader` and passing it the following arguments:

1. The Keystatic config

1. An options object containing:

- `repo`: The name of the content repository on GitHub (e.g. `Thinkmill/keystatic-data`)
- `token`: The Personal Access Token that allows read access to the repository. This is different from your GitHub App Client ID / Secret in `.env`.
For information on how to generate PATs, see [GitHub's documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ export function proseMirrorToMarkdoc(
listItemContent[0].type === 'paragraph'
) {
listItemContent = listItemContent[0].children;
} else if (
listItemContent.length === 2 &&
listItemContent[0].type === 'paragraph' &&
listItemContent[0].children.length === 1 &&
listItemContent[1].type === 'list'
) {
listItemContent = [listItemContent[0].children[0], listItemContent[1]];
}
return new Ast.Node('item', {}, listItemContent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,16 @@ function mapContent<T>(
}

function convertListItem(listItemContent: BlockContent[]): ListItem {
return { type: 'listItem', children: listItemContent };
return {
type: 'listItem',
spread:
listItemContent.length === 2 &&
listItemContent[0].type === 'paragraph' &&
listItemContent[1].type === 'list'
? false
: undefined,
children: listItemContent,
};
}

export function proseMirrorToMDXRoot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ test('nested list', () => {
);
expect(markdoc).toMatchInlineSnapshot(`
"- Something

- Something
"
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ test('nested list', () => {
);
expect(mdx).toMatchInlineSnapshot(`
"* Something

* Something

"
Expand Down
Loading