Skip to content

feat(parser): add icon support for code blocks#462

Closed
mrnasil wants to merge 2 commits intonuxt-content:mainfrom
mrnasil:feat/code-block-icon-support
Closed

feat(parser): add icon support for code blocks#462
mrnasil wants to merge 2 commits intonuxt-content:mainfrom
mrnasil:feat/code-block-icon-support

Conversation

@mrnasil
Copy link
Copy Markdown

@mrnasil mrnasil commented Jan 27, 2026

Summary

  • Add support for icon syntax in code block meta: [filename|icon|position]
  • Parse icon and iconPosition from code block syntax
  • Pass icon props to ProsePre component
  • Add basic icon/filename header rendering

Syntax

python [Script|logos:python|right]
print("test")
Format Description
[filename|icon] Filename with icon on left (default)
[filename|icon|right] Filename with icon on right
[|icon|position] Icon only, no filename
[filename] Backward compatible, no icon

Test plan

  • Unit tests for icon parsing added
  • All existing tests pass (61/61)
  • Playground example added

Notes

For full icon rendering support with @nuxt/ui, a separate PR to nuxt/ui is needed to handle iconPosition in CodeGroup.vue.

Add support for icon syntax in code block meta:
- `[filename|icon]` - filename with icon on left
- `[filename|icon|right]` - filename with icon on right
- `[|icon|position]` - icon only without filename

Changes:
- Update parseThematicBlock to extract icon and iconPosition
- Pass icon props to ProsePre component
- Add basic icon/filename header rendering in ProsePre
- Add comprehensive tests for icon parsing

Syntax example:
```python [Script|logos:python|right]
print("test")
```
@mrnasil
Copy link
Copy Markdown
Author

mrnasil commented Jan 27, 2026

I've opened a PR in nuxt/ui that implements the UI side of this feature: nuxt/ui#5953. Also waiting for this to be merged to fully unlock the functionality. Thanks!

@mrnasil
Copy link
Copy Markdown
Author

mrnasil commented Jan 31, 2026

@farnabaz When you get a chance, can you check this out? I need a structure like this for my documentation page. Creating a custom component didn’t seem worth it. Many docs also need icons for different languages or different types of explanations, I think.

@farnabaz
Copy link
Copy Markdown
Collaborator

farnabaz commented Mar 26, 2026

Thanks for the PR @mrnasil
However I think feature is deeply UI related and supporting/parsing icon (string) and position can be done in UI components.

You can use code block meta to pass these information to your component and use it there.

```ts icon="logos:nuxt" 
Your awesome code example
```

And in meta props of ProsePre component you will get icon="logos:nuxt". with a simple logic values can be extracted.

I'm closing this PR in favor of meta prop.

@farnabaz farnabaz closed this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants