feat: work on highlighting and displaying language snippets

This commit is contained in:
Stevan Freeborn
2023-04-11 22:45:48 -05:00
parent c87b2a39e8
commit 5f4d4f656e
8 changed files with 202 additions and 27 deletions
+20 -5
View File
@@ -2,7 +2,8 @@ import { default as Markdoc } from '@markdoc/markdoc';
import fs from 'fs';
import path from 'path';
import React, { ReactNode } from 'react';
import Code from '../components/Code';
import CodeSnippet from '../components/CodeSnippet';
import Fence from '../components/Fence';
import { Doc, DocSection } from './../types/types';
const DOCS_PATH = path.join(process.cwd(), 'src/docs');
@@ -34,16 +35,29 @@ function getExamplePath(version: string, doc: Doc): string {
}
const markDocConfig = {
tags: {
code: {
render: 'Code',
nodes: {
fence: {
render: 'Fence',
attributes: {
language: {
type: 'string',
},
content: {
type: 'string',
},
},
},
},
tags: {
code: {
render: 'CodeSnippet',
attributes: {
heading: {
type: 'string',
},
defaultLanguage: {
type: 'string',
},
},
},
},
@@ -58,7 +72,8 @@ function parseMarkdown(sourcePath: string): ReactNode {
);
const children = Markdoc.renderers.react(content, React, {
components: {
Code: Code,
CodeSnippet: CodeSnippet,
Fence: Fence,
},
});