Skip to content

Commit 3b94bfb

Browse files
committed
Add Open Graph article metadata tags to ArticlePage
1 parent aa2a0ef commit 3b94bfb

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

wcfsetup/install/files/lib/page/ArticlePage.class.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,42 @@ protected function setMetaTags(): void
219219
MetaTagHandler::getInstance()->addTag('description', 'description', $this->articleContent->metaDescription);
220220
}
221221

222+
MetaTagHandler::getInstance()->addTag(
223+
'article:published_time',
224+
'article:published_time',
225+
\gmdate('c', $this->article->time),
226+
true
227+
);
228+
MetaTagHandler::getInstance()->addTag(
229+
'article:modified_time',
230+
'article:modified_time',
231+
\gmdate('c', $this->article->time),
232+
true
233+
);
234+
MetaTagHandler::getInstance()->addTag(
235+
'article:author',
236+
'article:author',
237+
$this->article->getUserProfile()->getLink(),
238+
true
239+
);
240+
MetaTagHandler::getInstance()->addTag(
241+
'article:section',
242+
'article:section',
243+
$this->article->getCategory()->getTitle(),
244+
true
245+
);
246+
222247
if ($this->tags !== []) {
223248
$keywords = '';
249+
$i = 0;
224250
foreach ($this->tags as $tag) {
225251
if ($keywords !== '') {
226252
$keywords .= ', ';
227253
}
228254
$keywords .= $tag->name;
255+
256+
MetaTagHandler::getInstance()->addTag('article:tag' . $i, 'article:tag', $tag->name, true);
257+
$i++;
229258
}
230259
MetaTagHandler::getInstance()->addTag('keywords', 'keywords', $keywords);
231260
}

0 commit comments

Comments
 (0)