lisongx / wikidata-elements

Custom HTML elements to reuse Wikidata
https://wikidata-elements.js.org
MIT License
14 stars 2 forks source link

Wikipedia link #6

Closed dominiclooser closed 4 years ago

dominiclooser commented 4 years ago

Perhaps I did not see it, is there a possibility to get the wikipedia link? I think that's not a normal property.

lisongx commented 4 years ago

Hi Dominic @dominiclooser!

Thank you for opening up the issue,

We can't do that right now 😌. I don't think it's normal property, but it's something return in the Wikidata API under sitelinks (https://www.wikidata.org/wiki/Special:EntityData/Q42.json)

For reference, the API response for a certain item(Q42):

     "sitelinks": {
        "enwiki": {
          "site": "enwiki",
          "title": "Douglas Adams",
          "badges": [

          ],
          "url": "https://en.wikipedia.org/wiki/Douglas_Adams"
        },
        "enwikiquote": {
          "site": "enwikiquote",
          "title": "Douglas Adams",
          "badges": [

          ],
          "url": "https://en.wikiquote.org/wiki/Douglas_Adams"
        },

So we could easily add one new component wd-link (I'm thinking we should have new component for Link, just for the explicitly)

<wd-link 
    id="Q42" 
    sitelink="enwiki"
    # everyother attrs you can pass to HTML anchor tag
    alt="hover text" />Douglas Adams</wd-link>

to render an HTML a tag

<a href="https://en.wikipedia.org/wiki/Douglas_Adams" alt="hover text">Douglas Adams </a>

Would this solve your problem? Happy to know more about your idea and what you want to achieve using this!

Best Li

dominiclooser commented 4 years ago

Dear Li Thanks a lot for your answer and sorry for my late answer. I didn't get noticed and I didn't check manually. I am in the process of embedding wikidata data into my websites. One example is this: https://dominiclooser.netlify.com/empfehlungen/uw/ (work in progress). Here I did recommend films, books and people to a friend. In the background I just put in wikidata id's, and the actual label is fetched via your wonderfull web components. In the moment it's not a big difference to manually writing the name but in the future and want to build overlays with more infos about the items (similar to infoboxes). I starting to use this for a lot of different webpages. I love it. And your web components are very useful. Wikipedia links could be nice for these infoboxes. I am not sure if a separate component is the best way to implement, but I am not opposed to the idea. Thanks a lot for work! Best Dominic

lisongx commented 4 years ago

Hey Dominic,

It's really good to hear back from you!

Your site looks really cool, and to be honest, the way you're using this is exactly what I have in mind to built the tool for. I'm now working in the new tag which can use to render the wikipedia links (or any other link for a given property in wikidata for that matter, for example: P856 )

Will likely to have a working beta version available for you test, will let you know!

Thanks again for using this, more ideas and comments are welcome. ❤️

lisongx commented 4 years ago

@dominiclooser this is now possible in the 0.1.0 version!

Have a try and let me know if that works for you 🤞 https://github.com/lisongx/wikidata-elements#a-iswd-link , thanks again for opening this issue.

lisongx commented 4 years ago

@dominiclooser feel free to close the issue if you think this solve your problem

dominiclooser commented 4 years ago

Dear Li Thanks a lot for your work! Highly appreciated. I am just trying out the new link element, but it doesn't seem to work correctly. The href attribute does not get populated. I tried the following examples:

<a is='wd-link' entity-id='Q669591' site='enwiki'>English Wikipedia</a>

<a is='wd-link' entity-id='Q669591' property='P856'>Official Website</a>

<a is='wd-link' entity-id=#{entity.id} property='P345'>IMDB</a>

Did I do something wrong? I'm testing with current Chrome.

lisongx commented 4 years ago

I assume you are using the new version!

The code looks 100% correct to me, do you have a JSBin where you can reproduce that?

I’ll give it a try tomorrow, will let you know what I find out. Thanks for testing this!

dominiclooser commented 4 years ago

I guess I found the error, checking it out ... you are hearing from me ... Cheers!

dominiclooser commented 4 years ago

It works! I feel so silly, my code still used the old version although I updated it.

Thanks again for your work! I'm already far with the overlay and can show you soon the new version.