Skip to content

Commit f97c6b1

Browse files
committed
Merge branch 'main' into feat/create-folder
2 parents a8cf5dc + 449e93e commit f97c6b1

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

src/app/src/components/content/ContentEditorCode.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,6 @@ function setContent(document: DatabasePageItem) {
135135
<template>
136136
<div
137137
ref="editorRef"
138-
class="h-full -ml-3"
138+
class="h-full -ml-3 py-2"
139139
/>
140140
</template>

src/app/src/utils/content.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ async function generateDocumentFromMarkdownContent(id: string, content: string):
144144
return {
145145
id,
146146
meta: {},
147-
body,
147+
body: {
148+
...body,
149+
toc: document.toc,
150+
},
148151
...document.data,
149152
} as unknown as DatabaseItem
150153
}

src/app/src/utils/database.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1+
import { compressTree } from '@nuxt/content/runtime'
12
import { type DatabasePageItem, ContentFileExtension } from '../types'
23
import { stringify } from 'minimark/stringify'
4+
import { MDCRoot } from '@nuxtjs/mdc'
5+
import { MarkdownRoot } from '@nuxt/content'
36

47
export function isEqual(document1: DatabasePageItem, document2: DatabasePageItem) {
5-
function removeLastStyle(document: DatabasePageItem) {
6-
if (document.body?.value[document.body?.value.length - 1]?.[0] === 'style') {
7-
return { ...document, body: { ...document.body, value: document.body?.value.slice(0, -1) } }
8+
function withoutLastStyles(body: MarkdownRoot) {
9+
if (body.value[body.value.length - 1]?.[0] === 'style') {
10+
return { ...body, value: body.value.slice(0, -1) }
811
}
9-
return document
12+
return body
1013
}
1114

1215
const { body: body1, meta: meta1, ...documentData1 } = document1
1316
const { body: body2, meta: meta2, ...documentData2 } = document2
1417

1518
// Compare body first
1619
if (document1.extension === ContentFileExtension.Markdown) {
17-
if (document1.body?.type === 'minimark') {
18-
document1 = removeLastStyle(document1)
19-
}
20-
21-
if (document2.body?.type === 'minimark') {
22-
document2 = removeLastStyle(document2)
23-
}
24-
25-
if (stringify(body1) !== stringify(body2)) {
20+
const minifiedBody1 = withoutLastStyles(
21+
document1.body.type === 'minimark' ? document1.body : compressTree(document1.body as unknown as MDCRoot)
22+
)
23+
const minifiedBody2 = withoutLastStyles(
24+
document2.body.type === 'minimark' ? document2.body : compressTree(document2.body as unknown as MDCRoot)
25+
)
26+
27+
if (stringify(minifiedBody1) !== stringify(minifiedBody2)) {
2628
return false
2729
}
2830
}

0 commit comments

Comments
 (0)