Alekhya

August 23, 2025 ยท View on GitHub

Alekhya is sanskrit word which means image in english

Prototype for generating code images from text using Shiki and Nuxt 4. As a USP it allows you to retrieve code snippet as PNG image via API call thanks to pi0/shiki-image.

๐ŸŒ Retrieve Code Image via API

1. Encode your code

Node
import { Buffer } from 'node:buffer'

const code = 'console.log("Hello World!")'
const encoded = Buffer.from(code).toString('base64')
JavaScript (Browser)
const code = 'console.log("Hello World!")'
const encoded = btoa(
  new TextEncoder().encode(code).reduce(
    (data, byte) => data + String.fromCharCode(byte),
    ''
  )
)
Python
import base64

code = 'console.log("Hello World!")'
encoded = base64.b64encode(code.encode()).decode()
Other
take raw code โ†’ convert to bytes โ†’ encode as Base64

2. Craft URL

https://getalekhya.netlify.app/api/image/code?code=<encodedCode>&lang=<yourLang>

3. Make API Request

Use any of your preferred tools to make API call to above URL

Supported query params

Why

  • You can generate code snippet in your build pipeline or automation
  • Directly render various code snippets as image in your docs
  • Add PR for your ideas ๐Ÿ˜œ

๐ŸŽฏ Goal

  • Code image generator
    • Allow downloading, copying images in various formats
    • Add UI like editor window
    • more...
  • [-] Provide API to retrieve code images
    • API with basic features
    • Allow UI customization

Proudly powered by Nuxt 4 โœจ