-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Social: Added Bluesky to social previews (#39659)
* Update dependencies * Add Bluesky to social previews * Add changelogs * Update social-previews package to fix the Bluesky URL * Update pnpm-lock.yaml * Fix dependencies after rebase
- Loading branch information
1 parent
90f7d63
commit d5aee4b
Showing
13 changed files
with
125 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
projects/js-packages/publicize-components/changelog/add-bluesky-to-social-previews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Social: Added Bluesky to social previews |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
projects/js-packages/publicize-components/src/components/social-previews/bluesky.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { BlueskyPreviews } from '@automattic/social-previews'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { useSelect } from '@wordpress/data'; | ||
import { store as editorStore } from '@wordpress/editor'; | ||
import { decodeEntities } from '@wordpress/html-entities'; | ||
import useSocialMediaMessage from '../../hooks/use-social-media-message'; | ||
import { store, CONNECTION_SERVICE_BLUESKY } from '../../social-store'; | ||
|
||
const BlueskyPreview = props => { | ||
const { message } = useSocialMediaMessage(); | ||
const { content, siteName } = useSelect( select => { | ||
// @ts-expect-error -- `@wordpress/editor` is a nightmare to work with TypeScript | ||
const { getEditedPostAttribute } = select( editorStore ); | ||
// @ts-expect-error -- It says, "Property 'getUnstableBase' does not exist..." but it does | ||
const { getUnstableBase } = select( coreStore ); | ||
|
||
return { | ||
content: getEditedPostAttribute( 'content' ).split( '<!--more' )[ 0 ], | ||
siteName: decodeEntities( getUnstableBase().name ), | ||
}; | ||
}, [] ); | ||
|
||
const user = useSelect( select => { | ||
const { | ||
displayName, | ||
profileImage: avatarUrl, | ||
username: address, | ||
} = select( store ).getConnectionProfileDetails( CONNECTION_SERVICE_BLUESKY ); | ||
|
||
return { displayName, avatarUrl, address }; | ||
}, [] ); | ||
|
||
const firstMediaItem = props.media?.[ 0 ]; | ||
|
||
const customImage = firstMediaItem?.type.startsWith( 'image/' ) ? firstMediaItem.url : null; | ||
|
||
const blueskyConnections = useSelect( | ||
select => select( store ).getConnectionsByService( CONNECTION_SERVICE_BLUESKY ), | ||
[] | ||
); | ||
|
||
return ( | ||
<BlueskyPreviews | ||
{ ...props } | ||
siteName={ siteName } | ||
user={ user } | ||
description={ decodeEntities( content ) } | ||
customText={ decodeEntities( | ||
message || `${ props.title }\n\n${ content.replaceAll( /[\s\n]/g, ' ' ) }` | ||
) } | ||
customImage={ customImage } | ||
hidePostPreview={ ! blueskyConnections.length } | ||
/> | ||
); | ||
}; | ||
|
||
export default BlueskyPreview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/add-bluesky-to-social-previews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: enhancement | ||
|
||
Social: Added Bluesky to social previews |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/plugins/social/changelog/add-bluesky-to-social-previews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Added Bluesky to social previews |