social_share_rails 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/app/assets/javascripts/social_share_rails/social_share.js +1 -1
- data/lib/social_share_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6a0ff64263ad9a668671c19b361a3645434b6304d3e0de2387b45739a8f93937
|
|
4
|
+
data.tar.gz: efc9a4e5f8439383ca8ddbf1ec12b5478b1739bc8f47665aadbd5e711b436e20
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b876b4ec6d3a498c449dfa8fae77027efbc2c22462aadc0e3cc1927617c284f8ae8169d18d3ded71b6a255a9b5c1b99941ae896d67315bd42a1a4b85bdb02827
|
|
7
|
+
data.tar.gz: d259c5ea008f45177ebf1d00a8ea6fa2c1c289c77d986bc7427fc7465d0e696792483518639bf98d4c8dbb8c0c96d0592938731ee15a075ec8cf528295ef7647
|
data/README.md
CHANGED
|
@@ -71,10 +71,23 @@ Add the `social_share` helper to your views:
|
|
|
71
71
|
}) %>
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
#### Fallback to Current Page URL
|
|
75
|
+
|
|
76
|
+
If no url is provided, the helper will automatically use the current page URL (window.location.href) as the fallback. For example:
|
|
77
|
+
|
|
78
|
+
```erb
|
|
79
|
+
<%= social_share("Share this post", {
|
|
80
|
+
allow_sites: %w[twitter facebook linkedin],
|
|
81
|
+
rounded: true
|
|
82
|
+
}) %>
|
|
83
|
+
```
|
|
84
|
+
In this case, the current page URL will be shared.
|
|
85
|
+
|
|
86
|
+
|
|
74
87
|
### Options
|
|
75
88
|
|
|
76
89
|
- **title** (String): The title of the post to share.
|
|
77
|
-
- **url** (String): The URL to share.
|
|
90
|
+
- **url** (String): The URL to share (falls back to the current page URL if not provided).
|
|
78
91
|
- **desc** (String): Optional description of the content.
|
|
79
92
|
- **allow_sites** (Array): List of social platforms to include.
|
|
80
93
|
- **rounded** (Boolean): If `true`, uses rounded icon styles.
|
|
@@ -24,7 +24,7 @@ window.SocialShare = {
|
|
|
24
24
|
var parent = el.parentNode;
|
|
25
25
|
var attributes = this.getEncodedAttributes(el, site, parent, ["title", "url", "desc"]);
|
|
26
26
|
var title = attributes.title;
|
|
27
|
-
var url = attributes.url;
|
|
27
|
+
var url = attributes.url || encodeURIComponent(window.location.href); // Use current URL if none provided
|
|
28
28
|
var desc = attributes.desc;
|
|
29
29
|
var img = encodeURIComponent(parent.getAttribute("data-img") || "");
|
|
30
30
|
var via = encodeURIComponent(parent.getAttribute("data-via") || "");
|