@riebeckite/plugin-share 0.0.6
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.
- package/LICENSE +201 -0
- package/README.md +142 -0
- package/README_ja.md +142 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +66 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +382 -0
- package/dist/src/client.d.ts +8 -0
- package/dist/src/options.d.ts +15 -0
- package/dist/src/render.d.ts +17 -0
- package/dist/src/services.d.ts +31 -0
- package/dist/src/types.d.ts +53 -0
- package/package.json +65 -0
- package/style.css +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright Rerurate_514
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# @riebeckite/plugin-share
|
|
2
|
+
|
|
3
|
+
Per-article share controls built at build time. For every published entry the
|
|
4
|
+
plugin builds share URLs for the configured services and injects the controls
|
|
5
|
+
into the rendered HTML. The links are ordinary anchors and work without
|
|
6
|
+
JavaScript; only the copy-link action is a progressive enhancement.
|
|
7
|
+
|
|
8
|
+
[日本語](./README_ja.md)
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
`share()` resolves each note's `permalink` to an absolute URL, composes the
|
|
13
|
+
service URLs from the note title and URL, and inserts the controls near the
|
|
14
|
+
article. Both `entry.html` and the cached `PostContent.html` that the content
|
|
15
|
+
route renders are updated, so the controls appear on generated pages and in
|
|
16
|
+
feeds.
|
|
17
|
+
|
|
18
|
+
Supported services:
|
|
19
|
+
|
|
20
|
+
| Service | Share URL |
|
|
21
|
+
| ------- | --------- |
|
|
22
|
+
| `x` | `https://twitter.com/intent/tweet?url=…&text=…` |
|
|
23
|
+
| `bluesky` | `https://bsky.app/intent/compose?text=…` |
|
|
24
|
+
| `mastodon` | `https://{instance}/share?text=…` |
|
|
25
|
+
| `facebook` | `https://www.facebook.com/sharer/sharer.php?u=…` |
|
|
26
|
+
| `linkedin` | `https://www.linkedin.com/sharing/share-offsite/?url=…` |
|
|
27
|
+
| `hatena` | `https://b.hatena.ne.jp/add?mode=confirm&url=…&title=…` |
|
|
28
|
+
| `copy` | Copies the note URL (button, no JavaScript required for the links) |
|
|
29
|
+
|
|
30
|
+
`mastodon` is opt-in: add `"mastodon"` to `services` and set
|
|
31
|
+
`mastodonInstance`.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { defineConfig } from "@riebeckite/core";
|
|
37
|
+
import { share } from "@riebeckite/plugin-share";
|
|
38
|
+
|
|
39
|
+
export default defineConfig({
|
|
40
|
+
// ...
|
|
41
|
+
plugins: [share()],
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Enable Mastodon and change placement:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
share({
|
|
49
|
+
services: ["x", "bluesky", "mastodon", "copy"],
|
|
50
|
+
mastodonInstance: "mastodon.social",
|
|
51
|
+
placement: "top",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Options
|
|
56
|
+
|
|
57
|
+
| Option | Type | Default | Description |
|
|
58
|
+
| ------ | ---- | ------- | ----------- |
|
|
59
|
+
| `services` | `ShareService[]` | every service except `mastodon` | Services to render, in order |
|
|
60
|
+
| `placement` | `"top" \| "bottom"` | `"bottom"` | Where the controls appear |
|
|
61
|
+
| `mastodonInstance` | `string` | none | Mastodon host; required when `services` includes `"mastodon"` |
|
|
62
|
+
| `className` | `string` | none | Extra root class alongside the stable `rr-share` hook |
|
|
63
|
+
| `ariaLabel` | `string` | `"Share"` | Accessible name for the control group |
|
|
64
|
+
| `labels` | `Partial<Record<ShareService, string>>` | built-in labels | Per-service visible labels |
|
|
65
|
+
| `copiedLabel` | `string` | `"Copied"` | Status announced after a successful copy |
|
|
66
|
+
| `copyFailedLabel` | `string` | `"Copy failed"` | Status announced when a copy fails |
|
|
67
|
+
|
|
68
|
+
`share` throws a configuration error at `riebeckite check` time when
|
|
69
|
+
`services` includes `"mastodon"` but `mastodonInstance` is missing.
|
|
70
|
+
|
|
71
|
+
## Output
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<div class="rr-share" data-rr-share data-rr-share-placement="bottom"
|
|
75
|
+
role="group" aria-label="Share">
|
|
76
|
+
<ul class="rr-share__list">
|
|
77
|
+
<li class="rr-share__item">
|
|
78
|
+
<a class="rr-share__link rr-share__link--x"
|
|
79
|
+
href="https://twitter.com/intent/tweet?url=…&text=…"
|
|
80
|
+
target="_blank" rel="noopener noreferrer" data-share-service="x">X</a>
|
|
81
|
+
</li>
|
|
82
|
+
<li class="rr-share__item">
|
|
83
|
+
<button type="button" class="rr-share__button rr-share__copy"
|
|
84
|
+
data-rr-share-copy data-share-url="https://example.com/posts/hello"
|
|
85
|
+
data-rr-share-copied="Copied" hidden>Copy link</button>
|
|
86
|
+
</li>
|
|
87
|
+
</ul>
|
|
88
|
+
<p class="rr-share__status" role="status" aria-live="polite"></p>
|
|
89
|
+
</div>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Progressive enhancement
|
|
93
|
+
|
|
94
|
+
The share links are plain anchors, so they work with JavaScript disabled. The
|
|
95
|
+
copy-link button starts `hidden` and is revealed by `initShare()`, which the
|
|
96
|
+
app calls during page initialization; a no-JS reader never sees a control that
|
|
97
|
+
cannot work. Copying uses `navigator.clipboard.writeText` and falls back to a
|
|
98
|
+
hidden textarea with `document.execCommand("copy")`. The result is announced in
|
|
99
|
+
the `aria-live="polite"` status region.
|
|
100
|
+
|
|
101
|
+
## Style
|
|
102
|
+
|
|
103
|
+
The package ships `style.css`. Register it like any other plugin stylesheet:
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import "@riebeckite/plugin-share/style.css";
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The stable classes are `rr-share` (root), `rr-share__list`, `rr-share__item`,
|
|
110
|
+
`rr-share__link`, `rr-share__link--{service}`, `rr-share__button`,
|
|
111
|
+
`rr-share__copy`, and `rr-share__status`. A theme can target these hooks; the
|
|
112
|
+
optional `className` is added to the root without replacing them.
|
|
113
|
+
|
|
114
|
+
## Exports
|
|
115
|
+
|
|
116
|
+
- `share(options?)` — plugin factory
|
|
117
|
+
- `sharePlugin` — alias of `share`
|
|
118
|
+
- `resolveShareOptions(options?)` — apply option defaults
|
|
119
|
+
- `validateShareOptions(options?)` — validate runtime options
|
|
120
|
+
- `buildAbsoluteUrl(config, permalink)` — resolve a note URL to absolute
|
|
121
|
+
- `normalizeMastodonInstance(value)` — normalize an instance to a bare host
|
|
122
|
+
- `buildShareUrl(service, target, instance?)` — build one service URL
|
|
123
|
+
- `buildShareLinks(options, target)` — build every link-bearing service
|
|
124
|
+
- `renderShareControls(options, target)` — render the controls HTML
|
|
125
|
+
- `injectShareControls(html, block, placement)` — insert into a note fragment
|
|
126
|
+
- `initShare()` — client initializer (also via
|
|
127
|
+
`@riebeckite/plugin-share/client`)
|
|
128
|
+
- Constants: `SHARE_SERVICES`, `SHARE_ATTRIBUTE`, `SHARE_ROOT_CLASS`,
|
|
129
|
+
`DEFAULT_SHARE_SERVICES`, `DEFAULT_SHARE_LABELS`, `DEFAULT_SHARE_PLACEMENT`
|
|
130
|
+
- Types: `ShareOptions`, `ResolvedShareOptions`, `ShareService`,
|
|
131
|
+
`SharePlacement`, `ShareLink`, `ShareTarget`
|
|
132
|
+
|
|
133
|
+
## Limitations
|
|
134
|
+
|
|
135
|
+
- Share URLs are fixed at build time. A full rebuild always recomputes them.
|
|
136
|
+
- Mastodon cannot be enabled without a concrete instance.
|
|
137
|
+
- The plugin inserts into the note fragment; a Site that owns its layout can
|
|
138
|
+
move the controls with CSS or omit them per page.
|
|
139
|
+
|
|
140
|
+
## See also
|
|
141
|
+
|
|
142
|
+
- [Plugin guide](../../../docs/en/plugin-system.md)
|
package/README_ja.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# @riebeckite/plugin-share
|
|
2
|
+
|
|
3
|
+
記事ごとの共有ボタンをビルド時に生成するプラグインです。公開対象の各エントリ
|
|
4
|
+
について、設定したサービス向けの共有 URL を組み立て、本文の近くにコントロール
|
|
5
|
+
を挿入します。共有リンクは通常の `<a>` なので JavaScript なしでも動作し、コピー
|
|
6
|
+
操作だけをプログレッシブ・エンハンスメントとして追加します。
|
|
7
|
+
|
|
8
|
+
[English](./README.md)
|
|
9
|
+
|
|
10
|
+
## 仕組み
|
|
11
|
+
|
|
12
|
+
`share()` は各ノートの `permalink` を絶対 URL に解決し、ノートのタイトルと URL
|
|
13
|
+
からサービスごとの共有 URL を組み立て、記事の近くにコントロールを挿入します。
|
|
14
|
+
`entry.html` と、コンテンツルートが描画するキャッシュ済みの `PostContent.html`
|
|
15
|
+
の両方を更新するため、生成ページとフィードの両方に反映されます。
|
|
16
|
+
|
|
17
|
+
対応サービスは次のとおりです。
|
|
18
|
+
|
|
19
|
+
| サービス | 共有 URL |
|
|
20
|
+
| -------- | -------- |
|
|
21
|
+
| `x` | `https://twitter.com/intent/tweet?url=…&text=…` |
|
|
22
|
+
| `bluesky` | `https://bsky.app/intent/compose?text=…` |
|
|
23
|
+
| `mastodon` | `https://{instance}/share?text=…` |
|
|
24
|
+
| `facebook` | `https://www.facebook.com/sharer/sharer.php?u=…` |
|
|
25
|
+
| `linkedin` | `https://www.linkedin.com/sharing/share-offsite/?url=…` |
|
|
26
|
+
| `hatena` | `https://b.hatena.ne.jp/add?mode=confirm&url=…&title=…` |
|
|
27
|
+
| `copy` | ノートの URL をコピーするボタン(リンクは JS 不要) |
|
|
28
|
+
|
|
29
|
+
`mastodon` はオプトインです。`services` に `"mastodon"` を追加し、
|
|
30
|
+
`mastodonInstance` を設定してください。
|
|
31
|
+
|
|
32
|
+
## 使い方
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { defineConfig } from "@riebeckite/core";
|
|
36
|
+
import { share } from "@riebeckite/plugin-share";
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
// ...
|
|
40
|
+
plugins: [share()],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Mastodon を有効にし、表示位置を変える例です。
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
share({
|
|
48
|
+
services: ["x", "bluesky", "mastodon", "copy"],
|
|
49
|
+
mastodonInstance: "mastodon.social",
|
|
50
|
+
placement: "top",
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## オプション
|
|
55
|
+
|
|
56
|
+
| オプション | 型 | 既定値 | 説明 |
|
|
57
|
+
| ---------- | -- | ------ | ---- |
|
|
58
|
+
| `services` | `ShareService[]` | `mastodon` 以外のすべて | 表示するサービス(順序どおり) |
|
|
59
|
+
| `placement` | `"top" \| "bottom"` | `"bottom"` | コントロールの表示位置 |
|
|
60
|
+
| `mastodonInstance` | `string` | なし | Mastodon のホスト。`services` に `"mastodon"` を含めると必須 |
|
|
61
|
+
| `className` | `string` | なし | 安定した `rr-share` フックに追加するルートクラス |
|
|
62
|
+
| `ariaLabel` | `string` | `"Share"` | コントロールグループのアクセシブル名 |
|
|
63
|
+
| `labels` | `Partial<Record<ShareService, string>>` | 組み込みラベル | サービスごとの表示ラベル |
|
|
64
|
+
| `copiedLabel` | `string` | `"Copied"` | コピー成功時に通知する文言 |
|
|
65
|
+
| `copyFailedLabel` | `string` | `"Copy failed"` | コピー失敗時に通知する文言 |
|
|
66
|
+
|
|
67
|
+
`services` に `"mastodon"` を含めたのに `mastodonInstance` が未設定の場合、
|
|
68
|
+
`riebeckite check` の時点で設定エラーになります。
|
|
69
|
+
|
|
70
|
+
## 出力
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<div class="rr-share" data-rr-share data-rr-share-placement="bottom"
|
|
74
|
+
role="group" aria-label="Share">
|
|
75
|
+
<ul class="rr-share__list">
|
|
76
|
+
<li class="rr-share__item">
|
|
77
|
+
<a class="rr-share__link rr-share__link--x"
|
|
78
|
+
href="https://twitter.com/intent/tweet?url=…&text=…"
|
|
79
|
+
target="_blank" rel="noopener noreferrer" data-share-service="x">X</a>
|
|
80
|
+
</li>
|
|
81
|
+
<li class="rr-share__item">
|
|
82
|
+
<button type="button" class="rr-share__button rr-share__copy"
|
|
83
|
+
data-rr-share-copy data-share-url="https://example.com/posts/hello"
|
|
84
|
+
data-rr-share-copied="Copied" hidden>Copy link</button>
|
|
85
|
+
</li>
|
|
86
|
+
</ul>
|
|
87
|
+
<p class="rr-share__status" role="status" aria-live="polite"></p>
|
|
88
|
+
</div>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## プログレッシブ・エンハンスメント
|
|
92
|
+
|
|
93
|
+
共有リンクは通常の `<a>` なので、JavaScript を無効にしても動作します。コピー
|
|
94
|
+
ボタンは `hidden` の状態で出力され、アプリのページ初期化時に呼ばれる
|
|
95
|
+
`initShare()` が表示に切り替えます。JavaScript がない読者に、動かない操作を
|
|
96
|
+
見せることはありません。コピーには `navigator.clipboard.writeText` を使い、
|
|
97
|
+
失敗時は非表示の textarea と `document.execCommand("copy")` にフォールバック
|
|
98
|
+
します。結果は `aria-live="polite"` のステータス領域で通知します。
|
|
99
|
+
|
|
100
|
+
## スタイル
|
|
101
|
+
|
|
102
|
+
パッケージに `style.css` が含まれます。他のプラグインと同じように読み込みます。
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import "@riebeckite/plugin-share/style.css";
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
安定したクラスは `rr-share`(ルート)、`rr-share__list`、`rr-share__item`、
|
|
109
|
+
`rr-share__link`、`rr-share__link--{service}`、`rr-share__button`、
|
|
110
|
+
`rr-share__copy`、`rr-share__status` です。Theme はこれらのフックを対象に
|
|
111
|
+
できます。任意の `className` はルートに追加され、これらのフックを置き換え
|
|
112
|
+
ません。
|
|
113
|
+
|
|
114
|
+
## エクスポート
|
|
115
|
+
|
|
116
|
+
- `share(options?)` — プラグインファクトリ
|
|
117
|
+
- `sharePlugin` — `share` のエイリアス
|
|
118
|
+
- `resolveShareOptions(options?)` — オプションの既定値を適用する
|
|
119
|
+
- `validateShareOptions(options?)` — 実行時オプションを検証する
|
|
120
|
+
- `buildAbsoluteUrl(config, permalink)` — ノート URL を絶対 URL に解決する
|
|
121
|
+
- `normalizeMastodonInstance(value)` — インスタンスをホスト名に正規化する
|
|
122
|
+
- `buildShareUrl(service, target, instance?)` — 1 サービスの URL を組み立てる
|
|
123
|
+
- `buildShareLinks(options, target)` — リンクを持つサービスをすべて組み立てる
|
|
124
|
+
- `renderShareControls(options, target)` — コントロールの HTML を生成する
|
|
125
|
+
- `injectShareControls(html, block, placement)` — ノート断片に挿入する
|
|
126
|
+
- `initShare()` — ブラウザ初期化関数(`@riebeckite/plugin-share/client` からも
|
|
127
|
+
読み込める)
|
|
128
|
+
- 定数: `SHARE_SERVICES`, `SHARE_ATTRIBUTE`, `SHARE_ROOT_CLASS`,
|
|
129
|
+
`DEFAULT_SHARE_SERVICES`, `DEFAULT_SHARE_LABELS`, `DEFAULT_SHARE_PLACEMENT`
|
|
130
|
+
- 型: `ShareOptions`, `ResolvedShareOptions`, `ShareService`,
|
|
131
|
+
`SharePlacement`, `ShareLink`, `ShareTarget`
|
|
132
|
+
|
|
133
|
+
## 制約
|
|
134
|
+
|
|
135
|
+
- 共有 URL はビルド時に確定します。再ビルドすれば常に正しく再計算されます。
|
|
136
|
+
- Mastodon は具体的なインスタンスなしには有効化できません。
|
|
137
|
+
- プラグインはノート断片に挿入します。レイアウトを所有する Site は、CSS で
|
|
138
|
+
位置を変えたり、ページごとに出力しない選択もできます。
|
|
139
|
+
|
|
140
|
+
## 関連
|
|
141
|
+
|
|
142
|
+
- [プラグインガイド](../../../docs/ja/plugin-system.md)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { initShare } from "./src/client.js";
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
var COPY_SELECTOR = "[data-rr-share-copy]";
|
|
3
|
+
var STATUS_SELECTOR = ".rr-share__status";
|
|
4
|
+
function initShare() {
|
|
5
|
+
if (typeof document === "undefined") return;
|
|
6
|
+
const buttons = document.querySelectorAll(COPY_SELECTOR);
|
|
7
|
+
for (const button of buttons) {
|
|
8
|
+
button.hidden = false;
|
|
9
|
+
if (button.dataset.rrShareReady === "true") continue;
|
|
10
|
+
button.dataset.rrShareReady = "true";
|
|
11
|
+
button.addEventListener("click", () => {
|
|
12
|
+
void handleCopy(button);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function handleCopy(button) {
|
|
17
|
+
const url = button.dataset.shareUrl || window.location.href;
|
|
18
|
+
const status = button.closest("[data-rr-share]")?.querySelector(STATUS_SELECTOR);
|
|
19
|
+
const copied = await copyToClipboard(url);
|
|
20
|
+
if (status) {
|
|
21
|
+
status.textContent = copied ? button.dataset.rrShareCopied || "Copied" : button.dataset.rrShareCopyFailed || "Copy failed";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function copyToClipboard(value) {
|
|
25
|
+
try {
|
|
26
|
+
if (window.isSecureContext && navigator.clipboard) {
|
|
27
|
+
await navigator.clipboard.writeText(value);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
return copyWithExecCommand(value);
|
|
33
|
+
}
|
|
34
|
+
function copyWithExecCommand(value) {
|
|
35
|
+
const selection = window.getSelection();
|
|
36
|
+
const savedRanges = [];
|
|
37
|
+
if (selection) {
|
|
38
|
+
for (let index = 0; index < selection.rangeCount; index += 1) {
|
|
39
|
+
savedRanges.push(selection.getRangeAt(index).cloneRange());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const textarea = document.createElement("textarea");
|
|
43
|
+
textarea.value = value;
|
|
44
|
+
textarea.setAttribute("readonly", "");
|
|
45
|
+
textarea.style.position = "fixed";
|
|
46
|
+
textarea.style.top = "-1000px";
|
|
47
|
+
textarea.style.opacity = "0";
|
|
48
|
+
document.body.appendChild(textarea);
|
|
49
|
+
textarea.select();
|
|
50
|
+
let copied = false;
|
|
51
|
+
try {
|
|
52
|
+
copied = document.execCommand("copy");
|
|
53
|
+
} catch {
|
|
54
|
+
copied = false;
|
|
55
|
+
} finally {
|
|
56
|
+
textarea.remove();
|
|
57
|
+
if (selection && savedRanges.length > 0) {
|
|
58
|
+
selection.removeAllRanges();
|
|
59
|
+
for (const range of savedRanges) selection.addRange(range);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return copied;
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
initShare
|
|
66
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ShareOptions } from "./src/types.js";
|
|
2
|
+
export { initShare } from "./src/client.js";
|
|
3
|
+
export { DEFAULT_SHARE_ARIA_LABEL, DEFAULT_SHARE_COPIED_LABEL, DEFAULT_SHARE_COPY_FAILED_LABEL, DEFAULT_SHARE_LABELS, DEFAULT_SHARE_PLACEMENT, DEFAULT_SHARE_SERVICES, resolveShareOptions, validateShareOptions, } from "./src/options.js";
|
|
4
|
+
export { injectShareControls, renderShareControls, SHARE_ATTRIBUTE, SHARE_ROOT_CLASS, } from "./src/render.js";
|
|
5
|
+
export { buildAbsoluteUrl, buildShareLinks, buildShareUrl, normalizeMastodonInstance, type ShareTarget, } from "./src/services.js";
|
|
6
|
+
export type { ResolvedShareOptions, ShareLink, ShareOptions, SharePlacement, ShareService, } from "./src/types.js";
|
|
7
|
+
export { SHARE_SERVICES } from "./src/types.js";
|
|
8
|
+
export declare const SHARE_PLUGIN_NAME = "share";
|
|
9
|
+
/**
|
|
10
|
+
* Per-article share controls.
|
|
11
|
+
*
|
|
12
|
+
* For every entry the plugin builds absolute share URLs for the configured
|
|
13
|
+
* services and injects the controls into both `entry.html` and the cached
|
|
14
|
+
* `PostContent.html` that the content route renders. The links are ordinary
|
|
15
|
+
* anchors, so they work without JavaScript; only the copy-link action is
|
|
16
|
+
* enhanced at runtime.
|
|
17
|
+
*/
|
|
18
|
+
export declare function share(options?: ShareOptions): import("@riebeckite/core").RiebeckitePlugin<ShareOptions>;
|
|
19
|
+
/** Alias matching the `*Plugin` suffix used by other plugin factories. */
|
|
20
|
+
export declare const sharePlugin: typeof share;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
// index.ts
|
|
2
|
+
import {
|
|
3
|
+
createClientEntry,
|
|
4
|
+
createStyleAsset,
|
|
5
|
+
definePlugin
|
|
6
|
+
} from "@riebeckite/core";
|
|
7
|
+
|
|
8
|
+
// src/services.ts
|
|
9
|
+
function buildAbsoluteUrl(config, pathOrUrl) {
|
|
10
|
+
if (!pathOrUrl) return config.site.baseUrl;
|
|
11
|
+
if (/^https?:\/\//i.test(pathOrUrl)) return pathOrUrl;
|
|
12
|
+
return new URL(
|
|
13
|
+
pathOrUrl,
|
|
14
|
+
config.site.baseUrl || "https://example.com"
|
|
15
|
+
).toString();
|
|
16
|
+
}
|
|
17
|
+
function normalizeMastodonInstance(value) {
|
|
18
|
+
if (typeof value !== "string") return "";
|
|
19
|
+
const trimmed = value.trim();
|
|
20
|
+
if (trimmed === "") return "";
|
|
21
|
+
const withoutScheme = trimmed.replace(/^https?:\/\//i, "");
|
|
22
|
+
const host = withoutScheme.split(/[/?#]/, 1)[0] ?? "";
|
|
23
|
+
return host.replace(/\.+$/, "");
|
|
24
|
+
}
|
|
25
|
+
function buildShareUrl(service, target, mastodonInstance = "") {
|
|
26
|
+
const url = target.url;
|
|
27
|
+
const title = target.title;
|
|
28
|
+
const composed = title ? `${title} ${url}` : url;
|
|
29
|
+
switch (service) {
|
|
30
|
+
case "x":
|
|
31
|
+
return `https://twitter.com/intent/tweet?url=${encode(url)}&text=${encode(title)}`;
|
|
32
|
+
case "bluesky":
|
|
33
|
+
return `https://bsky.app/intent/compose?text=${encode(composed)}`;
|
|
34
|
+
case "mastodon": {
|
|
35
|
+
const instance = normalizeMastodonInstance(mastodonInstance);
|
|
36
|
+
if (instance === "") return null;
|
|
37
|
+
return `https://${instance}/share?text=${encode(composed)}`;
|
|
38
|
+
}
|
|
39
|
+
case "facebook":
|
|
40
|
+
return `https://www.facebook.com/sharer/sharer.php?u=${encode(url)}`;
|
|
41
|
+
case "linkedin":
|
|
42
|
+
return `https://www.linkedin.com/sharing/share-offsite/?url=${encode(url)}`;
|
|
43
|
+
case "hatena":
|
|
44
|
+
return `https://b.hatena.ne.jp/add?mode=confirm&url=${encode(url)}&title=${encode(title)}`;
|
|
45
|
+
case "copy":
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function buildShareLinks(options, target) {
|
|
50
|
+
const links = [];
|
|
51
|
+
for (const service of options.services) {
|
|
52
|
+
const url = buildShareUrl(service, target, options.mastodonInstance);
|
|
53
|
+
if (url === null) continue;
|
|
54
|
+
links.push({ service, label: options.labels[service], url });
|
|
55
|
+
}
|
|
56
|
+
return links;
|
|
57
|
+
}
|
|
58
|
+
function encode(value) {
|
|
59
|
+
return encodeURIComponent(value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/types.ts
|
|
63
|
+
var SHARE_SERVICES = [
|
|
64
|
+
"x",
|
|
65
|
+
"bluesky",
|
|
66
|
+
"mastodon",
|
|
67
|
+
"facebook",
|
|
68
|
+
"linkedin",
|
|
69
|
+
"hatena",
|
|
70
|
+
"copy"
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
// src/options.ts
|
|
74
|
+
var DEFAULT_SHARE_SERVICES = [
|
|
75
|
+
"x",
|
|
76
|
+
"bluesky",
|
|
77
|
+
"facebook",
|
|
78
|
+
"linkedin",
|
|
79
|
+
"hatena",
|
|
80
|
+
"copy"
|
|
81
|
+
];
|
|
82
|
+
var DEFAULT_SHARE_LABELS = {
|
|
83
|
+
x: "X",
|
|
84
|
+
bluesky: "Bluesky",
|
|
85
|
+
mastodon: "Mastodon",
|
|
86
|
+
facebook: "Facebook",
|
|
87
|
+
linkedin: "LinkedIn",
|
|
88
|
+
hatena: "Hatena Bookmark",
|
|
89
|
+
copy: "Copy link"
|
|
90
|
+
};
|
|
91
|
+
var DEFAULT_SHARE_PLACEMENT = "bottom";
|
|
92
|
+
var DEFAULT_SHARE_ARIA_LABEL = "Share";
|
|
93
|
+
var DEFAULT_SHARE_COPIED_LABEL = "Copied";
|
|
94
|
+
var DEFAULT_SHARE_COPY_FAILED_LABEL = "Copy failed";
|
|
95
|
+
function resolveShareOptions(options = {}) {
|
|
96
|
+
return {
|
|
97
|
+
services: normalizeServices(options.services),
|
|
98
|
+
placement: options.placement === "top" ? "top" : DEFAULT_SHARE_PLACEMENT,
|
|
99
|
+
mastodonInstance: normalizeMastodonInstance(options.mastodonInstance),
|
|
100
|
+
className: normalizeNonEmpty(options.className, ""),
|
|
101
|
+
ariaLabel: normalizeNonEmpty(options.ariaLabel, DEFAULT_SHARE_ARIA_LABEL),
|
|
102
|
+
labels: { ...DEFAULT_SHARE_LABELS, ...sanitizeLabels(options.labels) },
|
|
103
|
+
copiedLabel: normalizeNonEmpty(
|
|
104
|
+
options.copiedLabel,
|
|
105
|
+
DEFAULT_SHARE_COPIED_LABEL
|
|
106
|
+
),
|
|
107
|
+
copyFailedLabel: normalizeNonEmpty(
|
|
108
|
+
options.copyFailedLabel,
|
|
109
|
+
DEFAULT_SHARE_COPY_FAILED_LABEL
|
|
110
|
+
)
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function validateShareOptions(options) {
|
|
114
|
+
if (!options) return [];
|
|
115
|
+
const issues = [];
|
|
116
|
+
const mastodonEnabled = Array.isArray(options.services) && options.services.includes("mastodon");
|
|
117
|
+
if (options.services !== void 0) {
|
|
118
|
+
if (!Array.isArray(options.services)) {
|
|
119
|
+
issues.push({
|
|
120
|
+
path: "services",
|
|
121
|
+
message: "Expected an array of service names."
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
for (const [index, service] of options.services.entries()) {
|
|
125
|
+
if (!SHARE_SERVICES.includes(service)) {
|
|
126
|
+
issues.push({
|
|
127
|
+
path: `services[${index}]`,
|
|
128
|
+
message: `Expected one of: ${SHARE_SERVICES.join(", ")}.`
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (mastodonEnabled) {
|
|
135
|
+
if (normalizeMastodonInstance(options.mastodonInstance) === "") {
|
|
136
|
+
issues.push({
|
|
137
|
+
path: "mastodonInstance",
|
|
138
|
+
message: 'Required when "mastodon" is enabled in services.'
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} else if (options.mastodonInstance !== void 0 && (typeof options.mastodonInstance !== "string" || options.mastodonInstance.trim() === "")) {
|
|
142
|
+
issues.push({
|
|
143
|
+
path: "mastodonInstance",
|
|
144
|
+
message: "Expected a non-empty string."
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (options.placement !== void 0 && options.placement !== "top" && options.placement !== "bottom") {
|
|
148
|
+
issues.push({
|
|
149
|
+
path: "placement",
|
|
150
|
+
message: 'Expected "top" or "bottom".'
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
for (const key of [
|
|
154
|
+
"className",
|
|
155
|
+
"ariaLabel",
|
|
156
|
+
"copiedLabel",
|
|
157
|
+
"copyFailedLabel"
|
|
158
|
+
]) {
|
|
159
|
+
const value = options[key];
|
|
160
|
+
if (value !== void 0 && (typeof value !== "string" || value.trim() === "")) {
|
|
161
|
+
issues.push({ path: key, message: "Expected a non-empty string." });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (options.labels !== void 0) {
|
|
165
|
+
if (typeof options.labels !== "object" || options.labels === null || Array.isArray(options.labels)) {
|
|
166
|
+
issues.push({
|
|
167
|
+
path: "labels",
|
|
168
|
+
message: "Expected an object mapping service names to labels."
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
for (const [key, value] of Object.entries(options.labels)) {
|
|
172
|
+
if (!SHARE_SERVICES.includes(key)) {
|
|
173
|
+
issues.push({
|
|
174
|
+
path: `labels.${key}`,
|
|
175
|
+
message: `Unknown service. Expected one of: ${SHARE_SERVICES.join(", ")}.`
|
|
176
|
+
});
|
|
177
|
+
} else if (typeof value !== "string" || value.trim() === "") {
|
|
178
|
+
issues.push({
|
|
179
|
+
path: `labels.${key}`,
|
|
180
|
+
message: "Expected a non-empty string."
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return issues;
|
|
187
|
+
}
|
|
188
|
+
function normalizeServices(services) {
|
|
189
|
+
const source = services ?? DEFAULT_SHARE_SERVICES;
|
|
190
|
+
const seen = /* @__PURE__ */ new Set();
|
|
191
|
+
const resolved = [];
|
|
192
|
+
for (const service of source) {
|
|
193
|
+
if (!SHARE_SERVICES.includes(service)) continue;
|
|
194
|
+
if (seen.has(service)) continue;
|
|
195
|
+
seen.add(service);
|
|
196
|
+
resolved.push(service);
|
|
197
|
+
}
|
|
198
|
+
return resolved;
|
|
199
|
+
}
|
|
200
|
+
function sanitizeLabels(labels) {
|
|
201
|
+
if (!labels || typeof labels !== "object") return {};
|
|
202
|
+
const resolved = {};
|
|
203
|
+
for (const service of SHARE_SERVICES) {
|
|
204
|
+
const value = labels[service];
|
|
205
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
206
|
+
resolved[service] = value.trim();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return resolved;
|
|
210
|
+
}
|
|
211
|
+
function normalizeNonEmpty(value, fallback) {
|
|
212
|
+
if (typeof value !== "string") return fallback;
|
|
213
|
+
const trimmed = value.trim();
|
|
214
|
+
return trimmed === "" ? fallback : trimmed;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/render.ts
|
|
218
|
+
import { escapeHtml, escapeHtmlAttribute } from "@riebeckite/core";
|
|
219
|
+
var SHARE_ATTRIBUTE = "data-rr-share";
|
|
220
|
+
var SHARE_ROOT_CLASS = "rr-share";
|
|
221
|
+
function renderShareControls(options, target) {
|
|
222
|
+
const links = buildShareLinks(options, target);
|
|
223
|
+
const wantsCopy = options.services.includes("copy");
|
|
224
|
+
if (links.length === 0 && !wantsCopy) return "";
|
|
225
|
+
const rootClass = options.className ? `${SHARE_ROOT_CLASS} ${options.className}` : SHARE_ROOT_CLASS;
|
|
226
|
+
const items = links.map(renderLinkItem).join("");
|
|
227
|
+
const copyItem = wantsCopy ? renderCopyItem(options, target) : "";
|
|
228
|
+
const ariaLabel = escapeHtmlAttribute(options.ariaLabel);
|
|
229
|
+
return `<div class="${escapeHtmlAttribute(rootClass)}" ${SHARE_ATTRIBUTE} data-rr-share-placement="${escapeHtmlAttribute(options.placement)}" role="group" aria-label="${ariaLabel}"><ul class="${SHARE_ROOT_CLASS}__list">${items}${copyItem}</ul><p class="${SHARE_ROOT_CLASS}__status" role="status" aria-live="polite"></p></div>`;
|
|
230
|
+
}
|
|
231
|
+
function injectShareControls(html, block, placement) {
|
|
232
|
+
if (block === "" || html.includes(SHARE_ATTRIBUTE)) return html;
|
|
233
|
+
if (placement === "top") {
|
|
234
|
+
const article = /<article\b[^>]*>/i.exec(html);
|
|
235
|
+
if (article) {
|
|
236
|
+
const end = article.index + article[0].length;
|
|
237
|
+
return `${html.slice(0, end)}${block}${html.slice(end)}`;
|
|
238
|
+
}
|
|
239
|
+
const body = /<body\b[^>]*>/i.exec(html);
|
|
240
|
+
if (body) {
|
|
241
|
+
const end = body.index + body[0].length;
|
|
242
|
+
return `${html.slice(0, end)}${block}${html.slice(end)}`;
|
|
243
|
+
}
|
|
244
|
+
return `${block}
|
|
245
|
+
${html}`;
|
|
246
|
+
}
|
|
247
|
+
const closeIndex = html.toLowerCase().lastIndexOf("</article>");
|
|
248
|
+
if (closeIndex !== -1) {
|
|
249
|
+
return `${html.slice(0, closeIndex)}${block}${html.slice(closeIndex)}`;
|
|
250
|
+
}
|
|
251
|
+
return `${html}
|
|
252
|
+
${block}`;
|
|
253
|
+
}
|
|
254
|
+
function renderLinkItem(link) {
|
|
255
|
+
const modifier = `${SHARE_ROOT_CLASS}__link--${link.service}`;
|
|
256
|
+
return `<li class="${SHARE_ROOT_CLASS}__item"><a class="${SHARE_ROOT_CLASS}__link ${modifier}" href="${escapeHtmlAttribute(link.url)}" target="_blank" rel="noopener noreferrer" data-share-service="${escapeHtmlAttribute(link.service)}">${escapeHtml(link.label)}</a></li>`;
|
|
257
|
+
}
|
|
258
|
+
function renderCopyItem(options, target) {
|
|
259
|
+
return `<li class="${SHARE_ROOT_CLASS}__item"><button type="button" class="${SHARE_ROOT_CLASS}__button ${SHARE_ROOT_CLASS}__copy" data-rr-share-copy data-share-url="${escapeHtmlAttribute(target.url)}" data-rr-share-copied="${escapeHtmlAttribute(options.copiedLabel)}" data-rr-share-copy-failed="${escapeHtmlAttribute(options.copyFailedLabel)}" hidden>${escapeHtml(options.labels.copy)}</button></li>`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/client.ts
|
|
263
|
+
var COPY_SELECTOR = "[data-rr-share-copy]";
|
|
264
|
+
var STATUS_SELECTOR = ".rr-share__status";
|
|
265
|
+
function initShare() {
|
|
266
|
+
if (typeof document === "undefined") return;
|
|
267
|
+
const buttons = document.querySelectorAll(COPY_SELECTOR);
|
|
268
|
+
for (const button of buttons) {
|
|
269
|
+
button.hidden = false;
|
|
270
|
+
if (button.dataset.rrShareReady === "true") continue;
|
|
271
|
+
button.dataset.rrShareReady = "true";
|
|
272
|
+
button.addEventListener("click", () => {
|
|
273
|
+
void handleCopy(button);
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
async function handleCopy(button) {
|
|
278
|
+
const url = button.dataset.shareUrl || window.location.href;
|
|
279
|
+
const status = button.closest("[data-rr-share]")?.querySelector(STATUS_SELECTOR);
|
|
280
|
+
const copied = await copyToClipboard(url);
|
|
281
|
+
if (status) {
|
|
282
|
+
status.textContent = copied ? button.dataset.rrShareCopied || "Copied" : button.dataset.rrShareCopyFailed || "Copy failed";
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
async function copyToClipboard(value) {
|
|
286
|
+
try {
|
|
287
|
+
if (window.isSecureContext && navigator.clipboard) {
|
|
288
|
+
await navigator.clipboard.writeText(value);
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
} catch {
|
|
292
|
+
}
|
|
293
|
+
return copyWithExecCommand(value);
|
|
294
|
+
}
|
|
295
|
+
function copyWithExecCommand(value) {
|
|
296
|
+
const selection = window.getSelection();
|
|
297
|
+
const savedRanges = [];
|
|
298
|
+
if (selection) {
|
|
299
|
+
for (let index = 0; index < selection.rangeCount; index += 1) {
|
|
300
|
+
savedRanges.push(selection.getRangeAt(index).cloneRange());
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const textarea = document.createElement("textarea");
|
|
304
|
+
textarea.value = value;
|
|
305
|
+
textarea.setAttribute("readonly", "");
|
|
306
|
+
textarea.style.position = "fixed";
|
|
307
|
+
textarea.style.top = "-1000px";
|
|
308
|
+
textarea.style.opacity = "0";
|
|
309
|
+
document.body.appendChild(textarea);
|
|
310
|
+
textarea.select();
|
|
311
|
+
let copied = false;
|
|
312
|
+
try {
|
|
313
|
+
copied = document.execCommand("copy");
|
|
314
|
+
} catch {
|
|
315
|
+
copied = false;
|
|
316
|
+
} finally {
|
|
317
|
+
textarea.remove();
|
|
318
|
+
if (selection && savedRanges.length > 0) {
|
|
319
|
+
selection.removeAllRanges();
|
|
320
|
+
for (const range of savedRanges) selection.addRange(range);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return copied;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// index.ts
|
|
327
|
+
var SHARE_PLUGIN_NAME = "share";
|
|
328
|
+
function share(options = {}) {
|
|
329
|
+
const resolved = resolveShareOptions(options);
|
|
330
|
+
const processed = /* @__PURE__ */ new Map();
|
|
331
|
+
return definePlugin({
|
|
332
|
+
name: SHARE_PLUGIN_NAME,
|
|
333
|
+
options,
|
|
334
|
+
validateOptions: validateShareOptions,
|
|
335
|
+
onPostProcessed: (context) => {
|
|
336
|
+
processed.set(context.slug, context.content);
|
|
337
|
+
},
|
|
338
|
+
onManifestCreated: (context) => {
|
|
339
|
+
const { manifest, config } = context;
|
|
340
|
+
if (!config) return;
|
|
341
|
+
for (const entry of manifest.entries) {
|
|
342
|
+
if (!entry.html || entry.html.includes(SHARE_ATTRIBUTE)) continue;
|
|
343
|
+
const block = renderShareControls(resolved, {
|
|
344
|
+
url: buildAbsoluteUrl(config, entry.permalink),
|
|
345
|
+
title: entry.title
|
|
346
|
+
});
|
|
347
|
+
if (block === "") continue;
|
|
348
|
+
const html = injectShareControls(entry.html, block, resolved.placement);
|
|
349
|
+
entry.html = html;
|
|
350
|
+
const content = processed.get(entry.slug);
|
|
351
|
+
if (content) content.html = html;
|
|
352
|
+
}
|
|
353
|
+
processed.clear();
|
|
354
|
+
},
|
|
355
|
+
assets: [createStyleAsset(SHARE_PLUGIN_NAME)],
|
|
356
|
+
clientEntries: [createClientEntry(SHARE_PLUGIN_NAME, "initShare")]
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
var sharePlugin = share;
|
|
360
|
+
export {
|
|
361
|
+
DEFAULT_SHARE_ARIA_LABEL,
|
|
362
|
+
DEFAULT_SHARE_COPIED_LABEL,
|
|
363
|
+
DEFAULT_SHARE_COPY_FAILED_LABEL,
|
|
364
|
+
DEFAULT_SHARE_LABELS,
|
|
365
|
+
DEFAULT_SHARE_PLACEMENT,
|
|
366
|
+
DEFAULT_SHARE_SERVICES,
|
|
367
|
+
SHARE_ATTRIBUTE,
|
|
368
|
+
SHARE_PLUGIN_NAME,
|
|
369
|
+
SHARE_ROOT_CLASS,
|
|
370
|
+
SHARE_SERVICES,
|
|
371
|
+
buildAbsoluteUrl,
|
|
372
|
+
buildShareLinks,
|
|
373
|
+
buildShareUrl,
|
|
374
|
+
initShare,
|
|
375
|
+
injectShareControls,
|
|
376
|
+
normalizeMastodonInstance,
|
|
377
|
+
renderShareControls,
|
|
378
|
+
resolveShareOptions,
|
|
379
|
+
share,
|
|
380
|
+
sharePlugin,
|
|
381
|
+
validateShareOptions
|
|
382
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy-to-clipboard enhancement for `@riebeckite/plugin-share`.
|
|
3
|
+
*
|
|
4
|
+
* The share links are plain anchors and work without JavaScript. Only the
|
|
5
|
+
* copy-link action needs a runtime: it starts hidden and is revealed here, so
|
|
6
|
+
* no-JS readers never see a control that cannot work.
|
|
7
|
+
*/
|
|
8
|
+
export declare function initShare(): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConfigValidationIssue } from "@riebeckite/core";
|
|
2
|
+
import { type ResolvedShareOptions, type ShareOptions, type SharePlacement, type ShareService } from "./types.js";
|
|
3
|
+
/** Services rendered when `services` is omitted. Mastodon is opt-in. */
|
|
4
|
+
export declare const DEFAULT_SHARE_SERVICES: readonly ShareService[];
|
|
5
|
+
export declare const DEFAULT_SHARE_LABELS: Readonly<Record<ShareService, string>>;
|
|
6
|
+
export declare const DEFAULT_SHARE_PLACEMENT: SharePlacement;
|
|
7
|
+
export declare const DEFAULT_SHARE_ARIA_LABEL = "Share";
|
|
8
|
+
export declare const DEFAULT_SHARE_COPIED_LABEL = "Copied";
|
|
9
|
+
export declare const DEFAULT_SHARE_COPY_FAILED_LABEL = "Copy failed";
|
|
10
|
+
/**
|
|
11
|
+
* Applies defaults to `ShareOptions`. Pure and deterministic so the plugin can
|
|
12
|
+
* resolve options once and reuse them for every manifest entry.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveShareOptions(options?: ShareOptions): ResolvedShareOptions;
|
|
15
|
+
export declare function validateShareOptions(options: ShareOptions | undefined): readonly ConfigValidationIssue[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ShareTarget } from "./services.js";
|
|
2
|
+
import type { ResolvedShareOptions, SharePlacement } from "./types.js";
|
|
3
|
+
/** Attribute that marks the generated controls for tests, CSS, and JS. */
|
|
4
|
+
export declare const SHARE_ATTRIBUTE = "data-rr-share";
|
|
5
|
+
/** Stable root hook every rendered set carries, even with a custom class. */
|
|
6
|
+
export declare const SHARE_ROOT_CLASS = "rr-share";
|
|
7
|
+
/**
|
|
8
|
+
* Renders the share controls for one note. Returns an empty string when no
|
|
9
|
+
* service can be rendered, so callers can leave the HTML untouched.
|
|
10
|
+
*/
|
|
11
|
+
export declare function renderShareControls(options: ResolvedShareOptions, target: ShareTarget): string;
|
|
12
|
+
/**
|
|
13
|
+
* Inserts the rendered controls into a note fragment. Top placement lands
|
|
14
|
+
* after the opening `<article>` (or at the start) and bottom placement lands
|
|
15
|
+
* before the closing `</article>` (or at the end).
|
|
16
|
+
*/
|
|
17
|
+
export declare function injectShareControls(html: string, block: string, placement: SharePlacement): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ResolvedRiebeckiteConfig } from "@riebeckite/core";
|
|
2
|
+
import type { ResolvedShareOptions, ShareLink, ShareService } from "./types.js";
|
|
3
|
+
/** The text pre-filled into a compose-style share intent. */
|
|
4
|
+
export type ShareTarget = {
|
|
5
|
+
/** Absolute URL of the note. */
|
|
6
|
+
url: string;
|
|
7
|
+
/** Note title. */
|
|
8
|
+
title: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Resolves a note's `permalink` to an absolute URL against the site base URL.
|
|
12
|
+
* Already-absolute URLs are returned unchanged.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildAbsoluteUrl(config: ResolvedRiebeckiteConfig, pathOrUrl: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes a Mastodon instance to a bare host. Accepts `"mastodon.social"`,
|
|
17
|
+
* `"https://mastodon.social/"`, and `"https://mastodon.social/@user"` (the
|
|
18
|
+
* path is dropped). Returns `""` when nothing usable remains.
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeMastodonInstance(value: string | undefined): string;
|
|
21
|
+
/**
|
|
22
|
+
* Builds the share URL for one service. Returns `null` for `"copy"` (which is
|
|
23
|
+
* a button, not a link) and for `"mastodon"` without a usable instance.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildShareUrl(service: ShareService, target: ShareTarget, mastodonInstance?: string): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Builds every link-bearing service in the configured order, resolving labels
|
|
28
|
+
* and skipping services whose URL cannot be built (for example `mastodon`
|
|
29
|
+
* without an instance). The `copy` service is intentionally excluded.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildShareLinks(options: ResolvedShareOptions, target: ShareTarget): ShareLink[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Services a note can be shared to. `copy` is the copy-link action. */
|
|
2
|
+
export declare const SHARE_SERVICES: readonly ["x", "bluesky", "mastodon", "facebook", "linkedin", "hatena", "copy"];
|
|
3
|
+
export type ShareService = (typeof SHARE_SERVICES)[number];
|
|
4
|
+
/** Where the controls sit relative to the note body. */
|
|
5
|
+
export type SharePlacement = "top" | "bottom";
|
|
6
|
+
/** Options accepted by `share()`. */
|
|
7
|
+
export type ShareOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Services to render, in order. Defaults to every service except
|
|
10
|
+
* `mastodon`; add `"mastodon"` and set {@link ShareOptions.mastodonInstance}
|
|
11
|
+
* to enable it.
|
|
12
|
+
*/
|
|
13
|
+
services?: readonly ShareService[];
|
|
14
|
+
/** Where the controls appear. Defaults to `"bottom"`. */
|
|
15
|
+
placement?: SharePlacement;
|
|
16
|
+
/**
|
|
17
|
+
* Instance host used by the `mastodon` service, for example
|
|
18
|
+
* `"mastodon.social"`. Accepts a bare host or a full URL; the scheme and
|
|
19
|
+
* trailing slash are stripped. Required when `services` includes
|
|
20
|
+
* `"mastodon"`.
|
|
21
|
+
*/
|
|
22
|
+
mastodonInstance?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Extra CSS class added to the root element alongside the stable
|
|
25
|
+
* `rr-share` hook. Defaults to none.
|
|
26
|
+
*/
|
|
27
|
+
className?: string;
|
|
28
|
+
/** Accessible name for the share group. Defaults to `"Share"`. */
|
|
29
|
+
ariaLabel?: string;
|
|
30
|
+
/** Per-service visible labels, merged over the defaults. */
|
|
31
|
+
labels?: Partial<Record<ShareService, string>>;
|
|
32
|
+
/** Status text announced after a successful copy. Defaults to `"Copied"`. */
|
|
33
|
+
copiedLabel?: string;
|
|
34
|
+
/** Status text announced when a copy fails. Defaults to `"Copy failed"`. */
|
|
35
|
+
copyFailedLabel?: string;
|
|
36
|
+
};
|
|
37
|
+
/** `ShareOptions` with every default applied. */
|
|
38
|
+
export type ResolvedShareOptions = {
|
|
39
|
+
services: readonly ShareService[];
|
|
40
|
+
placement: SharePlacement;
|
|
41
|
+
mastodonInstance: string;
|
|
42
|
+
className: string;
|
|
43
|
+
ariaLabel: string;
|
|
44
|
+
labels: Readonly<Record<ShareService, string>>;
|
|
45
|
+
copiedLabel: string;
|
|
46
|
+
copyFailedLabel: string;
|
|
47
|
+
};
|
|
48
|
+
/** A rendered share link. `url` is absolute and ready for an `href`. */
|
|
49
|
+
export type ShareLink = {
|
|
50
|
+
service: ShareService;
|
|
51
|
+
label: string;
|
|
52
|
+
url: string;
|
|
53
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@riebeckite/plugin-share",
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"source": "./index.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./client": {
|
|
16
|
+
"types": "./dist/client.d.ts",
|
|
17
|
+
"import": "./dist/client.js",
|
|
18
|
+
"source": "./client.ts",
|
|
19
|
+
"default": "./dist/client.js"
|
|
20
|
+
},
|
|
21
|
+
"./style.css": "./style.css"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@riebeckite/core": "0.0.6"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"tsx": "^4.22.4"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"README.md",
|
|
35
|
+
"README_ja.md",
|
|
36
|
+
"dist",
|
|
37
|
+
"style.css"
|
|
38
|
+
],
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/Rerurate514/riebeckite.git",
|
|
42
|
+
"directory": "packages/plugins/share"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/Rerurate514/riebeckite#readme",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/Rerurate514/riebeckite/issues"
|
|
47
|
+
},
|
|
48
|
+
"description": "Per-article share links and copy-to-clipboard for Riebeckite.",
|
|
49
|
+
"keywords": [
|
|
50
|
+
"riebeckite",
|
|
51
|
+
"plugin",
|
|
52
|
+
"share",
|
|
53
|
+
"social"
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
57
|
+
},
|
|
58
|
+
"sideEffects": [
|
|
59
|
+
"./style.css"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "node ../../../scripts/build_package.mjs",
|
|
63
|
+
"test": "node --import tsx --test \"test/*.test.ts\""
|
|
64
|
+
}
|
|
65
|
+
}
|
package/style.css
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @riebeckite/plugin-share
|
|
3
|
+
*
|
|
4
|
+
* Per-article share controls. Plugin CSS loads before theme CSS, so a theme can
|
|
5
|
+
* restyle the stable `rr-share` hooks without editing the plugin.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.rr-share {
|
|
9
|
+
--rr-share-ink: var(--rb-color-ink, inherit);
|
|
10
|
+
--rr-share-muted: var(--rb-color-muted, #5a5a5a);
|
|
11
|
+
--rr-share-accent: var(--rb-color-accent, currentColor);
|
|
12
|
+
--rr-share-rule: color-mix(in srgb, var(--rr-share-ink) 18%, transparent);
|
|
13
|
+
|
|
14
|
+
margin-block: 1.5rem;
|
|
15
|
+
color: var(--rr-share-ink);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.rr-share__list {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-wrap: wrap;
|
|
21
|
+
gap: 0.5rem;
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding: 0;
|
|
24
|
+
list-style: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.rr-share__item {
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.rr-share__link,
|
|
33
|
+
.rr-share__button {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
padding: 0.375rem 0.625rem;
|
|
37
|
+
border: 1px solid var(--rr-share-rule);
|
|
38
|
+
background: transparent;
|
|
39
|
+
color: inherit;
|
|
40
|
+
font: inherit;
|
|
41
|
+
font-size: 0.8125rem;
|
|
42
|
+
line-height: 1.4;
|
|
43
|
+
text-decoration: none;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.rr-share__link:hover,
|
|
48
|
+
.rr-share__link:focus-visible,
|
|
49
|
+
.rr-share__button:hover,
|
|
50
|
+
.rr-share__button:focus-visible {
|
|
51
|
+
border-color: var(--rr-share-accent);
|
|
52
|
+
color: var(--rr-share-accent);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.rr-share__link:focus-visible,
|
|
56
|
+
.rr-share__button:focus-visible {
|
|
57
|
+
outline: 2px solid var(--rr-share-accent);
|
|
58
|
+
outline-offset: 1px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.rr-share__button[hidden] {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.rr-share__status {
|
|
66
|
+
margin: 0.5rem 0 0;
|
|
67
|
+
font-size: 0.75rem;
|
|
68
|
+
line-height: 1.4;
|
|
69
|
+
color: var(--rr-share-muted);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.rr-share__status:empty {
|
|
73
|
+
display: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
html[data-theme="dark"] .rr-share,
|
|
77
|
+
html.dark .rr-share {
|
|
78
|
+
--rr-share-ink: var(--rb-color-paper, #ffffff);
|
|
79
|
+
}
|