Skip to content

Commit

Permalink
simplify README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ewnd9 committed Jan 25, 2020
1 parent 5bc49fb commit 03df484
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ $ yarn add anki-apkg-export

## Usage

### Node.js

```js
const fs = require('fs');
const initSqlJs = require('sql.js');
Expand All @@ -38,38 +36,13 @@ const { default: AnkiExport } = require('anki-apkg-export');
fs.writeFileSync('./output.apkg', zip, 'binary');
console.log(`Package has been generated: output.apkg`);
})();

```

### Browser (Webpack)

[`script-loader`](https://github.com/webpack/script-loader) is required

```js
import AnkiExport from 'anki-apkg-export';
import { saveAs } from 'file-saver';
import 'script-loader!sql.js/dist/sql-asm';

(async () => {
const sql = await window.initSqlJs();
const apkg = new AnkiExport('deck-name', {}, sql);

// could be a File from <input /> or a Blob from fetch
apkg.addMedia('anki.png', file);

apkg.addCard('card #1 front', 'card #1 back');
apkg.addCard('card #2 front', 'card #2 back', { tags: ['nice', 'better card'] });
apkg.addCard('card #3 with image <img src="anki.png" />', 'card #3 back');

const zip = await apkg.save()
saveAs(zip, 'output.apkg');
})();
```

## Examples

- [Node.js](examples/server)
- [Browser (Webpack), with ajax and input media attachments](examples/browser)
- [Browser/webpack/asm, with ajax and input media attachments](examples/browser)
- [Browser/webpack/wasm, with ajax and input media attachments](examples/browser)

## Changelog

Expand Down

0 comments on commit 03df484

Please sign in to comment.