summaryrefslogtreecommitdiff
path: root/src/components/OpenMoji.astro
blob: 9fd581d9048f2890f86c84a1a7db7c937534f19d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { join, dirname } from 'path';

interface Props { code: string; alt: string; size?: string; }
const { code, alt, size = '1.2em' } = Astro.props;

const svgPath = join(
  dirname(fileURLToPath(import.meta.url)),
  `../../node_modules/openmoji/color/svg/${code}.svg`
);
const svg = readFileSync(svgPath, 'utf-8');
---
<span class="openmoji" role="img" aria-label={alt} style={`width:${size};height:${size};display:inline-flex;vertical-align:middle`} set:html={svg} />