npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

emdash-plugin-highlightjs

v1.0.2

Published

Syntax highlighting for EmDash CMS using Highlight.js — 12 themes, auto dark/light mode, copy button, and a custom code block component for Portable Text.

Downloads

416

Readme

emdash-plugin-highlightjs

CI Security npm version

Syntax highlighting for EmDash CMS using Highlight.js. Features 12 themes, auto dark/light switching, a copy button, and a custom Portable Text code block component.

Features

  • 12 themes — GitHub, Atom One, VS Code, A11Y, Stack Overflow, Tokyo Night, Rose Pine, Panda, Monokai, Dracula, Nord, Night Owl
  • Auto dark/light — Themes with both variants switch via MutationObserver on <html> class
  • Copy button — Optional floating copy button with "Copied!" feedback
  • Portable Text blockCode.astro component with language detection and filename support
  • Admin settings — Theme picker and copy button toggle at /_emdash/admin
  • CSS caching — Theme CSS read once and cached in memory
  • Server-side highlighting — No client JS cost for syntax highlighting

Installation

npm install emdash-plugin-highlightjs

Usage

Register the plugin in astro.config.mjs:

import { highlightjsPlugin } from "emdash-plugin-highlightjs";

export default defineConfig({
  integrations: [
    emdash({
      plugins: [highlightjsPlugin()],
    }),
  ],
});

CSS and copy button are injected automatically on all public pages. Code.astro renders automatically for code blocks in Portable Text content.

How It Works

The plugin injects four fragments via the page:fragments hook:

  1. Light CSS (<style id="hljs-l">) in <head>
  2. Dark CSS (<style id="hljs-d" disabled>) in <head>
  3. Theme toggle script in <head>MutationObserver on <html>.class
  4. Copy button script at <body:end>

The Code.astro component renders code server-side via highlight.js — no client-side highlighting overhead.

Admin Settings

Navigate to /_emdash/adminHighlight.js.

| Field | Default | Description | |---|---|---| | Syntax Theme | github | Pick from 12 themes | | Show copy button | true | Toggle floating copy button |

Themes

| Theme | Dark variant | Light variant | |---|---|---| | GitHub | github-dark | github | | Atom One | atom-one-dark | atom-one-light | | VS Code | vs2015 | vs | | A11Y | a11y-dark | a11y-light | | Stack Overflow | stackoverflow-dark | stackoverflow-light | | Tokyo Night | tokyo-night-dark | tokyo-night-light | | Rose Pine | rose-pine | rose-pine-dawn | | Panda | panda-syntax-dark | panda-syntax-light | | Monokai | monokai | — | | Dracula | dracula | — | | Nord | nord | — | | Night Owl | night-owl | — |

Themes with both variants switch automatically with your site's dark/light mode. Single-variant themes use the dark CSS only.

Development

git clone https://github.com/adrianoamalfi/emdash-plugin-highlightjs.git
cd emdash-plugin-highlightjs
npm install
npm run typecheck
npm test

Versioning

This project follows Semantic Versioning. Releases are automated via semantic-release — pushing fix:, feat:, or BREAKING CHANGE: commits to main triggers a release to npm and GitHub.

License

MIT © Adriano Amalfi