Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/blocks/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const Code = ({
img,
lines,
hideCopyButton = false,
filename,
filenameOnly = true,
}) => {
// Create a ref for the code element.
const codeRef = useRef(null);
Expand Down Expand Up @@ -124,13 +126,15 @@ const Code = ({
// Extract language identifier for display
const langId = languageClass?.substring(9) || language || "python";
const displayLanguage = languageDisplayNames[langId] || langId;
const showLanguage = langId.toLowerCase() !== "none";
const showLanguage =
langId.toLowerCase() !== "none" && !(filenameOnly && filename);

const Header = (
<div className={classNames(styles.Header, "code-block-header")}>
{showLanguage && (
<span className={styles.Language}>{displayLanguage}</span>
)}
{filename && <span className={styles.Filename}>{filename}</span>}
</div>
);

Expand Down
4 changes: 4 additions & 0 deletions components/blocks/code.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
@apply uppercase tracking-wider pr-4;
}

.Filename {
@apply font-mono text-sm leading-6 pr-4;
}

.HasHeader {
@apply rounded-t-none !important;
}
Expand Down