chore: use lib instead of copy-pasting bundling module

This commit is contained in:
andres
2023-10-17 10:34:18 +02:00
parent 5e229bf646
commit ca68482061
6 changed files with 1904 additions and 253 deletions

View File

@@ -1,47 +0,0 @@
import { bundleMDX } from 'mdx-bundler'
import rehypePrettyCode from 'rehype-pretty-code'
import rehypeSlug from 'rehype-slug'
import { CODE_BLOCK_FILENAME_REGEX } from './constants'
import { attachMeta, parseMeta } from './rehype'
import theme from './theme.json'
import { BundledMdx } from './types'
export const bundleMdx = async (source: string): Promise<BundledMdx> => {
return await bundleMDX({
globals: {
components: '@it-incubator/mdx-components',
},
mdxOptions(options) {
options.rehypePlugins = [
...(options.rehypePlugins ?? []),
rehypeSlug,
[parseMeta, { defaultShowCopyCode: true }],
[
rehypePrettyCode,
{
filterMetaString: (meta: string) => meta.replace(CODE_BLOCK_FILENAME_REGEX, ''),
onVisitHighlightedChars(node: any) {
node.properties.className = ['highlighted']
},
onVisitHighlightedLine(node: any) {
node.properties.className.push('highlighted')
},
onVisitLine(node: any) {
// Prevent lines from collapsing in `display: grid` mode, and
// allow empty lines to be copy/pasted
if (node.children.length === 0) {
node.children = [{ type: 'text', value: ' ' }]
}
},
theme,
},
],
attachMeta,
]
return options
},
source,
})
}

View File

@@ -3,10 +3,10 @@ import path from 'node:path'
import { join } from 'path'
import { electronApp, is, optimizer } from '@electron-toolkit/utils'
import { bundleMdx } from '@it-incubator/md-bundler'
import { BrowserWindow, app, ipcMain, shell } from 'electron'
import icon from '../../resources/icon.png?asset'
import { bundleMdx } from './bundle-mdx'
const chokidar = require('chokidar')
let mainWindow: BrowserWindow | null = null

View File

@@ -180,10 +180,6 @@
padding-inline: 1rem;
}
}
&:not([data-theme]) {
@apply px-4;
}
}
& img {