├── .editorconfig ├── .git-blame-ignore-revs ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yaml │ ├── publish.yml │ ├── size.yml │ └── test.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── assets ├── demo@2x.png └── logo.svg ├── deno.json ├── index.html ├── package.json ├── pnpm-lock.yaml ├── script ├── fix ├── fmt └── lint ├── src ├── icons │ ├── bluesky.svg │ ├── copy-url-done.svg │ ├── copy-url.svg │ ├── email.svg │ ├── facebook.svg │ ├── fediverse.svg │ ├── hackernews.svg │ ├── linkedin-in.svg │ ├── linkedin.svg │ ├── lobsters.svg │ ├── mastodon.svg │ ├── messenger.svg │ ├── odnoklassniki.svg │ ├── pinterest.svg │ ├── pocket.svg │ ├── print.svg │ ├── reddit.svg │ ├── teams.svg │ ├── telegram.svg │ ├── tumblr.svg │ ├── twitter.svg │ ├── viber.svg │ ├── vkontakte.svg │ ├── web-share.svg │ └── whatsapp.svg ├── index.js ├── shareon.css └── shareon.js ├── svgo.config.js └── vite.config.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | max_line_length = 80 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | d95105353f659f1dfc16aa00e97dde9a18406be4 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: kytta 2 | liberapay: kytta 3 | custom: paypal.me/NickKaramoff 4 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: CI 3 | 4 | on: 5 | push: 6 | branches: 7 | - main 8 | pull_request: 9 | 10 | permissions: {} 11 | 12 | jobs: 13 | format: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v4 17 | with: 18 | persist-credentials: false 19 | - uses: denoland/setup-deno@v2 20 | with: 21 | deno-version: v2.x 22 | - run: script/fmt 23 | - uses: pre-commit-ci/lite-action@v1.1.0 24 | if: ${{ github.event_name == 'pull_request' }} 25 | 26 | lint: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - uses: actions/checkout@v4 30 | with: 31 | persist-credentials: false 32 | - uses: denoland/setup-deno@v2 33 | with: 34 | deno-version: v2.x 35 | - run: script/lint --fix 36 | - uses: pre-commit-ci/lite-action@v1.1.0 37 | if: ${{ github.event_name == 'pull_request' }} 38 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | jobs: 9 | publish: 10 | runs-on: ubuntu-latest 11 | permissions: 12 | contents: read 13 | id-token: write 14 | 15 | steps: 16 | - name: Checkout 17 | uses: actions/checkout@v4 18 | - name: Set up pnpm 19 | uses: pnpm/action-setup@v4 20 | with: 21 | version: 9 22 | - name: Setup Node.js 23 | uses: actions/setup-node@v4 24 | with: 25 | node-version: 22 26 | registry-url: "https://registry.npmjs.org" 27 | cache: pnpm 28 | - name: Install dependencies 29 | run: pnpm install --ignore-scripts 30 | - name: Build 31 | run: pnpm run build 32 | - name: Publish to NPM (with provenance) 33 | run: pnpm publish --no-git-checks --access public --tag ${{ github.event.release.prerelease && 'next' || 'latest' }} 34 | env: 35 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 36 | NPM_CONFIG_PROVENANCE: "true" 37 | -------------------------------------------------------------------------------- /.github/workflows/size.yml: -------------------------------------------------------------------------------- 1 | name: Size Limit 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | pull-requests: write 10 | 11 | jobs: 12 | size: 13 | runs-on: ubuntu-latest 14 | env: 15 | CI_JOB_NUMBER: 1 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Fetch Git refs 20 | run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 21 | - uses: pnpm/action-setup@v4 22 | with: 23 | version: 9 24 | - uses: actions/setup-node@v4 25 | with: 26 | node-version: 22 27 | cache: pnpm 28 | - name: Check package size 29 | uses: andresz1/size-limit-action@v1.8.0 30 | with: 31 | github_token: ${{ secrets.GITHUB_TOKEN }} 32 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | env: 12 | FORCE_COLOR: 2 13 | 14 | jobs: 15 | test: 16 | runs-on: ubuntu-latest 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | - uses: pnpm/action-setup@v4 21 | with: 22 | version: 9 23 | - uses: actions/setup-node@v4 24 | with: 25 | node-version: 22 26 | cache: pnpm 27 | - name: Install dependencies 28 | run: pnpm install --ignore-scripts 29 | - name: Build 30 | run: pnpm run build 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dev/ 2 | dist/ 3 | .idea/ 4 | node_modules/ 5 | .vscode/ 6 | package-lock.json 7 | yarn.lock 8 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | ci: 2 | skip: 3 | - deno-fmt 4 | - deno-lint 5 | 6 | repos: 7 | - repo: https://github.com/pre-commit/pre-commit-hooks 8 | rev: v5.0.0 9 | hooks: 10 | - id: end-of-file-fixer 11 | exclude: 'src/icons/.*\.svg' 12 | - id: fix-byte-order-marker 13 | - id: mixed-line-ending 14 | - id: trailing-whitespace 15 | args: [--markdown-linebreak-ext=md] 16 | - id: check-json 17 | - id: check-toml 18 | - id: check-yaml 19 | - repo: local 20 | hooks: 21 | - id: deno-fmt 22 | name: deno fmt 23 | entry: deno fmt 24 | language: system 25 | types_or: 26 | - html 27 | - css 28 | - javascript 29 | - ts 30 | - json 31 | - yaml 32 | exclude_types: 33 | - markdown 34 | exclude: ^pnpm-lock\.yaml$ 35 | - repo: local 36 | hooks: 37 | - id: deno-lint 38 | name: deno lint 39 | entry: deno lint 40 | args: ["--fix"] 41 | language: system 42 | files: '\.[cm]?[jt]s$' 43 | - repo: https://github.com/kytta/mirrors-svgo 44 | rev: v4.0.0-rc.2 45 | hooks: 46 | - id: svgo 47 | files: "^src/icons/" 48 | additional_dependencies: 49 | - svgo@3 50 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [2.6.0] - 2024-11-23 8 | 9 | ### Added 10 | 11 | - [#132](https://github.com/kytta/shareon/pull/132) 12 | Hacker News button by [Abdelhadi](https://github.com/Abd-Elhadi) 13 | - [#134](https://github.com/kytta/shareon/pull/134) 14 | Bluesky button 15 | 16 | ### Security 17 | 18 | - [#122](https://github.com/kytta/shareon/pull/122) 19 | Bump `braces` to v3.0.3 20 | - [#135](https://github.com/kytta/shareon/pull/135) 21 | Bump `micromatch` to 4.0.8 22 | - [#136](https://github.com/kytta/shareon/pull/136) 23 | Bump `cross-spawn` to v7.0.5 24 | - [#137](https://github.com/kytta/shareon/pull/137) 25 | Bump `rollup` to v4.27.2 26 | 27 | ### Behind-the-scenes 28 | 29 | - [#123](https://github.com/kytta/shareon/pull/123) 30 | Use PNPM lockfile v9 31 | - [#124](https://github.com/kytta/shareon/pull/124) 32 | Update dev dependencies 33 | 34 | ## [2.5.0] - 2024-02-04 35 | 36 | ### Added 37 | 38 | - [#108](https://github.com/kytta/shareon/pull/108) 39 | Fediverse button (via [Share₂Fedi](https://github.com/kytta/share2fedi)) 40 | 41 | ## [2.4.0] - 2023-12-07 42 | 43 | ### Added 44 | 45 | - [#99](https://github.com/kytta/shareon/pull/99) 46 | Email button 47 | - [#100](https://github.com/kytta/shareon/pull/100) 48 | Print button 49 | 50 | ### Behind-the-scenes 51 | 52 | - [#95](https://github.com/kytta/shareon/pull/95) 53 | Update to Vite v5 54 | - [#101](https://github.com/kytta/shareon/pull/101) 55 | Enable automatic package publishing 56 | 57 | ## [2.3.0] - 2023-08-01 58 | 59 | ### Added 60 | 61 | - [#80](https://github.com/kytta/shareon/pull/80): 62 | Tumblr button by [Isaac](https://github.com/kabszac) 63 | 64 | ### Behind-the-scenes 65 | 66 | - [#82](https://github.com/kytta/shareon/pull/82): 67 | PNPM is now enforced by [Anderson](https://github.com/andersonjoseph) 68 | 69 | ## [2.2.3] - 2023-07-19 70 | 71 | ### Fixed 72 | 73 | - v2.2.2 was published with the bug not fixed. 74 | 75 | ## [2.2.2] - 2023-07-15 76 | 77 | ### Fixed 78 | 79 | - [#71](https://github.com/kytta/shareon/pull/71): 80 | Web Share icon got minified incorrectly, causing it to not show up at all. 81 | Fixed by Jake. 82 | 83 | ## [2.2.1] - 2023-07-15 84 | 85 | ### Behind-the-scenes 86 | 87 | - [#70](https://github.com/kytta/shareon/pull/70): 88 | Icon minification and inlining happens automatically now. As a bonus, the CSS 89 | size went a bit down :) 90 | 91 | ## [2.2.0] - 2023-07-15 92 | 93 | ### Added 94 | 95 | - `data-hashtags` for Facebook and Twitter by Edward in https://github.com/kytta/shareon/pull/60 96 | - Microsoft Teams button by Dimitrios in https://github.com/kytta/shareon/pull/66 97 | - Web Share API button by Dimitrios in https://github.com/kytta/shareon/pull/67 98 | 99 | ### Changed 100 | 101 | - the advertized bundle size now uses Brotli for compression (https://github.com/kytta/shareon/pull/69) 102 | 103 | ## [2.1.0] - 2023-03-20 104 | 105 | ### Added 106 | 107 | - "Copy URL" button in https://github.com/kytta/shareon/pull/44 108 | 109 | ### Behind-the-scenes 110 | 111 | - Added pre-commit hooks in https://github.com/kytta/shareon/pull/47 112 | - Fixed `size-limit-action` branch in https://github.com/kytta/shareon/pull/48 113 | 114 | ## [2.0.2] - 2023-01-25 115 | 116 | ### Changed 117 | 118 | - Sourcemaps are not being output any more 119 | - They're being loaded automatically and don't serve any other purpose. 120 | Disabling those helps us save a few bytes 121 | - Change minifier to esbuild (instead of terser) 122 | - This disables the minification of ESM, which is a good thing, because 123 | otherwise the file can't be tree-shaken properly 124 | - Shareon is now `type: "module"` 125 | - This doesn't change anything for the end users 126 | - Banner was removed 127 | - It took unnecessary bytes, and embedding it was somewhat buggy 128 | - Browserslist config now targets `defaults` 129 | - Opera 90 and Samsung Browser 17 aren't targeted. Shareon will still work on 130 | these browsers. 131 | - the previous config (using `last 3 versions instead` of `last 2 versions`) 132 | didn't change coverage that much 133 | 134 | ### Behind-the-scenes 135 | 136 | - Updated to Vite v4 137 | - CSS is now bundled using Vite 138 | - this makes the build script leaner; it's still processed with PostCSS 139 | - Moved PostCSS and ESLint config to package.json 140 | 141 | ## [2.0.1] - 2023-01-23 142 | 143 | ### Changed 144 | 145 | - Mastodon button updated to match the new style (#42) 146 | 147 | ## [2.0.0] - 2021-02-13 148 | 149 | ### Added 150 | 151 | - **BREAKING:** new (auto-)init behaviour, inspired by [petite-vue](https://github.com/vuejs/petite-vue) 152 | 153 | - `require`, `import`, or use ` 29 | ``` 30 | 31 | - `defer` makes sure Shareon is loaded after HTML is parsed 32 | - `init` will automatically initialize Shareon buttons 33 | 34 | ### Do not auto-initialize 35 | 36 | Remove the `init` attribute and initialize Shareon when you need it: 37 | 38 | ```html 39 | 43 | 44 | 48 | ``` 49 | 50 | ### Use ESM build 51 | 52 | There is also a ESM build for the browsers, which doesn't support 53 | auto-initialization: 54 | 55 | ```html 56 | 61 | ``` 62 | 63 | ### Bundle with Node 64 | 65 | You can also install Shareon using your favourite package manager and include it 66 | in your source files: 67 | 68 | ```sh 69 | pnpm add shareon # or `npm install`, or `yarn add` 70 | ``` 71 | 72 | ```js 73 | import { init } from "shareon"; 74 | import "shareon/css"; // most bundlers will transpile this CSS 75 | 76 | init(); 77 | ``` 78 | 79 | CommonJS imports are also supported: 80 | 81 | ```js 82 | const Shareon = require("shareon"); 83 | require("shareon/css"); // most bundlers will transpile this CSS 84 | 85 | Shareon.init(); 86 | ``` 87 | 88 | ## Usage 89 | 90 | Create a container with class `shareon` and populate it with elements, class 91 | names of which match the names of the social networks (or `copy-url`, for the 92 | 'Copy URL' button, or `print` for the 'Print' button): 93 | 94 | ```html 95 |
121 | ``` 122 | 123 | Shareon will populate these `` elements with correct `href` attributes. 124 | 125 | ### Use with `