Skip to content

Commit f270cd3

Browse files
authored
[TldrTechBridge] Fix duplicate entries and empty sections (#4466)
1 parent 83c36a8 commit f270cd3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

bridges/TldrTechBridge.php

+8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public function collectData()
5757
continue;
5858
}
5959
$itemUrl = Url::fromString(self::URI . ltrim($child->href, '/'));
60+
if ($itemUrl == $locationUrl) {
61+
continue;
62+
}
6063
$this->extractItem($itemUrl);
6164
if (count($this->items) >= $limit) {
6265
break;
@@ -125,6 +128,11 @@ private function extractContent($url)
125128
}
126129
}
127130
}
131+
foreach ($content->find('section') as $section) {
132+
if (count($section->children()) == 0) {
133+
$content->removeChild($section);
134+
}
135+
}
128136
$title = $content->find('h2', 0);
129137
return [$content->innertext, $title->plaintext];
130138
}

0 commit comments

Comments
 (0)