From a6aaeeedcfac42f4554a81e9ff7fd5dcb088274d Mon Sep 17 00:00:00 2001
From: 3846masa <3846masahiro+git@gmail.com>
Date: Mon, 4 Oct 2021 22:32:41 +0900
Subject: [PATCH 1/3] fix(docs): fix banner
---
README.md | 12 +++++-
demo/.remarkrc.js | 16 +-------
demo/package.json | 5 ++-
demo/rehype-rewrite.js | 30 +++++++++++++++
demo/yarn.lock | 85 ++++++++++++++++++++++--------------------
5 files changed, 90 insertions(+), 58 deletions(-)
create mode 100644 demo/rehype-rewrite.js
diff --git a/README.md b/README.md
index 577e7c57..a5718527 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,12 @@
# BlurHash SW
+
+
+
[](https://www.npmjs.com/package/blurhash-sw)
-[](LICENSE)
+[](./LICENSE)
[](https://github.com/RichardLitt/standard-readme)
The BlurHash API provided by ServiceWorker.
diff --git a/demo/.remarkrc.js b/demo/.remarkrc.js
index 47c1af53..934de09e 100644
--- a/demo/.remarkrc.js
+++ b/demo/.remarkrc.js
@@ -1,21 +1,9 @@
-import { raw } from 'hast-util-raw';
-
export default {
plugins: [
'remark-emoji',
['remark-rehype', { allowDangerousHtml: true }],
'rehype-raw',
- [
- 'rehype-rewrite',
- {
- rewrite: (node, index, parent) => {
- if (node.type === 'comment') {
- const parsed = raw({ type: 'raw', value: node.value });
- parent.children.splice(index, 1, ...parsed.children);
- }
- },
- },
- ],
+ './rehype-rewrite.js',
'@mapbox/rehype-prism',
['rehype-wrap', { wrapper: 'div.markdown-body' }],
[
@@ -41,7 +29,7 @@ export default {
pathname: '/blurhash-sw/',
},
],
- 'rehype-preset-minify',
+ // 'rehype-preset-minify',
'rehype-stringify',
],
};
diff --git a/demo/package.json b/demo/package.json
index 67edb533..e2855b86 100644
--- a/demo/package.json
+++ b/demo/package.json
@@ -10,11 +10,12 @@
"rehype-meta": "3.1.0",
"rehype-preset-minify": "6.0.0",
"rehype-raw": "6.1.0",
- "rehype-rewrite": "3.0.0",
"rehype-stringify": "9.0.2",
"rehype-wrap": "1.0.10",
"remark-cli": "10.0.0",
"remark-emoji": "3.0.1",
- "remark-rehype": "9.1.0"
+ "remark-rehype": "9.1.0",
+ "unist-util-flatmap": "1.0.0",
+ "unist-util-remove": "3.1.0"
}
}
diff --git a/demo/rehype-rewrite.js b/demo/rehype-rewrite.js
new file mode 100644
index 00000000..42601b1f
--- /dev/null
+++ b/demo/rehype-rewrite.js
@@ -0,0 +1,30 @@
+import flatMap from 'unist-util-flatmap';
+import { remove } from 'unist-util-remove';
+import { raw } from 'hast-util-raw';
+
+const remarkRewrite = () => {
+ return (tree) => {
+ return Promise.resolve(tree)
+ .then((tree) =>
+ flatMap(tree, (node) => {
+ if (node.type === 'comment') {
+ const parsed = raw({ type: 'raw', value: node.value });
+ return parsed.children;
+ }
+ return [node];
+ }),
+ )
+ .then((tree) =>
+ remove(tree, (node) => {
+ return node.type === 'element' && 'dataHidden' in node.properties;
+ }),
+ )
+ .then((tree) =>
+ remove(tree, (node) => {
+ return node.type === 'element' && node.tagName === 'p' && node.children.length === 0;
+ }),
+ );
+ };
+};
+
+export default remarkRewrite;
diff --git a/demo/yarn.lock b/demo/yarn.lock
index 02167139..d4ab35e9 100644
--- a/demo/yarn.lock
+++ b/demo/yarn.lock
@@ -1208,7 +1208,27 @@ hast-util-raw@7.2.0, hast-util-raw@^7.2.0:
web-namespaces "^2.0.0"
zwitch "^2.0.0"
-hast-util-select@5.0.1, hast-util-select@^5.0.0:
+hast-util-select@^4.0.0:
+ version "4.0.2"
+ resolved "https://registry.yarnpkg.com/hast-util-select/-/hast-util-select-4.0.2.tgz#ae3ef2860e02cda2ad3a2e72b47c1f5e8f44e9e7"
+ integrity sha512-8EEG2//bN5rrzboPWD2HdS3ugLijNioS1pqOTIolXNf67xxShYw4SQEmVXd3imiBG+U2bC2nVTySr/iRAA7Cjg==
+ dependencies:
+ bcp-47-match "^1.0.0"
+ comma-separated-tokens "^1.0.0"
+ css-selector-parser "^1.0.0"
+ direction "^1.0.0"
+ hast-util-has-property "^1.0.0"
+ hast-util-is-element "^1.0.0"
+ hast-util-to-string "^1.0.0"
+ hast-util-whitespace "^1.0.0"
+ not "^0.1.0"
+ nth-check "^2.0.0"
+ property-information "^5.0.0"
+ space-separated-tokens "^1.0.0"
+ unist-util-visit "^2.0.0"
+ zwitch "^1.0.0"
+
+hast-util-select@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/hast-util-select/-/hast-util-select-5.0.1.tgz#ed3788ad1a8d2d7f16a6bf8153ce9378edbe9d6d"
integrity sha512-cxnImmR/tN/ipvbwGrKtEErmy83K1xWx8Bu7nImiwTOJ7X/fW1X6L1241ux+MYUXDwx8GxrE4LVmXRlEnbQsQA==
@@ -1230,26 +1250,6 @@ hast-util-select@5.0.1, hast-util-select@^5.0.0:
unist-util-visit "^4.0.0"
zwitch "^2.0.0"
-hast-util-select@^4.0.0:
- version "4.0.2"
- resolved "https://registry.yarnpkg.com/hast-util-select/-/hast-util-select-4.0.2.tgz#ae3ef2860e02cda2ad3a2e72b47c1f5e8f44e9e7"
- integrity sha512-8EEG2//bN5rrzboPWD2HdS3ugLijNioS1pqOTIolXNf67xxShYw4SQEmVXd3imiBG+U2bC2nVTySr/iRAA7Cjg==
- dependencies:
- bcp-47-match "^1.0.0"
- comma-separated-tokens "^1.0.0"
- css-selector-parser "^1.0.0"
- direction "^1.0.0"
- hast-util-has-property "^1.0.0"
- hast-util-is-element "^1.0.0"
- hast-util-to-string "^1.0.0"
- hast-util-whitespace "^1.0.0"
- not "^0.1.0"
- nth-check "^2.0.0"
- property-information "^5.0.0"
- space-separated-tokens "^1.0.0"
- unist-util-visit "^2.0.0"
- zwitch "^1.0.0"
-
hast-util-to-html@^8.0.0:
version "8.0.2"
resolved "https://registry.yarnpkg.com/hast-util-to-html/-/hast-util-to-html-8.0.2.tgz#3445497508e2157a3169864eb43fb6ee929d3cbe"
@@ -2924,15 +2924,6 @@ rehype-remove-style-type-css@^3.0.0:
unified "^10.0.0"
unist-util-visit "^4.0.0"
-rehype-rewrite@3.0.0:
- version "3.0.0"
- resolved "https://registry.yarnpkg.com/rehype-rewrite/-/rehype-rewrite-3.0.0.tgz#ce08dc4031f59bdad60fbe07e20d927fe5477031"
- integrity sha512-JAuCiYaBtcQ3ZGQa6fh1MeDCMXx2HbYqmQ2gTdjo4zNPjEdigo8cbk+AxFMo36OfEUluBQozvNzMWcvfeIVAQg==
- dependencies:
- hast-util-select "5.0.1"
- unified "10.1.0"
- unist-util-visit "4.1.0"
-
rehype-sort-attribute-values@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/rehype-sort-attribute-values/-/rehype-sort-attribute-values-4.0.0.tgz#6a1baaced2f984ebed9aa201145c85cbc1c76880"
@@ -3468,7 +3459,7 @@ unified-engine@^9.0.0:
vfile-reporter "^7.0.0"
vfile-statistics "^2.0.0"
-unified@10.1.0, unified@^10.0.0:
+unified@^10.0.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/unified/-/unified-10.1.0.tgz#4e65eb38fc2448b1c5ee573a472340f52b9346fe"
integrity sha512-4U3ru/BRXYYhKbwXV6lU6bufLikoAavTwev89H5UxY8enDFaAT2VXmIXYNm6hb5oHPng/EXr77PVyDFcptbk5g==
@@ -3523,6 +3514,11 @@ unist-util-filter@^4.0.0:
unist-util-is "^5.0.0"
unist-util-visit-parents "^5.0.0"
+unist-util-flatmap@1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/unist-util-flatmap/-/unist-util-flatmap-1.0.0.tgz#f914ed6b36ff040afce938d848f379f88b94b448"
+ integrity sha512-IG32jcKJlhARCYT2LsYPJWdoXYkzz3ESAdl1aa2hn9Auh+cgUmU6wgkII4yCc/1GgeWibRdELdCZh/p3QKQ1dQ==
+
unist-util-generated@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unist-util-generated/-/unist-util-generated-2.0.0.tgz#86fafb77eb6ce9bfa6b663c3f5ad4f8e56a60113"
@@ -3550,6 +3546,15 @@ unist-util-position@^4.0.0:
resolved "https://registry.yarnpkg.com/unist-util-position/-/unist-util-position-4.0.1.tgz#f8484b2da19a897a0180556d160c28633070dbb9"
integrity sha512-mgy/zI9fQ2HlbOtTdr2w9lhVaiFUHWQnZrFF2EUoVOqtAUdzqMtNiD99qA5a1IcjWVR8O6aVYE9u7Z2z1v0SQA==
+unist-util-remove@3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/unist-util-remove/-/unist-util-remove-3.1.0.tgz#8042577e151dac989b7517976bfe4bac58f76ccd"
+ integrity sha512-rO/sIghl13eN8irs5OBN2a4RC10MsJdiePCfwrvnzGtgIbHcDXr2REr0qi9F2r/CIb1r9FyyFmcMRIGs+EyUFw==
+ dependencies:
+ "@types/unist" "^2.0.0"
+ unist-util-is "^5.0.0"
+ unist-util-visit-parents "^5.0.0"
+
unist-util-stringify-position@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/unist-util-stringify-position/-/unist-util-stringify-position-3.0.0.tgz#d517d2883d74d0daa0b565adc3d10a02b4a8cde9"
@@ -3581,15 +3586,6 @@ unist-util-visit-parents@^5.0.0:
"@types/unist" "^2.0.0"
unist-util-is "^5.0.0"
-unist-util-visit@4.1.0, unist-util-visit@^4.0.0:
- version "4.1.0"
- resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-4.1.0.tgz#f41e407a9e94da31594e6b1c9811c51ab0b3d8f5"
- integrity sha512-n7lyhFKJfVZ9MnKtqbsqkQEk5P1KShj0+//V7mAcoI6bpbUjh3C/OG8HVD+pBihfh6Ovl01m8dkcv9HNqYajmQ==
- dependencies:
- "@types/unist" "^2.0.0"
- unist-util-is "^5.0.0"
- unist-util-visit-parents "^5.0.0"
-
unist-util-visit@^2.0.0, unist-util-visit@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-2.0.3.tgz#c3703893146df47203bb8a9795af47d7b971208c"
@@ -3608,6 +3604,15 @@ unist-util-visit@^3.0.0:
unist-util-is "^5.0.0"
unist-util-visit-parents "^4.0.0"
+unist-util-visit@^4.0.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-4.1.0.tgz#f41e407a9e94da31594e6b1c9811c51ab0b3d8f5"
+ integrity sha512-n7lyhFKJfVZ9MnKtqbsqkQEk5P1KShj0+//V7mAcoI6bpbUjh3C/OG8HVD+pBihfh6Ovl01m8dkcv9HNqYajmQ==
+ dependencies:
+ "@types/unist" "^2.0.0"
+ unist-util-is "^5.0.0"
+ unist-util-visit-parents "^5.0.0"
+
universal-deep-strict-equal@^1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/universal-deep-strict-equal/-/universal-deep-strict-equal-1.2.2.tgz#0da4ac2f73cff7924c81fa4de018ca562ca2b0a7"
From e7e0ce8b84c1711dcb6d99b2656af7e65c9e4962 Mon Sep 17 00:00:00 2001
From: 3846masa <3846masahiro+git@gmail.com>
Date: Mon, 4 Oct 2021 23:12:45 +0900
Subject: [PATCH 2/3] fix(docs): fix badges
---
README.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/README.md b/README.md
index a5718527..d5d59b8c 100644
--- a/README.md
+++ b/README.md
@@ -25,10 +25,19 @@
/>
-->
+
+ [](https://www.npmjs.com/package/blurhash-sw) [](./LICENSE) [](https://github.com/RichardLitt/standard-readme) +
+ The BlurHash API provided by ServiceWorker. [https://github.com/3846masa/blurhash-sw](https://github.com/3846masa/blurhash-sw) From 7eb7b351c5800eccd9864104414867c28f3a7cdb Mon Sep 17 00:00:00 2001 From: 3846masa <3846masahiro+git@gmail.com> Date: Mon, 4 Oct 2021 23:17:57 +0900 Subject: [PATCH 3/3] fix(docs): change image attributes --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d5d59b8c..d228bac7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ @@ -287,6 +287,7 @@ To delay creating the BlurHash image, load the BlurHash URL in an img element. " loading="lazy" aria-hidden="true" + onerror="this.remove();" />