diff --git a/config/i18n/locales/english/links.json b/config/i18n/locales/english/links.json index 8e31b3b5a..8a173bd71 100644 --- a/config/i18n/locales/english/links.json +++ b/config/i18n/locales/english/links.json @@ -8,6 +8,7 @@ }, "learn-to-code-cta": "https://www.freecodecamp.org/learn/", "twitter": "https://twitter.com/freecodecamp", + "bluesky": "https://bsky.app/profile/freecodecamp.bsky.social", "footer": { "about": "https://www.freecodecamp.org/news/about/", "support": "https://www.freecodecamp.org/news/support/", diff --git a/cypress/e2e/english/author/author.cy.ts b/cypress/e2e/english/author/author.cy.ts index 1b4b3f083..6d1cb7a6f 100644 --- a/cypress/e2e/english/author/author.cy.ts +++ b/cypress/e2e/english/author/author.cy.ts @@ -19,6 +19,10 @@ const selectors = { link: "[data-test-label='x-link']", icon: "[data-test-label='x-icon']" }, + bluesky: { + link: "[data-test-label='bluesky-link']", + icon: "[data-test-label='bluesky-icon']" + }, facebook: { link: "[data-test-label='facebook-link']", icon: "[data-test-label='facebook-icon']" @@ -173,6 +177,8 @@ describe('Author page (Hashnode sourced)', () => { .find('svg') .should('have.attr', 'data-test-label', 'x-icon'); }); + + //TODO: Add a bluesky test }); }); diff --git a/src/_data/site.js b/src/_data/site.js index aa272c11f..efac6217b 100644 --- a/src/_data/site.js +++ b/src/_data/site.js @@ -7,13 +7,13 @@ const { currentLocale_i18nISOCode, siteURL } = require('../../config'); const getUsername = require('../../utils/get-username'); const translate = require('../../utils/translate'); -// Get X / Twitter profile based on links in config/i18n/locales/lang/links.json -- +// Get Bluesky profile based on links in config/i18n/locales/lang/links.json -- // falls back to English Twitter profile if one for the current UI locale // isn't found -const twitterURL = translate('links:twitter'); -const twitterHandle = twitterURL - ? `@${getUsername(twitterURL)}` - : '@freecodecamp'; +const blueskyURL = translate('links:bluesky'); +const blueskyHandle = blueskyURL + ? `@${getUsername(blueskyURL)}` + : '@freecodecamp.bsky.social'; const logoURL = 'https://cdn.freecodecamp.org/platform/universal/fcc_primary.svg'; const coverImageURL = @@ -27,8 +27,8 @@ module.exports = async () => { title: 'freeCodeCamp.org', facebook: 'https://www.facebook.com/freecodecamp', facebook_username: 'freecodecamp', - twitter_handle: twitterHandle, - twitter: `https://x.com/${twitterHandle}`, + bluesky_handle: blueskyHandle, + bluesky: `https://bsky.app/profile/${blueskyHandle}`, logo: logoURL, cover_image: coverImageURL, og_image: coverImageURL, diff --git a/src/_includes/assets/js/social-row.js b/src/_includes/assets/js/social-row.js index 7c5ab79dd..58bec0abf 100644 --- a/src/_includes/assets/js/social-row.js +++ b/src/_includes/assets/js/social-row.js @@ -1,57 +1,57 @@ document.addEventListener('DOMContentLoaded', () => { - const tweetButton = document.getElementById('tweet-btn'); + const shareButton = document.getElementById('tweet-btn'); const url = window.location; // Use Nunjucks URL encoding here in case titles have any special characters like backticks const title = '{{ post.title | urlencode }}'.replace(/'/g, '%27'); - const twitterHandles = { + const blueskyHandles = { originalPostAuthor: - '{{ post.original_post.primary_author.twitter_handle }}', - currentPostAuthor: '{{ post.primary_author.twitter_handle }}' // Author or translator depending on context + '{{ post.original_post.primary_author.bluesky_handle }}', + currentPostAuthor: '{{ post.primary_author.bluesky_handle }}' // Author or translator depending on context }; const isTranslation = Boolean('{{ post.original_post }}'); let thanks; // Customize the tweet message only in cases where the (original post) author - // or translator has a Twitter handle + // or translator has a Bluesky handle if ( isTranslation && - (twitterHandles.originalPostAuthor || twitterHandles.currentPostAuthor) + (blueskyHandles.originalPostAuthor || blueskyHandles.currentPostAuthor) ) { const names = { originalPostAuthor: '{{ post.original_post.primary_author.name }}', currentPostAuthor: '{{ post.primary_author.name }}' }; - // Use either an X /Twitter handle or name in the post text + // Use either a Bluesky handle or name in the post text thanks = encodeURIComponent(`{% t 'social-row.tweets.translation', { author: '${ - twitterHandles.originalPostAuthor - ? twitterHandles.originalPostAuthor + blueskyHandles.originalPostAuthor + ? blueskyHandles.originalPostAuthor : names.originalPostAuthor }', translator: '${ - twitterHandles.currentPostAuthor - ? twitterHandles.currentPostAuthor + blueskyHandles.currentPostAuthor + ? blueskyHandles.currentPostAuthor : names.currentPostAuthor }' } %}`); - } else if (!isTranslation && twitterHandles.currentPostAuthor) { + } else if (!isTranslation && blueskyHandles.currentPostAuthor) { // An original post on a source Ghost instance - // Only customize the post text if the author has an X / Twitter handle + // Only customize the post text if the author has an Bluesky handle thanks = encodeURIComponent(`{% t 'social-row.tweets.default', { - author: '${twitterHandles.currentPostAuthor}' + author: '${blueskyHandles.currentPostAuthor}' } %}`); } - const twitterIntentStr = thanks - ? `https://x.com/intent/post?text=${thanks}%0A%0A${title}%0A%0A${url}` - : `https://x.com/intent/post?text=${title}%0A%0A${url}`; + const blueSkyIntentStr = thanks + ? `https://bsky.app/intent/compose?text=${thanks}%0A%0A${title}%0A%0A${url}` + : `https://bsky.app/intent/compose?text=${title}%0A%0A${url}`; const windowOpenStr = `window.open( - '${twitterIntentStr}', - 'share-twitter', + '${blueSkyIntentStr}', + 'share-bluesky', 'width=550, height=235' ); return false;`; - tweetButton.setAttribute('onclick', windowOpenStr); + shareButton.setAttribute('onclick', windowOpenStr); }); diff --git a/src/_includes/partials/author-info.njk b/src/_includes/partials/author-info.njk index 17161f283..d6b4ec0fb 100644 --- a/src/_includes/partials/author-info.njk +++ b/src/_includes/partials/author-info.njk @@ -56,10 +56,10 @@ {% include "partials/icons/website.njk" %} {% endif %} - {% if author.twitter_handle %} + {% if author.bluesky_handle %}