fix: preserve nested hard-break content and use timestamptz

remarkSplitBlocks was splicing after-break paragraphs onto the root
tree, which dropped content inside list items and other nested parents.
Insert the split sibling into the actual parent instead.

Also store timestamps as timestamptz so Drizzle no longer treats naive
timestamp values as UTC and shifts displayed times by the server offset.
This commit is contained in:
Zoe
2026-07-19 14:03:14 -05:00
parent 28ef0c8a07
commit 166052012d
4 changed files with 2864 additions and 45 deletions
+21 -21
View File
@@ -10,37 +10,37 @@ import rehypeKatex from 'rehype-katex';
function remarkSplitBlocks() {
return (tree: any) => {
visit(tree, 'paragraph', (node, index, parent) => {
if (parent == null || index == null) {
return;
}
const breakIndex = node.children.findIndex((child: any) => child.type === 'break');
if (breakIndex !== -1) {
const beforeBreak = node.children.slice(0, breakIndex);
const afterBreak = node.children.slice(breakIndex + 1);
if (breakIndex === -1) {
return;
}
node.children = beforeBreak;
const beforeBreak = node.children.slice(0, breakIndex);
const afterBreak = node.children.slice(breakIndex + 1);
// Keep content before the break in the current paragraph.
node.children = beforeBreak;
// Insert content after the break as the next sibling of this
// paragraph in its actual parent (root, listItem, blockquote, etc.).
// Previously this only spliced into tree.children and dropped
// nested content when the parent wasn't a direct root child.
if (afterBreak.length > 0) {
const newParagraph = {
type: 'paragraph',
children: afterBreak,
};
let rootChildIndex = -1;
if (parent.type === 'root') {
rootChildIndex = index!;
} else {
rootChildIndex = tree.children.findIndex((child: any) =>
child === parent || (child.children && child.children.includes(node))
);
parent.children.splice(index + 1, 0, newParagraph);
if (rootChildIndex === -1) {
rootChildIndex = tree.children.indexOf(parent);
}
}
if (rootChildIndex !== -1) {
tree.children.splice(rootChildIndex + 1, 0, newParagraph);
}
return index! + 1;
// Continue at the newly inserted paragraph so further
// hard breaks inside it are split as well.
return index + 1;
}
});
};