diff --git a/src/convertors/logseq/__snapshots__/logseq-convertor.test.ts.snap b/src/convertors/logseq/__snapshots__/logseq-convertor.test.ts.snap
index 2593d2c..75721e2 100644
--- a/src/convertors/logseq/__snapshots__/logseq-convertor.test.ts.snap
+++ b/src/convertors/logseq/__snapshots__/logseq-convertor.test.ts.snap
@@ -60,16 +60,7 @@ exports[`LogseqConvertor > parses example 1`] = `
"subject": "Contents",
},
{
- "backlinks": [
- {
- "id": "02052023",
- "label": "May 2nd, 2023",
- },
- {
- "id": "04052023",
- "label": "May 4th, 2023",
- },
- ],
+ "backlinks": [],
"dailyAt": 1683072000000,
"html": "
May 3rd, 2023
",
"id": "03052023",
diff --git a/src/convertors/logseq/logseq-convertor.test.ts b/src/convertors/logseq/logseq-convertor.test.ts
index 15f65ee..46c58a0 100644
--- a/src/convertors/logseq/logseq-convertor.test.ts
+++ b/src/convertors/logseq/logseq-convertor.test.ts
@@ -14,6 +14,7 @@ describe('LogseqConvertor', () => {
expect(notes).toMatchSnapshot()
})
+
it('parses properties example', async () => {
const convertor = new LogseqConvertor({graphId: '123'})
const {notes} = await convertor.convert({
@@ -22,12 +23,14 @@ describe('LogseqConvertor', () => {
expect(notes).toMatchSnapshot()
})
+
it('parses TODO example', async () => {
const convertor = new LogseqConvertor({graphId: '123'})
const {notes} = await convertor.convert({data: JSON.stringify(exampleTodoExport)})
expect(notes).toMatchSnapshot()
})
+
it('handles and ignores whiteboard pages', async () => {
const convertor = new LogseqConvertor({graphId: '123'})
const {notes} = await convertor.convert({
@@ -36,10 +39,25 @@ describe('LogseqConvertor', () => {
expect(notes).toMatchSnapshot()
})
+
it('exception for Org example', () => {
const convertor = new LogseqConvertor({graphId: '123'})
expect(
async () => await convertor.convert({data: JSON.stringify(exampleOrgExport)}),
).rejects.toThrowError()
})
+
+ it('does not include daily backlinks', async () => {
+ const data = {
+ ...exampleExport,
+ blocks: exampleExport.blocks.filter((b) => b['page-name'] === 'May 3rd, 2023'),
+ }
+
+ const convertor = new LogseqConvertor({graphId: '123'})
+ const {notes} = await convertor.convert({data: JSON.stringify(data)})
+ expect(notes.length).toBe(1)
+ const note = notes[0]
+
+ expect(note.backlinks).toEqual([])
+ })
})
diff --git a/src/convertors/logseq/logseq-convertor.ts b/src/convertors/logseq/logseq-convertor.ts
index 8058ce4..3d9cc9f 100644
--- a/src/convertors/logseq/logseq-convertor.ts
+++ b/src/convertors/logseq/logseq-convertor.ts
@@ -9,6 +9,7 @@ import {exportSchema} from './schema'
import {LogseqBlock, LogseqConversionError, LogseqExport, LogseqNote} from './types'
import {Convertor} from '../../convertor'
import {Backlink, ConvertedNote, ConvertOptions, ConvertResponse} from '../../types'
+import {isDailyNoteId} from 'helpers/to-id'
export class LogseqConvertor extends Convertor {
static accept = {'application/json': ['.json']}
@@ -120,6 +121,14 @@ export class LogseqConvertor extends Convertor {
pageResolver: (pageName) => toLogseqId(this.noteIds[pageName], pageName),
})
+ // Remove backlinks to daily notes. Reflect will automatically create the
+ // daily note when daily backlink is clicked. Also, Reflect importing logic
+ // doesn't recognize daily backlinks, so this would create regular note with
+ // daily-like ID, which would break the UI.
+ //
+ // See also: https://height.app/dWwdXWnlP/T-2442
+ backlinks = backlinks.filter((backlink) => !isDailyNoteId(backlink.id))
+
// If the block has children then we need to get the html for the children
if (block.children?.length) {
const {html: childHtml, backlinks: childBacklinks} = this.parseBlocks(
diff --git a/src/helpers/to-id.ts b/src/helpers/to-id.ts
index c607cf6..842d8f8 100644
--- a/src/helpers/to-id.ts
+++ b/src/helpers/to-id.ts
@@ -12,3 +12,7 @@ export const toNoteId = (value: string) => {
export const toDailyNoteId = (date: Date) => {
return format(date, 'ddMMyyyy')
}
+
+export const isDailyNoteId = (value: string) => {
+ return (/^(\d{2})(\d{2})(\d{4})$/).test(value)
+}