social-sharing-block
social-sharing-block copied to clipboard
add mastodon
would love to see mastodon in here, any interest in adding it? if so, want me to ope a PR?
also fyi the link in this repo about, https://nickdiego.com/projects/social-sharing-block is a 404
would love to see mastodon in here, any interest in adding it? if so, want me to open a PR?
Mastodon would be a great addition, but from my understanding, there is no uniform "share" link like there is for other social platforms. However, if you are aware of a way let me know, or feel free to open a PR.
also fyi the link in this repo about, https://nickdiego.com/projects/social-sharing-block is a 404
Thanks, I guess I never published the page 🤦♂️
I investigated a bit and am not sure there is a JS-free way to do it cleanly yet. Perhaps something convoluted with contenteditable and CSS animations/transitions is possible but it already feels fiddly just typing that, and visitor would still have to fill in their server/instance domain. Here are two existing repos I found, they both use JS to construct the URL out of a server/instance input:
Also in the prior art world, The docs page for Jan Boddez's Share on Mastodon plugin (see also WP plugin page, janboddez/share-on-mastodon) has some filter code to append WordPress tags as hashtags in the Custom Formatting section:
add_filter( 'share_on_mastodon_status', function( $status, $post ) {
$tags = get_the_tags( $post->ID );
if ( $tags ) {
$status .= "\n\n";
foreach ( $tags as $tag ) {
$status .= '#' . preg_replace( '/\s/', '', $tag->name ) . ' ';
}
$status = trim( $status );
}
return $status;
}, 11, 2 );
…Terence Eden shares a custom formatting code snippet for functions.php
with an amalgamation of tags code above and some other customizations in Better sharing of WordPress posts to Mastodon:
add_filter( 'share_on_mastodon_status', function( $status, $post ) {
// Create a short preview of the post
$status = "New blogging from me!\n\n";
$status .= "\"" . get_the_title($post) . "\"\n\n";
$status .= get_the_excerpt($post);
// Remove the … forced by the excerpt and replace with the Unicode symbol
$status = html_entity_decode($status);
// Add a link
$status .= "\n\nRead more: " . get_permalink( $post );
// Add tags
$tags = get_the_tags( $post->ID );
if ( $tags ) {
$status .= "\n\n";
foreach ( $tags as $tag ) {
$status .= '#' . preg_replace( '/\s/', '', $tag->name ) . ' ';
}
}
$status = trim( $status );
return $status;
}, 10, 2 );