Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ndyag/anki-apkg
Create .apkg file for Anki
https://github.com/ndyag/anki-apkg
anki
Last synced: 24 days ago
JSON representation
Create .apkg file for Anki
- Host: GitHub
- URL: https://github.com/ndyag/anki-apkg
- Owner: NdYAG
- License: mit
- Created: 2018-02-26T10:07:13.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T09:27:21.000Z (2 months ago)
- Last Synced: 2024-10-12T23:24:16.929Z (24 days ago)
- Topics: anki
- Language: TypeScript
- Size: 122 KB
- Stars: 36
- Watchers: 3
- Forks: 8
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# anki-apkg
anki-apkg is highly inspired by [anki-apkg-export](https://github.com/repeat-space/anki-apkg-export/) and works almost the same, then why a new package?
Because I'm not satisfied with only creating `{{front}}` and `{{back}}` field for a card, this package is created to make it possible to customize fields (and any other variables of a deck or card in the future).
```
npm install anki-apkg
``````js
const { APKG } = require('anki-apkg')const apkg = new APKG({
name: 'VocabularyBuilder',
card: {
fields: ['word', 'meaning', 'usage'],
template: {
question: '{{word}}',
answer: `
{{word}}
{{meaning}}
{{usage}}
`
},
styleText: '.card { text-align: center; }'
}
})
apkg.addCard({
timestamp: +new Date(), // create time
content: ['sample word', 'sample meaning', 'sample usage'] // keep the order same as `fields` defined above
})
apkg.save(__dirname)
```## Media
You can add media files to packages using
```ts
apkg.addMedia(filename: string, data: Buffer)
``````js
const { readFileSync } = require('fs')
const { join } = require('path')const { APKG } = require('../')
const apkg = new APKG({
name: 'UnicornBuilder',
card: {
fields: ['question', 'result'],
template: {
question: '{{question}}',
answer: `{{result}}`
}
}
})
apkg.addCard({
content: ['What happens if you eat too many skittles?', '']
})
apkg.addMedia('unicorn.gif', readFileSync(join(__dirname, 'media/unicorn.gif')))
apkg.save(__dirname)```