Skip to content

Commit

Permalink
fix: add back innerHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
dominique-pfister committed Jun 11, 2022
1 parent b4f67a6 commit 2d49f4d
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 4 deletions.
110 changes: 106 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/helix-shared-indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"dependencies": {
"hast-util-select": "5.0.2",
"hast-util-to-html": "8.0.3",
"hast-util-to-text": "3.1.1",
"jsep": "1.3.6",
"micromatch": "4.0.5",
Expand Down
2 changes: 2 additions & 0 deletions packages/helix-shared-indexer/src/index-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import jsep from 'jsep';
import rehypeParse from 'rehype-parse';
import { selectAll } from 'hast-util-select';
import { toText } from 'hast-util-to-text';
import { toHtml } from 'hast-util-to-html';
import { unified } from 'unified';

const helpers = {
Expand Down Expand Up @@ -45,6 +46,7 @@ const helpers = {
},
attribute: (elements, name) => elements.map((el) => el.properties[name]),
textContent: (elements) => elements.map((el) => toText(el)),
innerHTML: (elements) => elements.map((el) => el.children.map((child) => toHtml(child)).join('')),
match: (elements, re) => {
// todo: maybe base on function ?
const result = [];
Expand Down
5 changes: 5 additions & 0 deletions packages/helix-shared-indexer/test/index-resource.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ indices:
select: none
value: |
replace(path, '/test/specs/', '/')
paragraph:
select: main > div:nth-of-type(5)
value: |
innerHTML(el)
teaser:
select: main > div:nth-child(n+4) p
value: |
Expand Down Expand Up @@ -157,6 +161,7 @@ describe('Index Resource Tests', () => {
'member-without-get': '',
'missing-header': '',
'non-array-words': 'Mon, 22 Feb 2021 15:28:00 GMT',
paragraph: '\n <p>consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>\n ',
sourceHash: 'JJYxCM1NDG4ahJm9f',
teaser: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Ut',
title: 'I feel good',
Expand Down

0 comments on commit 2d49f4d

Please sign in to comment.