don't import css into /lib

This commit is contained in:
keyan 2024-06-25 17:18:21 -05:00
parent 1e3d37d6b0
commit 4fc832c7ed
2 changed files with 6 additions and 7 deletions

View File

@ -15,7 +15,7 @@ import copy from 'clipboard-copy'
import ZoomableImage, { decodeOriginalUrl } from './image'
import { IMGPROXY_URL_REGEXP, parseInternalLinks, parseEmbedUrl } from '@/lib/url'
import reactStringReplace from 'react-string-replace'
import { rehypeInlineCodeProperty, rehypeSubscript, rehypeSuperscript } from '@/lib/md'
import { rehypeInlineCodeProperty, rehypeStyler } from '@/lib/md'
import { Button } from 'react-bootstrap'
import { useRouter } from 'next/router'
import Link from 'next/link'
@ -24,6 +24,10 @@ import isEqual from 'lodash/isEqual'
import UserPopover from './user-popover'
import ItemPopover from './item-popover'
// Explicitely defined start/end tags & which CSS class from text.module.css to apply
export const rehypeSuperscript = () => rehypeStyler('<sup>', '</sup>', styles.superscript)
export const rehypeSubscript = () => rehypeStyler('<sub>', '</sub>', styles.subscript)
export function SearchText ({ text }) {
return (
<div className={styles.text}>

View File

@ -2,7 +2,6 @@ import { gfmFromMarkdown } from 'mdast-util-gfm'
import { visit } from 'unist-util-visit'
import { gfm } from 'micromark-extension-gfm'
import { fromMarkdown } from 'mdast-util-from-markdown'
import { superscript, subscript } from '../components/text.module.css'
export function mdHas (md, test) {
if (!md) return []
@ -32,7 +31,7 @@ export function rehypeInlineCodeProperty () {
}
}
function rehypeStyler (startTag, endTag, className) {
export function rehypeStyler (startTag, endTag, className) {
return function (tree) {
visit(tree, 'element', (node) => {
for (let i = 0; i < node.children.length; i += 1) {
@ -59,10 +58,6 @@ function rehypeStyler (startTag, endTag, className) {
}
}
// Explicitely defined start/end tags & which CSS class from text.module.css to apply
export const rehypeSuperscript = () => rehypeStyler('<sup>', '</sup>', superscript)
export const rehypeSubscript = () => rehypeStyler('<sub>', '</sub>', subscript)
export function extractUrls (md) {
if (!md) return []
const tree = fromMarkdown(md, {