Skip to content

Commit

Permalink
feat(function): Add model icon to rendered markdown model tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Jan 8, 2025
1 parent e27481e commit 1de2fe2
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/functions/markdown_plugins/ModelLink.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { renderToStaticMarkup } from "react-dom/server";
import IconLoader from "../../components/IconLoader";

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

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

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

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


// const icon_o = state.push('icon_open', 'span', 1)
const icon_o = state.push('icon_open', 'span', 1)
icon_o.attrPush([
'class', 'badge-icon'
])

// const icon_t = state.push('text', '', 0)
// icon_t.content = 'icon '
const icon_t = state.push('html_inline', '', 0)

// const icon_c = state.push('icon_close', 'span', -1)
icon_t.content = renderToStaticMarkup(
<IconLoader
name={String( item_link.groups.model_type ).toLowerCase().replace('kb', 'information')}
fill="#777"
/>
)

const icon_c = state.push('icon_close', 'span', -1)


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

0 comments on commit 1de2fe2

Please sign in to comment.