Support links between entries? #27

Open
opened 2023-07-12 22:59:30 +00:00 by mycrobe · 3 comments
Owner
Looks like dayone supports it: https://dayoneapp.com/guides/tips-and-tutorials/linking-journal-entries/
Author
Owner

Here's an entry with a link in it: dayone://view?entryId=14614ADEA2924066AA7A375EECF48C8E

Here's an entry with a link in it: dayone://view?entryId=14614ADEA2924066AA7A375EECF48C8E
Author
Owner

Here's code that is a POC to clean up dayone's broken urls in their markdown output.

let markdown = `

# Testing links to other entries
Here's a link to the meta entry about making this blog
dayone://view?entryId=FD23ADDD414043BA8C5D24DE513E6AD2

<https://tildegit.org/mycrobe/cmsetlbbq/issues/27>

This link may well be broken for a while on the blog/phlog/gemlog, and work to support it is tracked in https://tildegit\\\.foo\\\.org/mycrobe/cmsetlbbq/issues/27

`.replace(/([^\<])((?:gopher|gemini|http|https|ftp|sftp|spartan|titan|dayone):\/\/\S+)/gm, (match, notLessThanMatch, urlMatch, offset, string, groups) => {
    // console.log({match, notLessThanMatch, urlMatch, offset, groups})

    const before = string.substring(0, offset)
    const after = string.substring(offset + match.length)
    const updatedUrlMatch = urlMatch.replace(/\\\./g, '.')

    return `${notLessThanMatch}<${updatedUrlMatch}>`
}).replace(/dayone:\/\/view\?entryId=([\w\d]+)/, (_, guidMatch) => '../lookup?' + guidMatch.toLowerCase())

console.log(markdown)

note that at the end I'm replacing the dayone link with a "../lookup?{guid}".

I think that in a preprocess step, we could pass this function a map of guid -> dirname, and we can do that lookup in the dayone:// replace function.

Here's code that is a POC to clean up dayone's broken urls in their markdown output. ``` let markdown = ` # Testing links to other entries Here's a link to the meta entry about making this blog dayone://view?entryId=FD23ADDD414043BA8C5D24DE513E6AD2 <https://tildegit.org/mycrobe/cmsetlbbq/issues/27> This link may well be broken for a while on the blog/phlog/gemlog, and work to support it is tracked in https://tildegit\\\.foo\\\.org/mycrobe/cmsetlbbq/issues/27 `.replace(/([^\<])((?:gopher|gemini|http|https|ftp|sftp|spartan|titan|dayone):\/\/\S+)/gm, (match, notLessThanMatch, urlMatch, offset, string, groups) => { // console.log({match, notLessThanMatch, urlMatch, offset, groups}) const before = string.substring(0, offset) const after = string.substring(offset + match.length) const updatedUrlMatch = urlMatch.replace(/\\\./g, '.') return `${notLessThanMatch}<${updatedUrlMatch}>` }).replace(/dayone:\/\/view\?entryId=([\w\d]+)/, (_, guidMatch) => '../lookup?' + guidMatch.toLowerCase()) console.log(markdown) ``` note that at the end I'm replacing the dayone link with a "../lookup?{guid}". I think that in a preprocess step, we could pass this function a map of guid -> dirname, and we can do that lookup in the dayone:// replace function.
Author
Owner

ugh this is annoyingly hard. branch links tracks a not working impl of whats disussed in the above thread

ugh this is annoyingly hard. branch `links` tracks a not working impl of whats disussed in the above thread
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mycrobe/cmsetlbbq#27
No description provided.