nathanford / widowadjust

Hate typographic widows hanging around on your site? Use this. See it in action on artequalswork.com
MIT License
347 stars 27 forks source link

Installed via npm - wt is not defined #6

Open mattkomarnicki opened 4 years ago

mattkomarnicki commented 4 years ago

Hi Nathan, great plugin. This is exactly what I'm looking for, widow adjustment that works on both load and resize, however I have some issues making up and running.

1) I've installed the plugin via npm i widowtamer-npm --save.

2) I've made an import via import 'widowtamer-npm'; where I've successfully imported other packages.

3) In the other file where I do all the JS logic I've typed:

wt.fix({
    elements: 'h1 h2 h3 h4 h5 h6',
    chars: 20,
    method: 'nbsp',
    event: 'resize'
});

Unfortunately as soon as I refresh the page, console gives me ReferenceError: wt is not defined, pointing to wt.fix( line.

I thought that maybe assigning to window.wt would fix it.

import wt from 'widowtamer-npm';
window.wt = wt;

But then when I do npm run dev I get:

"export 'default' (imported as 'wt') was not found in 'widowtamer-npm'

What am I doing wrong?

richardcalahan commented 3 years ago

The module doesn't have a default export. It exports an object instead.

import { wt } from 'widowtamer-npm'