@@ -57,7 +57,6 @@ const BentoGrid = ({
57
57
portfolioUrl : string ;
58
58
} ) => {
59
59
const [ bentoLink , setBentoLink ] = useState < string > ( "" ) ;
60
- const [ apiLink , setApiLink ] = useState < string > ( "" ) ;
61
60
62
61
const getColor = ( value : number ) => {
63
62
switch ( value ) {
@@ -108,131 +107,22 @@ const BentoGrid = ({
108
107
109
108
await uploadBytes ( storageRef , blob ) ;
110
109
const downloadUrl = await getDownloadURL ( storageRef ) ;
111
-
112
- const newApiLink = `https://opbento.vercel.app/api/bento?n=${ encodeURIComponent (
113
- name
114
- ) } &i=${ encodeURIComponent (
115
- imageUrl
116
- ) } &g=${ githubURL } &x=${ encodeURIComponent (
117
- twitterURL
118
- ) } &l=${ encodeURIComponent ( linkedinURL ) } &p=${ encodeURIComponent (
119
- portfolioUrl
120
- ) } `;
121
- const newBentoLink = `[](https://opbento.vercel.app)` ;
122
-
123
- // Update state with new links
124
- setApiLink ( newApiLink ) ;
125
- setBentoLink ( newBentoLink ) ;
126
-
127
- // Debugging output to ensure links are set correctly
128
- console . log ( "API Link:" , newApiLink ) ;
129
- console . log ( "Bento Link:" , newBentoLink ) ;
130
-
131
- const scriptContent = `
132
- #!/bin/bash
133
-
134
- # Prompt for GitHub details and user-specific links
135
- read -p "Enter your GitHub username: " USERNAME
136
- read -p "Enter your GitHub email: " EMAIL
137
-
138
- # Define API and image link based on provided input
139
- API_LINK="${ newApiLink } "
140
- BENTO_LINK="${ newBentoLink } "
141
-
142
- echo "Generated API Link: \$API_LINK"
143
- echo "Generated Bento Link: \$BENTO_LINK"
144
-
145
- # Create README.md dynamically with Bento Link
146
- echo "# Bento GitHub Stats for \$USERNAME" > README.md
147
- echo "\$BENTO_LINK" >> README.md
148
- echo "Updated README.md with dynamic Bento GitHub Stats link."
149
-
150
- # Create .github/workflows directory and GitHub Actions workflow file
151
- mkdir -p .github/workflows
152
- touch .github/workflows/update_bento_readme.yml
153
-
154
- # Generate content for GitHub Actions workflow
155
- cat <<EOF > .github/workflows/update_bento_readme.yml
156
-
157
- name: Update README with Bento Stats
158
-
159
- on:
160
- schedule:
161
- - cron: "*/10 * * * *" # Runs every 5 minutes
162
- workflow_dispatch: # Allows manual triggering of the workflow
163
-
164
- jobs:
165
- update-readme:
166
- runs-on: ubuntu-latest
167
-
168
- steps:
169
- - name: Checkout repository
170
- uses: actions/checkout@v3
171
-
172
- - name: Fetch Latest Bento Image URL
173
- id: fetch_bento_url
174
- run: |
175
- API_URL="$API_LINK"
176
- RESPONSE=$(curl -s "$API_URL")
177
- echo "API Response: $RESPONSE" # Log the entire response
178
- IMAGE_URL=$(echo $RESPONSE | jq -r '.url')
179
- echo "Fetched Image URL: $IMAGE_URL"
180
- echo "::set-output name=image_url::$IMAGE_URL"
181
-
182
- - name: Delete current README.md
183
- if: env.skip != 'true'
184
- run: |
185
- if [ -f README.md ]; then
186
- rm README.md
187
- echo "Deleted old README.md"
188
- fi
189
-
190
- - name: Create new README.md
191
- if: env.skip != 'true'
192
- run: |
193
- IMAGE_URL=$(cat last_image_url.txt) # Read the URL from last_image_url.txt
194
- echo "# Bento GitHub Stats" > README.md
195
- echo "" >> README.md
196
- echo "Created new README.md with the latest image URL."
197
-
198
- - name: Commit and Push Changes
199
- if: env.skip != 'true'
200
- run: |
201
- git config --global user.email "\$EMAIL"
202
- git config --global user.name "\$USERNAME"
203
- git add .
204
- git commit -m "Update README with latest Bento stats image"
205
- git push
206
-
207
- EOF
208
-
209
- git config --global user.email "\$EMAIL"
210
- git config --global user.name "\$USERNAME"
211
- git add .
212
- git commit -m "Setup OpBento GitHub Action"
213
- git push
214
-
215
- echo "Setup complete! Your GitHub Actions workflow will run every 5 minutes and update the README with the latest Bento stats link."
216
- ` ;
217
-
218
- // Download the script
219
- const blob2 = new Blob ( [ scriptContent ] , { type : "text/plain" } ) ;
220
- const url = URL . createObjectURL ( blob2 ) ;
221
- const a = document . createElement ( "a" ) ;
222
- a . href = url ;
223
- a . download = "setup_bento_stats.sh" ;
224
- document . body . appendChild ( a ) ;
225
- a . click ( ) ;
226
- document . body . removeChild ( a ) ;
227
110
setLoading ( false ) ;
228
- URL . revokeObjectURL ( url ) ;
111
+ setBentoLink ( downloadUrl ) ;
229
112
} catch ( error ) {
230
113
console . error ( "Error generating or uploading the image:" , error ) ;
231
114
} finally {
232
115
bentoRef . current . className = previousClass ;
233
116
}
234
117
} ;
235
118
119
+ const copyToClipboard = async ( ) => {
120
+ await navigator . clipboard . writeText (
121
+ `[](https://opbento.vercel.app)`
122
+ ) ;
123
+ toast . success ( "Copied to clipboard" ) ;
124
+ } ;
125
+
236
126
return (
237
127
< div className = "max-w-5xl mx-auto" >
238
128
< div
@@ -503,10 +393,19 @@ echo "Setup complete! Your GitHub Actions workflow will run every 5 minutes and
503
393
) }
504
394
</ div >
505
395
506
- < Button className = "mx-4" onClick = { handleGenerateLink } >
507
- Generate Bento{ " " }
508
- { loading && < Loader2 className = "ml-2 size-4 animate-spin" /> }
396
+ < Button className = "mx-auto" onClick = { handleGenerateLink } >
397
+ Generate Bento { loading && < Loader2 className = "ml-2 w-4 h-4 animate-spin" /> }
509
398
</ Button >
399
+
400
+ < div className = "relative mt-4" >
401
+ < Input
402
+ value = { `[](https://opbento.vercel.app)` }
403
+ readOnly
404
+ />
405
+ < Button className = "absolute top-0 right-0" onClick = { copyToClipboard } >
406
+ < Clipboard />
407
+ </ Button >
408
+ </ div >
510
409
</ div >
511
410
) ;
512
411
} ;
0 commit comments