@cutting/markdown 0.1.4 → 0.1.6
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/esm/bundleMarkdown.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +22 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundleMarkdown.d.ts","sourceRoot":"","sources":["../../src/bundleMarkdown.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"bundleMarkdown.d.ts","sourceRoot":"","sources":["../../src/bundleMarkdown.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,OAAO,KAAK,EAAe,eAAe,EAAE,MAAM,SAAS,CAAC;AAiB5D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAIF,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAE3C,wBAAsB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0D1E;AAED,MAAM,MAAM,QAAQ,GAAG,eAAe,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE,wBAAsB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CA0BzE"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"front-matter";import{bundleMDX as t}from"mdx-bundler";import r from"remark-footnotes";import i from"remark-mdx-images";import o from"remark-breaks";import{visit as m}from"unist-util-visit";import n from"reading-time";import{join as a}from"path";import s from"remark-slug";import{readFile as p,readdir as l}from"fs/promises";import{DateTime as c}from"luxon";import u from"rehype-prism-plus";import d from"rehype-raw";import f from"rehype-preset-minify";import g from"remark-math";import x from"remark-gfm";import h from"remark-autolink-headings";import w from"rehype-mathjax";function y(){return e=>m(e,"code",((e,t,r)=>{const i=e.lang||"";let o="",m="";i.includes(":")&&(o=i.slice(0,i.search(":")),m=i.slice(i.search(":")+1,i.length)),m&&(r.children.splice(t,0,{type:"mdxJsxFlowElement",name:"div",attributes:[{type:"mdxJsxAttribute",name:"className",value:"remark-code-title"}],children:[{type:"text",value:m}],data:{_xdmExplicitJsx:!0}}),e.lang=o)}))}const k=process.cwd();async function v(e){const m=await p(e,"utf-8"),l=await async function(){const{visit:e}=await import("unist-util-visit"),{escapeHtml:t}=await import("@cutting/util");return function(){return r=>e(r,"inlineCode",(e=>{e.type="html",e.value=`<code class="language-typescript cutting-inline">${t(e.value)}</code>`}))}}();process.env.ESBUILD_BINARY_PATH=a(k,"node_modules","esbuild","bin","esbuild"),process.env.NODE_ENV="production";const c=await t({source:m,mdxOptions:e=>(e.remarkPlugins=[...e.remarkPlugins??[],i,o,y,l,[r,{inlineNotes:!0}],[h,{behavior:"wrap"}],s,x,g],e.rehypePlugins=[...e.rehypePlugins??[],w,[u,{ignoreMissing:!0}],f,[d,{passThrough:["mdxjsEsm","mdxFlowExpression","mdxTextExpression","mdxJsxFlowElement","mdxJsxTextElement"]}]],e)}).catch((e=>{throw console.error(e),e}));return{...c,frontmatter:{meta:{readingTime:n(c.code),...c.frontmatter.meta}}}}async function E(t){const r=await l(t,{withFileTypes:!0}),i=[];for(const o of r){const r=await p(a(t,o.name,"index.md")),{attributes:{meta:{date:m,slug:n,...s}}}=e(r.toString());i.push({slug:o.name.replace(/\.mdx/,""),date:new Date(m).toISOString(),formattedDate:c.fromISO(m).toLocaleString(c.DATE_FULL),...s})}return i.sort(((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime()))}export{v as bundleMarkdown,E as getPosts};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/remark/remark-code-title.ts","../../src/bundleMarkdown.ts","../../src/remark/remark-inline-code-language.ts"],"sourcesContent":["import { visit } from 'unist-util-visit';\n\ntype Tree = Parameters<typeof visit>[0];\n\nexport function remarkCodeTitles() {\n return (tree: Tree): void =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n visit(tree, 'code', (node: { lang?: string }, index: number, parent: any) => {\n const nodeLang = node.lang || '';\n let language = '';\n let title = '';\n\n if (nodeLang.includes(':')) {\n language = nodeLang.slice(0, nodeLang.search(':'));\n title = nodeLang.slice(nodeLang.search(':') + 1, nodeLang.length);\n }\n\n if (!title) {\n return;\n }\n\n const className = 'remark-code-title';\n\n const titleNode = {\n type: 'mdxJsxFlowElement',\n name: 'div',\n attributes: [{ type: 'mdxJsxAttribute', name: 'className', value: className }],\n children: [{ type: 'text', value: title }],\n data: { _xdmExplicitJsx: true },\n };\n\n parent.children.splice(index, 0, titleNode);\n node.lang = language;\n });\n}\n","import parseFrontMatter from 'front-matter';\nimport { bundleMDX } from 'mdx-bundler';\nimport remarkFootnotes from 'remark-footnotes';\nimport remarkMdxImages from 'remark-mdx-images';\nimport remarkBreaks from 'remark-breaks';\nimport { remarkCodeTitles } from './remark/remark-code-title';\nimport { remarkInlineCodeLanguageCreator } from './remark/remark-inline-code-language';\nimport type { FrontMatter, FrontMatterMeta } from './types';\nimport readingTime from 'reading-time';\nimport { join } from 'path';\nimport { readFile, readdir } from 'fs/promises';\nimport { DateTime } from 'luxon';\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/remark/remark-code-title.ts","../../src/bundleMarkdown.ts","../../src/remark/remark-inline-code-language.ts"],"sourcesContent":["import { visit } from 'unist-util-visit';\n\ntype Tree = Parameters<typeof visit>[0];\n\nexport function remarkCodeTitles() {\n return (tree: Tree): void =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n visit(tree, 'code', (node: { lang?: string }, index: number, parent: any) => {\n const nodeLang = node.lang || '';\n let language = '';\n let title = '';\n\n if (nodeLang.includes(':')) {\n language = nodeLang.slice(0, nodeLang.search(':'));\n title = nodeLang.slice(nodeLang.search(':') + 1, nodeLang.length);\n }\n\n if (!title) {\n return;\n }\n\n const className = 'remark-code-title';\n\n const titleNode = {\n type: 'mdxJsxFlowElement',\n name: 'div',\n attributes: [{ type: 'mdxJsxAttribute', name: 'className', value: className }],\n children: [{ type: 'text', value: title }],\n data: { _xdmExplicitJsx: true },\n };\n\n parent.children.splice(index, 0, titleNode);\n node.lang = language;\n });\n}\n","import parseFrontMatter from 'front-matter';\nimport { bundleMDX } from 'mdx-bundler';\nimport remarkFootnotes from 'remark-footnotes';\nimport remarkMdxImages from 'remark-mdx-images';\nimport remarkBreaks from 'remark-breaks';\nimport { remarkCodeTitles } from './remark/remark-code-title';\nimport { remarkInlineCodeLanguageCreator } from './remark/remark-inline-code-language';\nimport type { FrontMatter, FrontMatterMeta } from './types';\nimport readingTime from 'reading-time';\nimport { join } from 'path';\nimport remarkSlug from 'remark-slug';\nimport { readFile, readdir } from 'fs/promises';\nimport { DateTime } from 'luxon';\nimport rehypePrismPlus from 'rehype-prism-plus';\nimport rehypeRaw from 'rehype-raw';\nimport rehypePresetMinify from 'rehype-preset-minify';\nimport remarkMath from 'remark-math';\nimport remarkGfm from 'remark-gfm';\nimport remarkAutolinkHeadings from 'remark-autolink-headings';\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport rehypeMathjax from 'rehype-mathjax';\n\nexport type MarkdownAttributes = {\n title: string;\n};\n\nconst root = process.cwd();\n\ntype Matter = ReturnType<typeof bundleMDX>;\n\nexport async function bundleMarkdown(markdownPath: string): Promise<Matter> {\n const source = await readFile(markdownPath, 'utf-8');\n\n const remarkInlineCodeLanguage = await remarkInlineCodeLanguageCreator();\n\n process.env.ESBUILD_BINARY_PATH = join(root, 'node_modules', 'esbuild', 'bin', 'esbuild');\n process.env.NODE_ENV = 'production';\n\n const post = await bundleMDX({\n source,\n mdxOptions(options) {\n options.remarkPlugins = [\n ...(options.remarkPlugins ?? []),\n remarkMdxImages,\n remarkBreaks,\n remarkCodeTitles,\n remarkInlineCodeLanguage,\n [remarkFootnotes, { inlineNotes: true }],\n [remarkAutolinkHeadings, { behavior: 'wrap' }],\n remarkSlug,\n remarkGfm,\n remarkMath,\n ];\n options.rehypePlugins = [\n ...(options.rehypePlugins ?? []),\n rehypeMathjax,\n [rehypePrismPlus, { ignoreMissing: true }],\n rehypePresetMinify,\n [\n rehypeRaw,\n {\n passThrough: [\n 'mdxjsEsm',\n 'mdxFlowExpression',\n 'mdxTextExpression',\n 'mdxJsxFlowElement',\n 'mdxJsxTextElement',\n ],\n },\n ],\n ];\n\n return options;\n },\n }).catch((e) => {\n console.error(e);\n throw e;\n });\n\n return {\n ...post,\n frontmatter: {\n meta: {\n readingTime: readingTime(post.code),\n ...post.frontmatter.meta,\n },\n },\n };\n}\n\nexport type PostData = FrontMatterMeta & { formattedDate: string };\n\nexport async function getPosts(postsRootPath: string): Promise<PostData[]> {\n const postsPath = await readdir(postsRootPath, {\n withFileTypes: true,\n });\n\n const posts: PostData[] = [];\n\n for (const dirent of postsPath) {\n const file = await readFile(join(postsRootPath, dirent.name, 'index.md'));\n\n const {\n attributes: {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n meta: { date, slug, ...meta },\n },\n } = parseFrontMatter(file.toString()) as { attributes: FrontMatter };\n\n posts.push({\n slug: dirent.name.replace(/\\.mdx/, ''),\n date: new Date(date).toISOString(),\n formattedDate: DateTime.fromISO(date).toLocaleString(DateTime.DATE_FULL),\n ...meta,\n });\n }\n\n return posts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());\n}\n","// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport async function remarkInlineCodeLanguageCreator() {\n const { visit } = await import('unist-util-visit');\n const { escapeHtml } = await import('@cutting/util');\n\n return function remarkInlineCodeLanguage() {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (tree: any): void =>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n visit(tree, 'inlineCode', (node: any) => {\n const className = `language-typescript`;\n\n node.type = 'html';\n node.value = `<code class=\"${className} cutting-inline\">${escapeHtml(node.value)}</code>`;\n });\n };\n}\n"],"names":["remarkCodeTitles","tree","visit","node","index","parent","nodeLang","lang","language","title","includes","slice","search","length","children","splice","type","name","attributes","value","data","_xdmExplicitJsx","root","process","cwd","async","bundleMarkdown","markdownPath","source","readFile","remarkInlineCodeLanguage","import","escapeHtml","remarkInlineCodeLanguageCreator","env","ESBUILD_BINARY_PATH","join","NODE_ENV","post","bundleMDX","mdxOptions","options","remarkPlugins","remarkMdxImages","remarkBreaks","remarkFootnotes","inlineNotes","remarkAutolinkHeadings","behavior","remarkSlug","remarkGfm","remarkMath","rehypePlugins","rehypeMathjax","rehypePrismPlus","ignoreMissing","rehypePresetMinify","rehypeRaw","passThrough","catch","e","console","error","frontmatter","meta","readingTime","code","getPosts","postsRootPath","postsPath","readdir","withFileTypes","posts","dirent","file","date","slug","parseFrontMatter","toString","push","replace","Date","toISOString","formattedDate","DateTime","fromISO","toLocaleString","DATE_FULL","sort","a","b","getTime"],"mappings":"slBAIgBA,IACd,OAAQC,GAENC,EAAMD,EAAM,QAAQ,CAACE,EAAyBC,EAAeC,KAC3D,MAAMC,EAAWH,EAAKI,MAAQ,GAC9B,IAAIC,EAAW,GACXC,EAAQ,GAERH,EAASI,SAAS,OACpBF,EAAWF,EAASK,MAAM,EAAGL,EAASM,OAAO,MAC7CH,EAAQH,EAASK,MAAML,EAASM,OAAO,KAAO,EAAGN,EAASO,SAGvDJ,IAcLJ,EAAOS,SAASC,OAAOX,EAAO,EARZ,CAChBY,KAAM,oBACNC,KAAM,MACNC,WAAY,CAAC,CAAEF,KAAM,kBAAmBC,KAAM,YAAaE,MAL3C,sBAMhBL,S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C,MAAMW,KAAEA,EAAIC,KAAEA,KAASZ,KAEvBa,EAAiBH,EAAKI,YAE1BN,EAAMO,KAAK,CACTH,KAAMH,EAAOxD,KAAK+D,QAAQ,QAAS,IACnCL,KAAM,IAAIM,KAAKN,GAAMO,cACrBC,cAAeC,EAASC,QAAQV,GAAMW,eAAeF,EAASG,cAC3DvB,GAEN,CAED,OAAOQ,EAAMgB,MAAK,CAACC,EAAGC,IAAM,IAAIT,KAAKS,EAAEf,MAAMgB,UAAY,IAAIV,KAAKQ,EAAEd,MAAMgB,WAC5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cutting/markdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dagda1/cuttingedge.git"
|
|
@@ -14,41 +14,43 @@
|
|
|
14
14
|
"format": "^0.2.2",
|
|
15
15
|
"front-matter": "^4.0.2",
|
|
16
16
|
"github-slugger": "^2.0.0",
|
|
17
|
-
"esbuild": "^0.19.
|
|
17
|
+
"esbuild": "^0.19.5",
|
|
18
18
|
"image-size": "^1.0.2",
|
|
19
19
|
"js-yaml": "^4.1.0",
|
|
20
|
-
"katex": "^0.16.
|
|
20
|
+
"katex": "^0.16.9",
|
|
21
21
|
"leva": "^0.9.35",
|
|
22
|
-
"
|
|
22
|
+
"luxon": "^3.4.4",
|
|
23
|
+
"maath": "^0.10.4",
|
|
23
24
|
"mathjax-full": "3.2.2",
|
|
24
25
|
"mdast-util-to-markdown": "^2.1.0",
|
|
25
26
|
"mdx-bundler": "^9.2.1",
|
|
26
27
|
"reading-time": "^1.5.0",
|
|
27
|
-
"rehype-
|
|
28
|
-
"rehype-
|
|
29
|
-
"rehype-
|
|
30
|
-
"rehype-mathjax": "^4.0.3",
|
|
28
|
+
"rehype-citation": "^2.0.0",
|
|
29
|
+
"rehype-highlight": "^7.0.0",
|
|
30
|
+
"rehype-mathjax": "^5.0.0",
|
|
31
31
|
"rehype-prism-plus": "^1.6.3",
|
|
32
|
-
"rehype-slug": "^5.1.0",
|
|
33
32
|
"rehype-toc": "^3.0.2",
|
|
34
|
-
"remark-
|
|
33
|
+
"remark-autolink-headings": "^7.0.1",
|
|
34
|
+
"remark-breaks": "^4.0.0",
|
|
35
35
|
"remark-gfm": "^3.0.1",
|
|
36
36
|
"remark-footnotes": "^4.0.1",
|
|
37
|
-
"remark-math": "^
|
|
37
|
+
"remark-math": "^6.0.0",
|
|
38
38
|
"remark-mdx-images": "^2.0.0",
|
|
39
|
-
"rehype-preset-minify": "^
|
|
40
|
-
"rehype-raw": "^
|
|
39
|
+
"rehype-preset-minify": "^7.0.0",
|
|
40
|
+
"rehype-raw": "^7.0.0",
|
|
41
|
+
"remark-slug": "^7.0.1",
|
|
41
42
|
"resize-observer-polyfill": "^1.5.1",
|
|
42
43
|
"unist-util-visit": "^5.0.0",
|
|
43
|
-
"@cutting/util": "4.58.
|
|
44
|
+
"@cutting/util": "4.58.5"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"@cutting/
|
|
50
|
-
"@cutting/
|
|
51
|
-
"@cutting/
|
|
47
|
+
"@types/luxon": "^3.3.4",
|
|
48
|
+
"eslint": "8.53.0",
|
|
49
|
+
"typescript": "5.2.2",
|
|
50
|
+
"@cutting/devtools": "4.63.4",
|
|
51
|
+
"@cutting/eslint-config": "4.45.2",
|
|
52
|
+
"@cutting/tsconfig": "4.40.3",
|
|
53
|
+
"@cutting/useful-types": "4.40.2"
|
|
52
54
|
},
|
|
53
55
|
"files": [
|
|
54
56
|
"dist/**/*",
|