faizhameed / portfolio-gatsby

MIT License
1 stars 0 forks source link

Change the code highligthing based on language #43

Open faizhameed opened 3 years ago

faizhameed commented 3 years ago
    renderNode: {
      [BLOCKS.PARAGRAPH]: (node, children) => {
        if (
          node.content.length === 1 &&
          node.content[0].value.length > 2 &&
          node.content[0].marks.find((o) => o.type === "code")
        ) {
          console.log(
            typeof node.content[0].value,
            node.content[0].value.includes("//code_l")
          );
          return (
            <div className="gatsby-highlight">
              {/* 
              TODO: Get the type of language and fix based on the language
              */}
              <pre className={`language-js`}>
                <code>{node.content[0].value}</code>
              </pre>
            </div>
          );
        }
        return <Text>{children}</Text>;