iwf
    Preparing search index...

    Class SiteLink

    The class for a sitelink.

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    • Parameters

      • siteLink: SiteLink

        The siteLink for this class.

      Returns SiteLink

      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. Otherwise, we look it up with the 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 SiteLinks are equal.

      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.

      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.

      • Optionalbadges: string[]

        The badges of the site link, like featured article.

      • Optionalurl: string

        The URL of the page with domain.

      Returns SiteLink

      The SiteLink object.

      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'
      );