style: scrollable tables
This commit is contained in:
		
							parent
							
								
									134b6ed582
								
							
						
					
					
						commit
						50a87d0d86
					
				
					 2 changed files with 34 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -1,14 +1,28 @@
 | 
			
		|||
import { toJsxRuntime } from "hast-util-to-jsx-runtime"
 | 
			
		||||
import { Components, toJsxRuntime } from "hast-util-to-jsx-runtime"
 | 
			
		||||
import { QuartzPluginData } from "../plugins/vfile"
 | 
			
		||||
import { Node, Root } from "hast"
 | 
			
		||||
import { Fragment, jsx, jsxs } from "preact/jsx-runtime"
 | 
			
		||||
import { trace } from "./trace"
 | 
			
		||||
import { type FilePath } from "./path"
 | 
			
		||||
 | 
			
		||||
const customComponents: Components = {
 | 
			
		||||
  table: (props) => (
 | 
			
		||||
    <div class="table-container">
 | 
			
		||||
      <table {...props} />
 | 
			
		||||
    </div>
 | 
			
		||||
  ),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function htmlToJsx(fp: FilePath, tree: Node<QuartzPluginData>) {
 | 
			
		||||
  try {
 | 
			
		||||
    // @ts-ignore (preact makes it angry)
 | 
			
		||||
    return toJsxRuntime(tree as Root, { Fragment, jsx, jsxs, elementAttributeNameCase: "html" })
 | 
			
		||||
    return toJsxRuntime(tree as Root, {
 | 
			
		||||
      Fragment,
 | 
			
		||||
      jsx,
 | 
			
		||||
      jsxs,
 | 
			
		||||
      elementAttributeNameCase: "html",
 | 
			
		||||
      components: customComponents,
 | 
			
		||||
    })
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    trace(`Failed to parse Markdown in \`${fp}\` into JSX`, e as Error)
 | 
			
		||||
  }
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue