Class SiteLink

the class for a site link

Constructors

Properties

Accessors

Methods

Constructors

  • Parameters

    • siteLink: SiteLink

      The siteLink for this class

    Returns SiteLink

    Example

    const siteLink = new SiteLink({
    site: 'enwiki',
    title: 'Berlin',
    badges: ['Q17437796'],
    url: 'https://en.wikipedia.org/wiki/Berlin'
    });

Properties

_url: undefined | string
badges: string[]
site: string
title: string

Accessors

  • get internalID(): string
  • create a unique id for the site link

    Returns string

    the id

  • get url(): string
  • if the private property _url is set then we know the url already exists else we look it up with wikidata-properties package

    Returns string

    the url of the site link

Methods

  • this function checks if SiteLinks are equal

    Parameters

    Returns boolean

    true if the SiteLink are equal

    Example

    const siteLink1 = new SiteLink({ site: 'enwiki', title: 'foo' });
    const siteLink2 = new SiteLink({ site: 'enwiki', title: 'bar' });

    siteLink1.equals(siteLink2); // false
  • Returns SiteLink

    the SiteLink in a json format

    Example

    const json = siteLink.toJson();
    
  • create a SiteLink from a language and a value

    Parameters

    • site: string

      to what wiki is the site link

    • title: string

      the title of the page

    • Optional badges: string[]

      the badges of the site link like featured article

    • Optional url: string

      the url of the page with domain

    Returns SiteLink

    the SiteLink object

    Example

    const SiteLink = SiteLink.fromString('enwiki', 'Berlin');

    // or

    const SiteLink = SiteLink.fromString('enwiki', 'Berlin', ['Q17437796']);

    // or

    const SiteLink = SiteLink.fromString(
    'enwiki',
    'Berlin',
    ['Q17437796'],
    'https://en.wikipedia.org/wiki/Berlin'
    );

Generated using TypeDoc