Merge branch 'smart-autoinit'

https://codeberg.org/kytta/shareon/pulls/2
pull/45/head
Nikita Karamov 2022-02-10 20:37:45 +01:00
commit 3226d8442d
No known key found for this signature in database
GPG Key ID: 3C8E688C96EEB9C9
3 changed files with 27 additions and 15 deletions

View File

@ -6,10 +6,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [Unreleased]
### Added
- **BREAKING:** new (auto-)init behaviour, inspired by [petite-vue](https://github.com/vuejs/petite-vue)
- `require`, `import`, or use `<script>` to include Shareon without
initialization
- use exported `initializeShareon` function in Node to initialize Shareon
- use `init` attribute in `script` to initialize Shareon in-browser
```html
<script src="path/to/shareon.js" init>
```
### Changed
- **BREAKING:** default version of the package doesn't auto-initialize buttons
- change code style to [Prettier](https://prettier.io/)
### Removed
- **BREAKING:** `noinit` version of the package is removed
## [1.6.3] - 2022-02-02
### Changed
@ -200,7 +217,7 @@ Initial release of shareon
- Add Telegram button
- Add Twitter button
[Unreleased]: https://codeberg.org/kytta/shareon/compare/v1.6.3...main
[unreleased]: https://codeberg.org/kytta/shareon/compare/v1.6.3...main
[1.6.2]: https://github.com/kytta/shareon/compare/v1.6.2...v1.6.3
[1.6.2]: https://github.com/kytta/shareon/compare/v1.6.1...v1.6.2
[1.6.1]: https://github.com/kytta/shareon/compare/v1.6.0...v1.6.1

View File

@ -99,15 +99,8 @@ const getOutput = (baseDir) => {
];
};
export default [
{
input: join(__dirname, "src", "autoinit.js"),
output: getOutput(outputDir),
plugins: getPlugins(true),
},
{
input: join(__dirname, "src", "shareon.js"),
output: getOutput(join(outputDir, "noinit")),
plugins: getPlugins(false),
},
];
export default {
input: join(__dirname, "src", "index.js"),
output: getOutput(outputDir),
plugins: getPlugins(true),
};

View File

@ -1,8 +1,10 @@
import initializeShareon from "./shareon";
import "./style.css";
window.onload = () => {
// TODO: update README
const s = document.currentScript;
if (s && s.hasAttribute("init")) {
initializeShareon();
};
}
export default initializeShareon;