Skip to content

Commit 1de2fe2

Browse files
committed
feat(function): Add model icon to rendered markdown model tags
ref: #40 #42 nofusscomputing/centurion_erp#466
1 parent e27481e commit 1de2fe2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/functions/markdown_plugins/ModelLink.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { renderToStaticMarkup } from "react-dom/server";
2+
import IconLoader from "../../components/IconLoader";
13

24
const UNESCAPE_RE = /(?<markdown>\$(?<model_type>[a-z_]+)-(?<model_id>\d+))/g
35

@@ -45,17 +47,27 @@ function model_link (state) {
4547
if( state.env.models[item_link.groups.model_type][item_link.groups.model_id] ?? null ) {
4648

4749
const span_o = state.push('span_open', 'span', 1)
50+
span_o.attrPush(['class', 'text-inline'])
4851

4952
const anchor_o = state.push('a_open', 'a', 1)
5053
anchor_o.attrPush(['href', state.env.models[item_link.groups.model_type][item_link.groups.model_id].url])
5154

5255

53-
// const icon_o = state.push('icon_open', 'span', 1)
56+
const icon_o = state.push('icon_open', 'span', 1)
57+
icon_o.attrPush([
58+
'class', 'badge-icon'
59+
])
5460

55-
// const icon_t = state.push('text', '', 0)
56-
// icon_t.content = 'icon '
61+
const icon_t = state.push('html_inline', '', 0)
5762

58-
// const icon_c = state.push('icon_close', 'span', -1)
63+
icon_t.content = renderToStaticMarkup(
64+
<IconLoader
65+
name={String( item_link.groups.model_type ).toLowerCase().replace('kb', 'information')}
66+
fill="#777"
67+
/>
68+
)
69+
70+
const icon_c = state.push('icon_close', 'span', -1)
5971

6072

6173
const anchor_t = state.push('text', '', 0)

0 commit comments

Comments
 (0)