Skip to content

Commit

Permalink
Merge pull request #13 from swup/next
Browse files Browse the repository at this point in the history
Update for swup 4
  • Loading branch information
daun authored Jul 26, 2023
2 parents 400fa51 + 3a217b0 commit fdb6d1f
Show file tree
Hide file tree
Showing 13 changed files with 5,704 additions and 7,280 deletions.
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,4 @@ wiki-wishlist
*.sublime-workspace
.editorconfig
.idea
lib
/plugins
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
/dist
16 changes: 0 additions & 16 deletions .npmignore

This file was deleted.

20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Changelog

<!-- ## [Unreleased] -->

## [2.0.0] - 2023-07-26

- Switch to microbundle
- Export native ESM module
- Update for swup 4 compatibility
- Require Gia as peer dependency
- Use swup's container option to find components

## [1.0.0] - 2019-05-21

- Initial release

[Unreleased]: https://github.com/swup/gia-plugin/compare/2.0.0...HEAD

[2.0.0]: https://github.com/swup/gia-plugin/releases/tag/2.0.0
[1.0.0]: https://github.com/swup/gia-plugin/releases/tag/1.0.0
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Swup Gia Plugin

A [swup](https://swup.js.org) plugin for integrating
[Gia](https://www.npmjs.com/package/gia) frontend components.

Automatically reloads components when required only for the replaced containers.

## Installation

Install the plugin from npm and import it into your bundle.

```bash
npm install @swup/gia-plugin
```

```js
import SwupGiaPlugin from '@swup/gia-plugin';
```

Or include the minified production file from a CDN:

```html
<script src="https://unpkg.com/@swup/gia-plugin@2"></script>
```

## Usage

To run this plugin, include an instance in the swup options.

```javascript
const swup = new Swup({
plugins: [new SwupGiaPlugin()]
});
```

## Options

### components

Components to be used for mount/unmount. Defaults to an empty object.

```javascript
import Component from 'gia/Component'

class ExampleComponent extends Component {
// ...
}

const components = {
ExampleComponent
}

const swup = new Swup({
plugins: [new SwupGiaPlugin({ components })]
})
```

### firstLoad

Whether the components should be loaded on start. Defaults to `true`.

```javascript
new SwupGiaPlugin({ firstLoad: true });
```

### log

Let Gia report info on mounting/unmounting of components. Corresponds to setting the `log` variable
of [Gia's config](https://github.com/giantcz/gia#config)). Defaults to `false`.

```javascript
new SwupGiaPlugin({ log: false });
```
Loading

0 comments on commit fdb6d1f

Please sign in to comment.