summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-06-29 08:31:10 +0300
committerAndrew Dolgov <[email protected]>2023-06-29 08:31:26 +0300
commit068a9401c33a78c3206a07c7a0ab9ceaf3998004 (patch)
tree7c54b4fbba128e46300d9e289a3658e95ba7807a
parent94cf638799dfce6fe746aa84ac4a698aebf38828 (diff)
extract category to article tag
-rw-r--r--init.php9
1 files changed, 9 insertions, 0 deletions
diff --git a/init.php b/init.php
index d653a95..acc5caa 100644
--- a/init.php
+++ b/init.php
@@ -276,6 +276,15 @@ class Af_Lemmy extends Plugin {
if (@$doc->loadHTML($article["content"])) {
$xpath = new DOMXPath($doc);
+ $categories = [];
+ $category_links = $xpath->query('//a[contains(@href, "/c/")]');
+
+ foreach ($category_links as $link) {
+ array_push($categories, $link->textContent);
+ }
+
+ array_push($article["tags"], ...FeedItem_Common::normalize_categories($categories));
+
$found = $this->inline_stuff($article, $doc, $xpath, $origin_domain);
$node = $doc->getElementsByTagName('body')->item(0);