From 0c958962f8d0696969936b5e0df553f9182b3fc4 Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Thu, 3 Feb 2022 18:47:08 +0000 Subject: [PATCH 1/2] feat: lazy loading images --- .../__snapshots__/index.test.ts.snap | 24 +++++++++---------- .../src/remark/transformImage/index.ts | 2 +- .../__snapshots__/index.test.ts.snap | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap index bb3cfdabb0c5..d62f9f874f0f 100644 --- a/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__snapshots__/index.test.ts.snap @@ -14,27 +14,27 @@ exports[`transformImage plugin pathname protocol 1`] = ` exports[`transformImage plugin transform md images to 1`] = ` "![img](https://example.com/img.png) - + -{\\"img\\"} +{\\"img\\"} -{\\"img +{\\"img -{\\"img +{\\"img -{\\"img\\"} {\\"img\\"} +{\\"img\\"} {\\"img\\"} -{\\"img +{\\"img -{\\"site +{\\"site -{\\"img -{\\"img +{\\"img +{\\"img -{\\"img -{\\"img +{\\"img +{\\"img -{\\"img +{\\"img ## Heading diff --git a/packages/docusaurus-mdx-loader/src/remark/transformImage/index.ts b/packages/docusaurus-mdx-loader/src/remark/transformImage/index.ts index 97e9e841e58b..3dbb67e295b1 100644 --- a/packages/docusaurus-mdx-loader/src/remark/transformImage/index.ts +++ b/packages/docusaurus-mdx-loader/src/remark/transformImage/index.ts @@ -76,7 +76,7 @@ ${(e as Error).message}`; ); (jsxNode as Literal).type = 'jsx'; - jsxNode.value = ``; + jsxNode.value = ``; } async function ensureImageFileExist(imagePath: string, sourceFilePath: string) { diff --git a/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap b/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap index 5f176b716cf3..7d15b17f154b 100644 --- a/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/docusaurus-mdx-loader/src/remark/transformLinks/__tests__/__snapshots__/index.test.ts.snap @@ -44,7 +44,7 @@ exports[`transformAsset plugin transform md links to 1`] = ` Just staticAsset.pdf, and awesome staticAsset 2.pdf 'It is really "AWESOME"', but also coded staticAsset 3.pdf -{\\"Clickable +{\\"Clickable Stylized link to asset file From 31a8d066812e89c4682eeb860857eeedfa75cf0a Mon Sep 17 00:00:00 2001 From: johnnyreilly Date: Fri, 4 Feb 2022 11:41:01 +0000 Subject: [PATCH 2/2] feat: use real images --- .../__tests__/__fixtures__/static/img.png | Bin 0 -> 5142 bytes .../__tests__/__fixtures__/static2/img2.png | Bin 0 -> 4728 bytes .../__snapshots__/index.test.ts.snap | 24 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/static/img.png b/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/static/img.png index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f458149e3c8f53335f28fbc162ae67f55575c881 100644 GIT binary patch literal 5142 zcma)=cTf{R(}xj7f`AaDml%oxrAm_`5IRVc-jPtHML-0kDIiip57LWD@4bW~(nB|) z34|^sbOZqj<;8ct`Tl-)=Jw`pZtiw=e$UR_Mn2b8rM$y@hlq%XQe90+?|Mf68-Ux_ zzTBiDn~3P%oVt>{f$z+YC7A)8ak`PktoIXDkpXod+*gQW4fxTWh!EyR9`L|fi4YlH z{IyM;2-~t3s~J-KF~r-Z)FWquQCfG*TQy6w*9#k2zUWV-+tCNvjrtl9(o}V>-)N!) ziZgEgV>EG+b(j@ex!dx5@@nGZim*UfFe<+e;(xL|j-Pxg(PCsTL~f^br)4{n5?OU@ z*pjt{4tG{qBcDSa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zPl&YEoRwsk$8~Az>>djrdtp`PX z`Pu#IITS7lw07vx>YE<4pQ!&Z^7L?{Uox`CJnGjYLh1XN^tt#zY*0}tA*a=V)rf=&-kLgD|;t1D|ORVY}8 F{0H{b<4^zq literal 0 HcmV?d00001 diff --git a/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/static2/img2.png b/packages/docusaurus-mdx-loader/src/remark/transformImage/__tests__/__fixtures__/static2/img2.png index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..81923fc56250f9ccb038dd1c605e772846100290 100644 GIT binary patch literal 4728 zcmV-;5{K=HP)35VHbPD=^(Y6;?`BW{RiQ%nD4e zz)Gtoa`RM1E>wqJfut3LUcr@Dz*lGxjUfO8N&QjAcMeakuZSN4m=8090pR6%j$@-c zn6v=I0PX=i1Bhp%eg+2zhrPl(HUV@8lL){Nz=ibF1AyUd)L*%7a&R~^0_YAVAqoDa z;k7r?2F9+d930Mo0J?*TPlA6_BH0UoWH#!juFD)88b|=l&W{!9zQ8kp(D3^c5rOj$ zI5_M8pAKl}FR*sZJ3j$%rFrEQK%`Rb zyMswUrh+MLJR9|=t{WX3PKW?V-5=77t->4D9{$84uO8*qHuwkP*{Hv8-RavsuBRH-ebdz zyCil0;HtMpgrN&7J}!m;0{ZV5>$s4nA)*H)2jdSx08J7ui#-NMBPk7hHmGcnG<2+` z*!XO&>F=f?VVdScgZsjc04&w(liamu*kveiD%*}j0Kd!hnIiy40K3Ac0s+bl!vBnQ z`0h#C)})R2WdEyh0}3l9qH}O?J^%|9dS^>)-W&m`zX9Ga=`G1doaPuADyC%y7CiHsx``N-51R0FRW%zhr*43Iu;l@5*&v zSW6i`iH^&0NPYuZ|0el1SPu_u- zci;i|O5~%$J%Ee|r49+KW}|)tpra}4qQ*ct6p9Ae6$zT^J9;$eFH4kHl;+Bk1Rf3M z-<@G5Z_#f$GxdVT$GCtr?+x1St)b0|+J-yKqY4_)Q3ycB!)(;|>&EVTbNJpIQ^SCH z1M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SYe`3Fof`$FCS z2;sX94j+pEB>#YF+wrMv({*rg1aKh#z&#pp&VYl%x#0irv+P`xo}MuP0000 1`] = ` "![img](https://example.com/img.png) - + -{\\"img\\"} +{\\"img\\"} -{\\"img +{\\"img -{\\"img +{\\"img -{\\"img\\"} {\\"img\\"} +{\\"img\\"} {\\"img\\"} -{\\"img +{\\"img -{\\"site +{\\"site -{\\"img -{\\"img +{\\"img +{\\"img -{\\"img -{\\"img +{\\"img +{\\"img -{\\"img +{\\"img ## Heading