techouse / alfred-tailwindcss-docs

Search the Tailwind CSS documentation using Alfred
MIT License
56 stars 3 forks source link

getting error on the preview window #3

Open anguila opened 1 year ago

anguila commented 1 year ago

Hi! Thanks for sharing this workflow!

I'm getting the following error when opening the preview via cmd Y:

It seems to start to load the page but then it turns into this: image

Many thanks,

David

techouse commented 1 year ago

Hey!

Thanks for reporting. This looks like a website error as the page is simply a website link. Kinda odd behaviour though. Need to dig deeper, even though I'm not sure there's anything I can do tbh.

https://github.com/techouse/alfred-tailwindcss-docs/assets/1174328/9b71ad26-feab-449a-94b9-f52e6bf236d7

anguila commented 1 year ago

I just realised that issue seems to be happening only with branch v3 (default). if you use v0, v1 or v2 it actually does work. So there's some kind of problem with v3's website.

So as a quick workaround I just changed the script filter to include the branch v2 in it, so I don't have to type it every time:

image

Hope that helps anyone with that issue.

Best,

David

techouse commented 1 year ago

I did some digging on how this actually works on macOS.

Turns out this is all done by qlmanage. The problem is that qlmanage on its own can not load webpages. After digging deeper I found this hacky approach.

So one has to make a Property List, like so

/usr/libexec/PlistBuddy \
-c 'add :URL string "https://tailwindcss.com/docs/flex\#content-wrapper"' \
tailwind.webloc

which produces

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>URL</key>
    <string>https://tailwindcss.com/docs/flex#content-wrapper</string>
</dict>
</plist>

and then open that using

qlmanage -p tailwind.webloc

this produces the same error and I can't get the console of the browser to work. 🤪

And like you've observed above, v2 works fine, i.e.

/usr/libexec/PlistBuddy \
-c 'add :URL string "https://v2.tailwindcss.com/docs/transition-duration\#content-wrapper"' \
tailwind2.webloc \
&& qlmanage -p tailwind2.webloc