Skip to content

Commit 711920e

Browse files
committed
use badges
1 parent 0a8a57d commit 711920e

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

packages/core/src/Parser/references.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function references({ internal, external }: Partial<Linkers>) {
1515
return function transformer(tree: Root) {
1616
visit(tree, 'internalLink', (node: InternalLinkNode) => {
1717
const { kind, id } = node
18+
const shortId = `${kind}${id}`
1819

1920
if (!internal) {
2021
Object.assign(node, {
@@ -38,16 +39,30 @@ export function references({ internal, external }: Partial<Linkers>) {
3839

3940
Object.assign(node, {
4041
data: {
41-
hName: 'a',
42+
hName: 'span',
4243
hProperties: {
43-
href,
4444
title,
45-
className: 'internal-link',
4645
},
4746
hChildren: [
4847
{
49-
type: 'text',
50-
value: `${kind}${id}: ${title}`,
48+
type: 'element',
49+
tagName: 'a',
50+
properties: {
51+
className: ['internal-link', 'badge', 'badge-secondary', 'mx-1'],
52+
href,
53+
title,
54+
},
55+
children: [{ type: 'text', value: shortId }],
56+
},
57+
{
58+
type: 'element',
59+
tagName: 'a',
60+
properties: {
61+
className: ['internal-link'],
62+
href,
63+
title,
64+
},
65+
children: [{ type: 'text', value: title }],
5166
},
5267
],
5368
},

0 commit comments

Comments
 (0)