Skip to content

Commit

Permalink
docs(nxdev): allow to use ts or js for typescript / javascript syntax…
Browse files Browse the repository at this point in the history
… highlighting (#10153)
  • Loading branch information
juristr committed May 5, 2022
1 parent e8be469 commit a2b704d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion nx-dev/feature-doc-viewer/src/lib/code-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import React, { useEffect, useState } from 'react';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import SyntaxHighlighter from 'react-syntax-highlighter';

function resolveLanguage(lang: string) {
switch (lang) {
case 'ts':
return 'typescript';
case 'js':
return 'javascript';
default:
return lang;
}
}

export function CodeBlock({
text,
language,
Expand Down Expand Up @@ -59,7 +70,7 @@ export function CodeBlock({
<SyntaxHighlighter
showLineNumbers={!['bash', 'text', 'treeview'].includes(language)}
useInlineStyles={false}
language={language}
language={resolveLanguage(language)}
children={text}
style=""
{...rest}
Expand Down

1 comment on commit a2b704d

@vercel
Copy link

@vercel vercel bot commented on a2b704d May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.