Skip to content

Commit

Permalink
feat(share): ✨ do not show share button if page is not a content page
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 committed Jan 1, 2025
1 parent 75af101 commit 8c29416
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 1 addition & 0 deletions includes/Components/CitizenComponentPageTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public function getTemplateData(): array {
*/
'is-uls-ready' => false,
'int-language-count' => $this->numLanguages,
'is-sharable' => $this->title->exists() && $this->title->isContentPage(),
'msg-citizen-share' => $this->localizer->msg( "citizen-share" )->text()
];
}
Expand Down
6 changes: 1 addition & 5 deletions resources/skins.citizen.scripts/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
* @return {void}
*/
function init() {
if ( !mw.config.get( 'wgIsArticle' ) ) {
return;
}

const shareButton = document.getElementById( 'citizen-share' );
if ( !shareButton ) {
mw.log.error( '[Citizen] Unable to find share button (#shareButton not found)' );
// Citizen will not add the citizen-share element if the share button is undesirable
return;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/PageTools.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
object data-page-actions
}}
<div class="page-actions">
{{>Share}}
{{#is-sharable}}{{>Share}}{{/is-sharable}}
{{#has-languages}}{{>PageTools__languages}}{{/has-languages}}
{{#is-visible}}
{{#data-portlets.data-views}}{{>Menu}}{{/data-portlets.data-views}}
Expand Down

0 comments on commit 8c29416

Please sign in to comment.