Вікі-код для Документація
Остання зміна 2024/05/19 21:45 автором Ashterix
Показати останніх авторів
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{children/}} | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | {{velocity}} | ||
| 7 | {{html clean="false"}} | ||
| 8 | #set ($serverUrl = $xcontext.URLFactory.getServerURL($xcontext.context)) | ||
| 9 | #set ($hasImages = false) | ||
| 10 | #macro(addOpenGraphTagsForAttachedImages $pageReference) | ||
| 11 | #set ($page = $xwiki.getDocument($pageReference)) | ||
| 12 | #foreach ($attachment in $page.attachmentList) | ||
| 13 | #if ($attachment.isImage()) | ||
| 14 | #set ($hasImages = true) | ||
| 15 | #set ($path= $page.getAttachmentURL($attachment.filename)) | ||
| 16 | <meta property="og:image" content="$serverUrl$path" /> | ||
| 17 | #end | ||
| 18 | #end | ||
| 19 | #end | ||
| 20 | <meta property="og:url" content="$doc.externalURL"/> | ||
| 21 | <meta property="og:type" content="article" /> | ||
| 22 | <meta property="og:title" content="$tdoc.getRenderedTitle("plain/1.0")" /> | ||
| 23 | ## Add all current page's image attachments as "og:image". | ||
| 24 | #addOpenGraphTagsForAttachedImages($doc.documentReference) | ||
| 25 | ## If current page has no attached image, add the ones of the home page, if any. | ||
| 26 | #set ($wikiDescriptor = $services.wiki.getById($xcontext.wiki)) | ||
| 27 | #if (!$hasImages && $wikiDescriptor && $doc.documentReference != $wikiDescriptor.mainPageReference) | ||
| 28 | #addOpenGraphTagsForAttachedImages($wikiDescriptor.mainPageReference) | ||
| 29 | #end | ||
| 30 | {{/html}} | ||
| 31 | {{/velocity}} |