Getting Started
The Language Badge plugin enhances Expressive Code blocks on your website by adding a language badge to the codeblocks.
This
This guide will show you how to add it to your website.
Set-up
Section titled “Set-up”-
Install the
expressive-code-language-badgedependency using your preferred package manager:Terminal window npm i expressive-code-language-badgeTerminal window pnpm add expressive-code-language-badgeTerminal window yarn add expressive-code-language-badge -
Add the plugin to your site’s Expressive Code configuration:
astro.config.mjs import { defineConfig } from 'astro/config';import astroExpressiveCode from 'astro-expressive-code';import { pluginLanguageBadge } from 'expressive-code-language-badge';export default defineConfig({integrations: [astroExpressiveCode({plugins: [pluginLanguageBadge()],}),],});astro.config.mjs import { defineConfig } from 'astro/config';import starlight from '@astrojs/starlight';import { pluginLanguageBadge } from 'expressive-code-language-badge';export default defineConfig({integrations: [starlight({title: 'My Starlight site',expressiveCode: {plugins: [pluginLanguageBadge()],},}),],});next.config.mjs import createMDX from '@next/mdx';import rehypeExpressiveCode from 'rehype-expressive-code';import { pluginLanguageBadge } from 'expressive-code-language-badge';/** @type {import('rehype-expressive-code').RehypeExpressiveCodeOptions} */const rehypeExpressiveCodeOptions = {plugins: [pluginLanguageBadge()],};/** @type {import('next').NextConfig} */const nextConfig = {reactStrictMode: true,pageExtensions: ['js', 'jsx', 'ts', 'tsx', 'md', 'mdx'],};const withMDX = createMDX({extension: /\.mdx?$/,options: {remarkPlugins: [],rehypePlugins: [// The nested array structure is required to pass options// to a rehype plugin[rehypeExpressiveCode, rehypeExpressiveCodeOptions],],},});export default withMDX(nextConfig);ec.config.mjs import { pluginLanguageBadge } from 'expressive-code-language-badge';export default {plugins: [pluginLanguageBadge()],}; -
That’s it! The Language Badge plugin works out of the box with sensible defaults.
For more information on how to configure the plugin, see the Configuration page.
Support
Section titled “Support”This plugin is open-source software licensed under the MIT license. If you run into any bugs, please report issues on GitHub.