render block image tags

This commit is contained in:
Loren Norman 2025-07-29 15:22:31 -04:00
parent e9f3f8c5c7
commit ad3d1d8cb2
2 changed files with 11 additions and 4 deletions

View file

@ -4,7 +4,7 @@ import renderFields from './render_block_fields.js'
import renderInputs from './render_block_inputs.js'
const
export const
IO_PLUS_ALERT = `
::: tip :warning: IO+ Required
This Block requires an IO+ subscription to use. [Learn more about IO+](https://io.adafruit.com/plus)
@ -17,6 +17,9 @@ This Block requires an IO+ subscription to use. [Learn more about IO+](https://i
return trim(`${name} ${ioPlusBadge}`)
},
// ![alt](url "title")
renderBlockImage = ({ name, type }) => `![the ${name} block](/block_images/${type}.png "${name}")`,
renderDescription = ({ description }) => description || "No docs for this block, yet.",
renderIOPlusAlert = ({ ioPlus }) => ioPlus ? IO_PLUS_ALERT : "",
@ -70,6 +73,8 @@ definitionPath: ${ definition.definitionPath }
Type: \`${definition.type}\`
${ renderBlockImage(definition) }
${ renderDescription(definition) }
${ renderIOPlusAlert(definition) }

View file

@ -1,6 +1,8 @@
import { writeFileSync } from 'fs'
import { isString, without } from 'lodash-es'
import { renderBlockImage } from '../docs/render_block.js'
export default class BlockIndexExporter {
definitionSet = null
@ -78,11 +80,11 @@ const definitionToIndexLines = def => {
// block name and link
indexLines.push(`### [${ def.name }](/${ def.documentationPath() })`)
// block image // TODO
// indexLines.push(``)
// block short description
indexLines.push(`_${def.tooltip}_`)
// block image
indexLines.push(renderBlockImage(def))
return indexLines.join("\n")
}