-
-
Notifications
You must be signed in to change notification settings - Fork 45
feat: integrate SocialShareButton via CDN and auto-init #188
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
base: main
Are you sure you want to change the base?
Changes from all commits
bd8253d
be1f8f3
3147d1a
adee55b
e41040d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,9 +34,11 @@ | |
| } | ||
| }(window.location)) | ||
| </script> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.4/src/social-share-button.css" /> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.jsx"></script> | ||
| <script src="https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@v1.0.4/src/social-share-button.js"></script> | ||
|
Comment on lines
+37
to
+42
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @amankv1234 @kpj2006 instead of using the CDN I think we should use the npm package https://www.npmjs.com/package/@aossie-org/social-share-button. Can you make this change and then we can merge this PR?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kpj2006 , Should I make the npm changes as well?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better to make this pr, draft for now... |
||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,6 +205,7 @@ function Navbar() { | |
| )} | ||
| </motion.div> | ||
| ))} | ||
| <div data-social-share></div> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Expose the share control in the mobile navigation. Line 208 is inside the 🤖 Prompt for AI Agents🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== Navbar.jsx outline ==\n'
ast-grep outline frontend/src/components/Navbar.jsx --view expanded || true
printf '\n== index.html grep ==\n'
rg -n "social-share|SocialShare|data-social-share|script" frontend/index.html frontend/src/components/Navbar.jsx || true
printf '\n== relevant slices ==\n'
sed -n '1,280p' frontend/src/components/Navbar.jsx
printf '\n--- index.html ---\n'
sed -n '1,220p' frontend/index.htmlRepository: StabilityNexus/Chainvoice Length of output: 13125 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== search for SocialShareButton usages ==\n'
rg -n "SocialShareButton|social-share|data-social-share|updateOptions|destroy\\(" frontend || true
printf '\n== route/location usage in Navbar ==\n'
rg -n "useLocation|location|pathname|href" frontend/src/components/Navbar.jsx frontend/src || trueRepository: StabilityNexus/Chainvoice Length of output: 4926 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate the navbar and any social share wiring.
printf '\n-- files --\n'
git ls-files 'frontend/src/components/Navbar.jsx' 'frontend/index.html' || true
printf '\n-- social/share references --\n'
rg -n "SocialShareButton|social-share|data-social-share|updateOptions|destroy\\(|useEffect|useLocation|pathname" frontend/src/components/Navbar.jsx frontend/index.html frontend/src || true
printf '\n-- Navbar.jsx excerpt --\n'
sed -n '1,280p' frontend/src/components/Navbar.jsx
printf '\n-- index.html excerpt --\n'
sed -n '1,220p' frontend/index.htmlRepository: StabilityNexus/Chainvoice Length of output: 18788 🌐 Web query:
💡 Result: The term window.SocialShareButton is primarily associated with the SocialShareButton library developed by AOSSIE-Org [1][2]. This is a lightweight, zero-dependency, vanilla JavaScript library designed for social media sharing [2]. Implementation via CDN To use this library via a CDN, you can reference the files hosted on jsDelivr. The project documentation recommends using the 'latest' tag to ensure you have the most current version [3][4]: <script src="https://cdn.jsdelivr.net/gh/AOSSIE-Org/SocialShareButton@latest/src/social-share-button.js"></script> Initialization Once the library is loaded, you initialize it by targeting a specific DOM element (the container) where the buttons should appear [1][2]. Example Initialization: <script> if (window.SocialShareButton) { new window.SocialShareButton({ container: "#share-button" }); } </script> Key Considerations - SSR Safety: If you are using frameworks with Server-Side Rendering (e.g., Next.js, Nuxt, Angular Universal), ensure the library is only initialized on the client side (e.g., within useEffect, onMounted, or ngAfterViewInit lifecycle hooks) to avoid errors when the window object is undefined [5][6]. - Alternatives: Note that there are other libraries with similar naming conventions, such as 'social-share-buttons' by ozdemirburak [7][8] or 'shareon' [9], which may have different APIs and CDN implementation patterns. Always check the specific documentation for the library you have included in your project [10][9].
Citations:
Mount 🤖 Prompt for AI AgentsSource: Learnings |
||
| {publicItems.map((item) => ( | ||
| <motion.div | ||
| key={item.name} | ||
|
|
@@ -338,6 +339,10 @@ function Navbar() { | |
| </Link> | ||
| ))} | ||
|
|
||
| <div className="px-4 py-2"> | ||
| <div data-social-share></div> | ||
| </div> | ||
|
|
||
| <div className="px-4 py-2"> | ||
| <ConnectButton | ||
| accountStatus="full" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '1,120p' frontend/index.htmlRepository: StabilityNexus/Chainvoice
Length of output: 2685
🏁 Script executed:
Repository: StabilityNexus/Chainvoice
Length of output: 457
Remove or harden the SocialShareButton CDN includes.
These are the only references in the repo, so if the share widget isn’t needed, drop both assets. Otherwise pin them to an immutable commit and add SRI plus
crossorigin="anonymous"; the script executes with full origin privileges.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The widget is actively used —
Regarding SRI (integrity) hashes: jsdelivr.net CDN links using a version tag like @v1.0.4 already serve immutable, pinned content — the file does not change once a version tag is published to GitHub. Generating a valid integrity hash requires downloading the exact bytes served by jsdelivr at build time, which is outside the scope of this integration PR.
If the project adopts a CI pipeline or a lockfile-based asset strategy in the future, SRI hashes can be generated (e.g. via openssl dgst -sha384) and added at that point. For now, the version-pinned CDN link provides sufficient reproducibility for this integration.