Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/steps/extract-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function extractDescription(hast) {
visit(hast, (node, idx, parent) => {
if (parent?.tagName === 'div' && node.tagName === 'p') {
const words = toString(node).trim().split(/\s+/);
if (words.length >= 10 || words.some((w) => w.length > 25 && !w.startsWith('http'))) {
if (words.length >= 10 || words.some((w) => w.length > 25 && !w.startsWith('http') && !w.startsWith('/'))) {
Comment thread
rofe marked this conversation as resolved.
desc = `${words.slice(0, 25).join(' ')}${words.length > 25 ? ' ...' : ''}`;
return EXIT;
}
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/content/description-gridtable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<head>
<title>Title.</title>
<link rel="canonical" href="https://helix-pages.com/description-gridtable">
<meta name="description" content="And here the real description from a text that has more than 10 words..">
<meta property="og:title" content="Title.">
<meta property="og:description" content="And here the real description from a text that has more than 10 words..">
<meta property="og:url" content="https://helix-pages.com/description-gridtable">
<meta property="og:image" content="https://helix-pages.com/default-meta-image.png?width=1200&#x26;format=pjpg&#x26;optimize=medium">
<meta property="og:image:secure_url" content="https://helix-pages.com/default-meta-image.png?width=1200&#x26;format=pjpg&#x26;optimize=medium">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Title.">
<meta name="twitter:description" content="And here the real description from a text that has more than 10 words..">
<meta name="twitter:image" content="https://helix-pages.com/default-meta-image.png?width=1200&#x26;format=pjpg&#x26;optimize=medium">
<link id="favicon" rel="icon" type="image/svg+xml" href="/icons/spark.svg">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/scripts.js" type="module"></script>
<link rel="stylesheet" href="/styles.css">
</head>
16 changes: 16 additions & 0 deletions test/fixtures/content/description-gridtable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Title.

Short sentence < 10 words.

+--------------------------------------------------------------------------------------+
| Stock Locator Model Overview |
+--------------------------------------------------------------------------------------+
| ## Details |
| |
| [/longlink/thathas/morethan/25/characters](/longlink/thathas/morethan/25/characters) |
| |
+--------------------------------------------------------------------------------------+
| More Text |
| |
| And here the real description from a text that has more than 10 words.. |
+--------------------------------------------------------------------------------------+
5 changes: 5 additions & 0 deletions test/rendering.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ describe('Rendering', () => {
await testRender('description', 'head');
});

it('uses correct description from a gridtable', async () => {
config = DEFAULT_CONFIG_EMPTY;
await testRender('description-gridtable', 'head');
});

it('uses correct description with blockquote', async () => {
config = DEFAULT_CONFIG_EMPTY;
await testRender('description-blockquote', 'head');
Expand Down