Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blog): author header social icons #10222

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

OzakIOne
Copy link
Collaborator

@OzakIOne OzakIOne commented Jun 17, 2024

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Prepare for blog author page and also community request #10136

Also which UI UX should we adopt for the social icons ?

  • Open link in a new tab
  • Keep svg logo original colors or put a docusaurus color ?
  • Display the logos aside of the name or below ?
  • Darkmode ?

Visual mockup
design 1
design 2

Test Plan

Preview

add dogfood tests

Test links

https://deploy-preview-10222--docusaurus-2.netlify.app/blog/

Related issues/PRs

Fix #10136

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jun 17, 2024
Copy link

netlify bot commented Jun 17, 2024

[V2]

Name Link
🔨 Latest commit 685b2fe
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/66746a3d100aed0008a90148
😎 Deploy Preview https://deploy-preview-10222--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Jun 17, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 57 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 71 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 69 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 64 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 70 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report

Copy link

github-actions bot commented Jun 17, 2024

Size Change: +83 B (0%)

Total Size: 1.84 MB

Filename Size Change
website/build/assets/css/styles.********.css 112 kB +83 B (+0.07%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/codeTranslations.json 2 B
website/.docusaurus/docusaurus.config.mjs 27.1 kB
website/.docusaurus/globalData.json 123 kB
website/.docusaurus/i18n.json 930 B
website/.docusaurus/registry.js 304 kB
website/.docusaurus/routes.js 202 kB
website/.docusaurus/routesChunkNames.json 130 kB
website/.docusaurus/site-metadata.json 2.17 kB
website/build/assets/js/main.********.js 897 kB
website/build/index.html 38.1 kB

compressed-size-action

const link = url || (email && `mailto:${email}`) || undefined;
const renderSocialMedia = () => (
<div className={clsx(styles.authorSocial)}>
{(twitter as string) && <Twitter user={twitter as string} />}
Copy link
Collaborator Author

@OzakIOne OzakIOne Jun 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unknown keys such as twitter and github (and other keys that are not predefined) are typed as unknown which triggers TS to yell Type 'unknown' is not assignable to type 'ReactNode'
However as string might be an ugly solution, otherwise maybe update the Props type in theme classic.d.ts but which key should we define here ? (twitter?github? other random website?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use unknown keys in the first place

The type should contain a new "socials" attribute and we should validate those socials for both authors.yml and inline authors front matter

We should cover the most common socials (github, twitter/x, LinkedIn, SO, IG, website...) and allow unknown props (.unknown() in schema, [key: string]: string in type) in case users want to add extra social platforms

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the schema to allow a social object, however i'm not sure about the typing of unknown props if the user add a social website

@OzakIOne OzakIOne mentioned this pull request Jun 18, 2024
2 tasks
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how these social icons should display yet, but we need to discuss that.

We'd need many dogfood examples here to review, covering many distinct blog post situations: https://deploy-preview-10222--docusaurus-2.netlify.app/tests/blog/

One concern I have using React SVG components meant to be repeated on a page is the static markup duplication. It could be more optimized to use external SVGs, but let's figure that out later (see #5865)

Comment on lines 28 to 32
<a
href={twitterUrl}
target="_blank"
rel="noreferrer noopener"
className={clsx(styles.socialIcon)}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract AuthorSocialLink component, icon should be received as children

website/blog/authors.yml Outdated Show resolved Hide resolved
const link = url || (email && `mailto:${email}`) || undefined;
const renderSocialMedia = () => (
<div className={clsx(styles.authorSocial)}>
{(twitter as string) && <Twitter user={twitter as string} />}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use unknown keys in the first place

The type should contain a new "socials" attribute and we should validate those socials for both authors.yml and inline authors front matter

We should cover the most common socials (github, twitter/x, LinkedIn, SO, IG, website...) and allow unknown props (.unknown() in schema, [key: string]: string in type) in case users want to add extra social platforms

Comment on lines +110 to +114
{hasSocialMedia ? (
renderSocialMedia()
) : (
<small className="avatar__subtitle">{title}</small>
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should choose one or the other, but let's discuss and figure this out

@slorber slorber marked this pull request as draft June 20, 2024 14:52

// SVG Source: https://svgl.app/
function Github(props: SVGProps<SVGSVGElement>): JSX.Element {
const {colorMode} = useColorMode();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use this, hydration error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants