webmasterish / vuepress-plugin-autometa

Auto meta tags plugin for VuePress 1.x
MIT License
40 stars 6 forks source link

Front matter image source #9

Open davestewart opened 3 years ago

davestewart commented 3 years ago

Description

Better customisation of image source selection

Expected Behavior

I would be able to programatically choose the image source in frontmatter, using a string path or perhaps a function:

image_sources: [
    page => page.frontmatter.media.thumbnail || page.frontmatter.image
],

Actual Behavior

It seems the code only picks a frontmatter node called image but I want to pick one at media.thumbnail

Also, when the code moves on to use regex to grab a page tag, it ends up with:

<meta name="twitter:image" content="https://davestewart.co.uk/./screens/loading.png">

Also, note that this link shows a path relative the actual page - is there some way to get round this?

In my own code, I resolve the path and then require().

The compiled page (the image was just in markdown) actually shows this:

<img src="/assets/img/loading.143ab32a.png" alt="">

Steps to Reproduce

N/A

Your Environment

Sorry removed this as didn't think it was a bug before.

But, Node 12, latest everything else.

Great plugin, thanks for your hard work!

webmasterish commented 3 years ago

Hello @davestewart

Thanks for the feedback!

I'm currently quite busy and don't think I have any free time to go through this. If you have a solid solution, please feel free to submit a PR.

davestewart commented 3 years ago

Hello!

I've gotten it working locally using a bit of copy / paste, so perhaps I'll do this in due course :)

webmasterish commented 3 years ago

Cool!

davestewart commented 3 years ago

BTW... your brace, padding and comment style creates about 50% more lines than are actually needed in the file.

For example your source is nearly 900 lines, yet mine is < 600. It makes it quite hard to read vs, say Standard JS.

Would you consider a PR with a linting setup added?

webmasterish commented 3 years ago

I'm well aware of all the "standards" and all the linting tools, but that's how I write my code and that's how it's readable to me, and I wouldn't change it for every new standard/linting that comes along.

Thanks for taking the time to look into it and offering to do it, but I must say no.