diff --git a/.github/copilot/integrate-social-share-button.prompt.md b/.github/copilot/integrate-social-share-button.prompt.md index bea2b48..251b0b1 100644 --- a/.github/copilot/integrate-social-share-button.prompt.md +++ b/.github/copilot/integrate-social-share-button.prompt.md @@ -1,653 +1,209 @@ --- agent: agent description: > - Integrate SocialShareButton into any web project. Covers CDN (recommended), - npm (advanced), and React/Preact/Qwik Wrapper Components (optional). Framework-specific - steps for CRA, Next.js App Router, Next.js Pages Router, Vite/Vue/Angular, - Preact, Qwik, and Vanilla HTML. Use this skill whenever a developer asks how to add the - share button to their project. + Automatically integrate @aossie-org/social-share-button into a client web project + with zero manual steps except specifying where to place the button. --- # SocialShareButton — Integration Skill -You are helping a developer integrate the **SocialShareButton** library -(`social-share-button-aossie`) into their project. Follow these rules strictly. +## Goal ---- - -> 🚫 **IMPORTANT:** Do NOT create new files like `ShareButton.jsx` or `ShareButton.tsx`! -> ✅ Add code directly to the developer's **existing** component (Header, Navbar, etc.) -> 📄 **Exception:** If a separate file is needed (e.g. a dedicated share component), follow **Method 3 — React Wrapper Component** exclusively. - ---- - -## How to respond - -The README defines **3 installation methods**. Ask (or infer) which the developer wants: - -| Method | When to use | -| ------------------------------------------------------- | ------------------------------------------------------------------------- | -| **Method 1 — CDN (Recommended)** | Most projects. No build step needed. Load via ` - -
- - - - {children} - --``` + ``` +- **NPM Method**: Install dependency (`npm i @aossie-org/social-share-button`, `pnpm add`, `yarn add`, or `bun add`). ---- +### 4. Ask User Placement & Style -### CDN — Create React App +- **Method Preference**: Always recommend **CDN** over NPM. +- **Placement Prompting**: Ask the user explicitly: + - Which file they want to import/place the Social Share button in. + - The exact placement location inside that file (e.g., to the left of, right of, above, or below a specific existing component or DOM element, such as next to a logo, navigation items, or primary action buttons). +- **React / Next.js Guidance**: Always recommend placing in the **Navbar / Header** every time when integrating React or Next.js using CDN. +- **Vanilla HTML Guidance**: For HTML projects, ask for their main HTML file (e.g., `index.html`) and exact placement relative to existing HTML elements. +- **Style Options**: Prompt for preferred button style (`default` | `round` | `square`). -**Step 1:** Add CDN to `public/index.html`: +### 5. Inject Integration Code into Existing Files -```html -
- - -
-```
-
-**Step 2:** Open an **existing** component that renders on every page — typically `src/components/Header.jsx`, `src/layouts/MainLayout.jsx`, or your root `App.jsx`. Add the snippet below to that component so the share button is consistently available across your app.
-
-```jsx
-import { useEffect, useRef } from "react";
-import { useLocation } from "react-router-dom"; // omit if not using React Router
-
-// ⬇️ Replace 'Header' with the name of the component where you want the
-// share button to appear — e.g. Navbar, MainLayout, App, etc.
-function Header() {
- const shareButtonRef = useRef(null);
- const initRef = useRef(false);
- const { pathname } = useLocation(); // omit if not using React Router
-
- useEffect(() => {
- if (initRef.current || !window.SocialShareButton) return;
-
- shareButtonRef.current = new window.SocialShareButton({
- container: "#share-button",
- });
- initRef.current = true;
-
- return () => {
- if (shareButtonRef.current?.destroy) {
- shareButtonRef.current.destroy();
- }
- initRef.current = false;
- };
- }, []);
-
- // Keep the share URL and title in sync with the current route
- useEffect(() => {
- if (shareButtonRef.current) {
- shareButtonRef.current.updateOptions({
- url: window.location.href,
- title: document.title,
- });
- }
- }, [pathname]); // re-runs on every client-side route change
-
- return (
-
- - -
-