Testing GitHub-Style Copy Button
This post is designed to test the new GitHub-style copy button implementation for code blocks.
JavaScript Example
function greetUser(name) {
console.log(`Hello, ${name}!`);
return `Welcome to the site, ${name}`;
}
// Usage
const message = greetUser("John");
console.log(message);
Python Example
def calculate_fibonacci(n):
"""Calculate the nth Fibonacci number."""
if n <= 1:
return n
return calculate_fibonacci(n-1) + calculate_fibonacci(n-2)
# Generate first 10 Fibonacci numbers
for i in range(10):
print(f"F({i}) = {calculate_fibonacci(i)}")
YAML Configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: default
data:
database_url: "postgresql://user:pass@localhost:5432/mydb"
redis_url: "redis://localhost:6379"
log_level: "info"
features:
- authentication
- caching
- monitoring
Bash Script
#!/bin/bash
# Deploy application to Kubernetes
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
# Wait for deployment to be ready
kubectl rollout status deployment/my-app
# Get pod status
kubectl get pods -l app=my-app
echo "Deployment completed successfully!"
Go Code
package main
import (
"fmt"
"net/http"
"log"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World! Path: %s", r.URL.Path)
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("Server starting on :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}
SQL Query
SELECT
u.id,
u.username,
u.email,
COUNT(p.id) as post_count
FROM users u
LEFT JOIN posts p ON u.id = p.user_id
WHERE u.active = true
GROUP BY u.id, u.username, u.email
ORDER BY post_count DESC
LIMIT 10;
Testing Instructions
- Hover over each code block to see the copy button appear
- Click the copy button to copy the code
- The button should show a checkmark briefly after copying
- Test in both light and dark modes
- Verify the button works on mobile devices
The copy button should:
- Appear in the top-right corner of code blocks
- Show a clipboard icon by default
- Change to a checkmark when clicked
- Have smooth hover and click animations
- Work in both light and dark themes
- Be accessible via keyboard navigation