---
import { Code } from 'astro/components';
import type { CodeBlock } from "../api/lib/notion-types";
import { getNotionCodeProps } from "../api/lib";

export interface Props {
	data: CodeBlock["properties"];
	bemClass: string;
}

const { data, bemClass } = Astro.props as Props;

const { text, shikiLang } = getNotionCodeProps(data.language);
---

<Fragment>
	{text && (
		<div class={`${bemClass}__lang`}>{text}</div>
	)}
	<Code code={data.title[0][0]} lang={shikiLang} />
</Fragment>