@d1vij/react-mdx-loader 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
type StyleClasses = "header" | `header_${HeaderLevels}` | "header_icon" | "anchor" | "button" | "bold" | "italic" | "span" | "striked" | "paragraph" | "code" | "preformatted" | "blockquote" | "horizontal_line" | "image" | "list" | `${"un" | ""}ordered_list` | "list_item" | "table" | "table_head" | "table_head_cell" | "table_body" | "table_row" | "table_data";
|
|
1
|
+
declare const StyleClassesList: readonly ["header", "header_1", "header_2", "header_3", "header_4", "header_5", "header_6", "header_icon", "anchor", "button", "bold", "italic", "span", "striked", "paragraph", "code", "preformatted", "blockquote", "horizontal_line", "image", "list", "unordered_list", "ordered_list", "list_item", "table", "table_head", "table_head_cell", "table_body", "table_row", "table_data"];
|
|
2
|
+
type StyleClasses = (typeof StyleClassesList)[number];
|
|
4
3
|
type StyleClassesMap = Partial<{ [K in StyleClasses] : string }>;
|
|
5
4
|
declare const StyleContext: React.Context<StyleClassesMap>;
|
|
5
|
+
type JSX = React.JSX.Element | null;
|
|
6
|
+
type HeaderLevels = 1 | 2 | 3 | 4 | 5 | 6;
|
|
6
7
|
import { MDXProps } from "mdx/types";
|
|
7
8
|
type MDXSourceComponent = React.ComponentType<MDXProps>;
|
|
8
9
|
type MDXFromComponentProps = {
|
|
@@ -12,7 +13,7 @@ declare function MDXFromComponent({ SourceComponent }: MDXFromComponentProps): J
|
|
|
12
13
|
import { Options as MDXOptions } from "@mdx-js/rollup";
|
|
13
14
|
import { Plugin } from "vite";
|
|
14
15
|
type MDXLoaderPluginOptions = {
|
|
15
|
-
mdxPluginOptions
|
|
16
|
+
mdxPluginOptions?: MDXOptions;
|
|
16
17
|
};
|
|
17
18
|
/**
|
|
18
19
|
* Vite plugin to support MDX conversion.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createContext as
|
|
1
|
+
import{createContext as U,useContext as G}from"react";var p=U({});function o(){return G(p)}import{cn as R}from"@d1vij/shit-i-always-use";import{useState as W}from"react";import{jsxDEV as Z}from"react/jsx-dev-runtime";var Y=new URL(window.location.href).origin.toString();function X(t){let e=o(),[r]=W(()=>{if(t.href?.match(/^#.*/))return"_self";return new URL(t.href??"").origin.toString()===Y?"_self":"_blank"});return Z("a",{className:R(e.anchor),target:r,href:t.href,children:t.children},void 0,!1,void 0,this)}import{cn as $}from"@d1vij/shit-i-always-use";import{jsxDEV as x}from"react/jsx-dev-runtime";function c(t){let e=o();return x("blockquote",{className:$(e.blockquote),children:t.children},void 0,!1,void 0,this)}import{cn as A}from"@d1vij/shit-i-always-use";import{jsxDEV as Q}from"react/jsx-dev-runtime";function h(t){let e=o();return Q("span",{className:A(e.bold),children:t.children},void 0,!1,void 0,this)}import{cn as T}from"@d1vij/shit-i-always-use";import{jsxDEV as B}from"react/jsx-dev-runtime";function i(t){let e=o(),r=/language-(\w+)/.exec(t.className||"")?.[1];return B("code",{className:T(e.code,r&&`language-${r}`),children:t.children},void 0,!1,void 0,this)}import{cn as I,useClipboardText as H}from"@d1vij/shit-i-always-use";import{useEffect as D,useRef as v,useState as V}from"react";import{jsxDEV as _}from"react/jsx-dev-runtime";function n(t){let e=o(),r=v(null),[a,u]=V(""),{copy:z}=H();async function K(){let d=new URL(`/#${a}`,window.location.origin).toString();console.log("clicked"),await z(d)}return D(()=>{if(!r.current)return;let O=(r.current.textContent??"").toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,30);u(O)},[]),_("h1",{className:I(e.header,e[`header_${t.level}`]),children:_("button",{onClick:()=>void K(),ref:r,id:a,type:"button",children:t.children},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{cn as j}from"@d1vij/shit-i-always-use";import{jsxDEV as tt}from"react/jsx-dev-runtime";function y(t){let e=o();return tt("img",{className:j(e.image),alt:t.alt,title:t.title,src:t.src},void 0,!1,void 0,this)}import{cn as et}from"@d1vij/shit-i-always-use";import{jsxDEV as ot}from"react/jsx-dev-runtime";function b(t){let e=o();return ot("span",{className:et(e.italic),children:t.children},void 0,!1,void 0,this)}import{cn as J}from"@d1vij/shit-i-always-use";import{jsxDEV as g}from"react/jsx-dev-runtime";function s(t){let e=o(),r=t.type==="ordered"?"ol":"ul";return g(r,{className:J(e.list,t.type==="ordered"&&e.ordered_list,t.type==="unordered"&&e.unordered_list),children:t.children},void 0,!1,void 0,this)}function P(t){let e=o();return g("li",{className:J(e.list_item),children:t.children},void 0,!1,void 0,this)}import{cn as rt}from"@d1vij/shit-i-always-use";import{jsxDEV as nt}from"react/jsx-dev-runtime";function C(t){let e=o();return nt("p",{className:rt(e.paragraph),children:t.children},void 0,!1,void 0,this)}import{cn as lt}from"@d1vij/shit-i-always-use";import{jsxDEV as mt}from"react/jsx-dev-runtime";function f(t){let e=o();return mt("pre",{className:lt(e.preformatted),children:t.children},void 0,!1,void 0,this)}import{cn as st}from"@d1vij/shit-i-always-use";import{jsxDEV as at}from"react/jsx-dev-runtime";function N(t){let e=o();return at("span",{className:st(e.striked),children:t.children},void 0,!1,void 0,this)}import{cn as l}from"@d1vij/shit-i-always-use";import{jsxDEV as m}from"react/jsx-dev-runtime";function M(t){let e=o();return m("table",{className:l(e.table),children:t.children},void 0,!1,void 0,this)}function E(t){let e=o();return m("thead",{className:l(e.table_head),children:t.children},void 0,!1,void 0,this)}function L(t){let e=o();return m("tbody",{className:l(e.table_body),children:t.children},void 0,!1,void 0,this)}function k(t){let e=o();return m("tr",{className:l(e.table_row),children:t.children},void 0,!1,void 0,this)}function q(t){let e=o();return m("th",{className:l(e.table_head_cell),children:t.children},void 0,!1,void 0,this)}function F(t){let e=o();return m("td",{className:l(e.table_data),children:t.children},void 0,!1,void 0,this)}var pt={h1:(t)=>n({...t,level:1}),h2:(t)=>n({...t,level:2}),h3:(t)=>n({...t,level:3}),h4:(t)=>n({...t,level:4}),h5:(t)=>n({...t,level:5}),h6:(t)=>n({...t,level:6}),a:X,em:b,del:N,strong:h,code:i,blockquote:c,pre:f,p:C,ol:(t)=>s({...t,type:"ordered"}),ul:(t)=>s({...t,type:"unordered"}),li:P,img:y,table:M,thead:E,tbody:L,th:q,tr:k,td:F},S=pt;import{jsxDEV as ct}from"react/jsx-dev-runtime";function w({SourceComponent:t}){return ct(t,{components:S},void 0,!1,void 0,this)}import it from"@mdx-js/rollup";function yt({mdxPluginOptions:t}){return{name:"react-mdx-loader-plugin",enforce:"pre",config(e){return{...e,plugins:[it(t)]}}}}export{p as StyleContext,yt as MDXLoaderPlugin,w as MDXFromComponent};
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "https://github.com/d1vij/react-mdx-loader"
|
|
6
6
|
},
|
|
7
7
|
"homepage": "https://github.com/d1vij/react-mdx-loader",
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.1",
|
|
9
9
|
"description": "Supporting lib to create content driven sites using MDX",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"files": [
|