Skip to content

Commit ac0aebe

Browse files
committed
feat: new format of github embedded
1 parent 3fe84fb commit ac0aebe

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/components/text.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Block, Decoration, ExternalObjectInstance } from 'notion-types'
22
import { parsePageId } from 'notion-utils'
33
import * as React from 'react'
44

5+
import FaGithub from '../icons/FaGithub'
56
import { useNotionContext } from '../lib/context'
67
import { mapNoteUri, removeBaseUrl } from '../lib/helpers'
78
import { formatDate, getHashFragmentValue } from '../lib/utils'
@@ -261,6 +262,7 @@ export const Text: React.FC<{
261262
)
262263
}
263264

265+
// Github mention
264266
case 'eoi': {
265267
const blockId = decorator[1]
266268
const externalObjectInstance = recordMap.block[blockId]
@@ -269,6 +271,25 @@ export const Text: React.FC<{
269271
return <EOI block={externalObjectInstance} inline={true} />
270272
}
271273

274+
// Github new format
275+
case 'lm' as any: {
276+
const href = (decorator[1] as any)?.href
277+
const title = (decorator[1] as any)?.title
278+
return (
279+
<a
280+
className="not-prose px-1 hover:cursor-pointer hover:border-sky-300 hover:shadow-sm inline-flex gap-1 flex-row items-baseline group"
281+
target="_blank"
282+
href={href}
283+
rel="noopener noreferrer"
284+
>
285+
<FaGithub className="text-[0.9em]" />
286+
<div className="text-[1em] m2it-link group-hover:m2it-link-hover border-b border-slate-200 leading-[1.1]">
287+
{title}
288+
</div>
289+
</a>
290+
)
291+
}
292+
272293
default:
273294
if (process.env.NODE_ENV !== 'production') {
274295
console.log('unsupported text format', decorator)

0 commit comments

Comments
 (0)