Skip to content

Commit

Permalink
test: fix testing condition of source.filter option
Browse files Browse the repository at this point in the history
  • Loading branch information
webdiscus committed Nov 9, 2023
1 parent 54a43d5 commit 563b356
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 53 deletions.
70 changes: 25 additions & 45 deletions examples/simple-site/package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<meta property="og:image:type" content="image/png" />
<meta property="og:video" content="assets/video/video.697ef306.mp4" />
<meta property="og:video:type" content="video/mp4" />
<!-- test: the `content` w/o `property` attribute must not be resolved -->
<meta name="source" content="@images/apple.png">
</head>
<body>
<h1>Home</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<meta property="og:image:type" content="image/png" />
<meta property="og:video" content="@videos/video.mp4" />
<meta property="og:video:type" content="video/mp4" />
<!-- test: the `content` w/o `property` attribute must not be resolved -->
<meta name="source" content="@images/apple.png">
</head>
<body>
<h1>Home</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@ module.exports = {
{
tag: 'meta',
attributes: ['content'],
// TODO: resolve the `content` attribute when one of other attributes contains one of a value
// or try to resolve a relative path in the attribute
// oneOf: {
// name: ['twitter:image'],
// property: ['og:image', 'og:video'],
// itemprop: ['image', 'screenshot'],
// },
filter: ({ attributes }) => {
const attrName = 'property';
const attrValues = ['og:image', 'og:video']; // allowed values
if (attributes[attrName] && attrValues.indexOf(attributes[attrName]) < 0) {

if (!attributes[attrName] || attrValues.indexOf(attributes[attrName]) < 0) {
return false; // return false to disable processing
}
// return true or undefined to enable processing
Expand Down

0 comments on commit 563b356

Please sign in to comment.