mwbot-ts - v1.2.7
    Preparing search index...

    Interface Title

    The instance members of the Title class. For static members including the constructor (defined separately due to TypeScript limitations) and the differences in feature from the native mediawiki.Title, see TitleStatic.

    interface Title {
        canHaveTalkPage(): boolean;
        equals(title: string | Title, evalFragment?: boolean): null | boolean;
        exists(): null | boolean;
        getExtension(): null | string;
        getFileNameTextWithoutExtension(): string;
        getFileNameWithoutExtension(): string;
        getFragment(): null | string;
        getInterwiki(): string;
        getMain(): string;
        getMainText(): string;
        getNamespaceId(): number;
        getNamespacePrefix(): string;
        getPrefixedDb(options?: TitleOutputOptions): string;
        getPrefixedText(options?: TitleOutputOptions): string;
        getRelativeText(namespace: number): string;
        getSubjectPage(): null | Title;
        getTalkPage(): null | Title;
        hadLeadingColon(): boolean;
        isExternal(): boolean;
        isLocal(): boolean;
        isTalkPage(): boolean;
        isTrans(): boolean;
        toString(): string;
        toText(): string;
        wasLocalInterwiki(): boolean;
    }
    Index

    Methods

    • Check if the title can have an associated talk page.

      Returns boolean

    • Checks if this Title is equal to a given title.

      This method is exclusive to mwbot-ts.

      Parameters

      • title: string | Title

        The title to compare against.

      • OptionalevalFragment: boolean

        Whether to include the fragment in the comparison. (Default: false)

      Returns null | boolean

      true if the titles are equal, false otherwise, or null if title is invalid.

    • Check whether this title exists on the wiki.

      This is an instance method that does the same as the static method TitleStatic.exists.

      Returns null | boolean

      Boolean if the information is available, otherwise null.

    • Get the extension of the page name (if any).

      Returns null | string

      Name extension or null if there is none.

    • Get the page name as if it is a file name, without extension or namespace prefix, in the human-readable form with spaces instead of underscores. For example, the title File:Example_image.svg will be returned as Example image.

      Note that this method will work for non-file titles but probably give nonsensical results. A title like User:Dr._J._Fail will be returned as Dr. J! Use getMainText instead.

      Returns string

    • Get the page name as if it is a file name, without extension or namespace prefix, in the canonical form with underscores instead of spaces. For example, the title File:Example_image.svg will be returned as Example_image.

      Note that this method will work for non-file titles but probably give nonsensical results. A title like User:Dr._J._Fail will be returned as Dr._J! Use getMain instead.

      Returns string

    • Get the fragment (if any), with all underscores replaced by spaces.

      Note that this method (by design) does not include the hash character and the value is not URL-encoded.

      Returns null | string

    • Get the interwiki prefix.

      Example: mw: for mw:Main_page.

      If an interwiki is set, interwiki prefix plus :, an empty string otherwise. Use isExternal to check if an interwiki is set.

      This method is exclusive to mwbot-ts.

      Returns string

      Interwiki prefix(es).

    • Get the main page name.

      Example: Example_image.svg for File:Example_image.svg.

      Returns string

    • Get the main page name (with spaces instead of underscores).

      Example: Example image.svg for File:Example_image.svg.

      Returns string

    • Get the namespace number.

      Example: 6 for File:Example_image.svg.

      Returns number

    • Get the namespace prefix (in the content language).

      Example: File: for File:Example_image.svg. In NS_MAIN this is an empty string, otherwise namespace name plus :.

      Returns string

    • Get the full page name.

      Example: File:Example_image.svg. Most useful for API calls, anything that must identify the "title".

      Parameters

      • Optionaloptions: TitleOutputOptions

        Title output options.

        This parameter is exclusive to mwbot-ts.

      Returns string

    • Get the full page name, with all underscores replaced by spaces.

      Example: File:Example image.svg for File:Example_image.svg.

      Parameters

      • Optionaloptions: TitleOutputOptions

        Title output options.

        This parameter is exclusive to mwbot-ts.

      Returns string

    • Get the page name relative to a namespace.

      Example:

      • Foo:Bar relative to the Foo namespace becomes Bar.
      • Bar relative to any non-main namespace becomes :Bar.
      • Foo:Bar relative to any namespace other than Foo stays Foo:Bar.

      Parameters

      • namespace: number

        The namespace to be relative to.

      Returns string

      The page name relative to a namespace.

      NOTE: Interwiki prefixes (if any) are not included in the output.

    • Get the title for the subject page of a talk page.

      Returns null | Title

      The title for the subject page of a talk page, null if not available.

      NOTE: If this Title is interwiki, this method always returns null because interwiki titles are always treated as being in the default namespace. Without this restriction, the method would simply return the current instance unchanged.

    • Get the title for the associated talk page.

      Returns null | Title

      The title for the associated talk page, null if not available.

      NOTE: If this Title is interwiki, this method always returns null because interwiki titles are always treated as being in the default namespace. Without this restriction, the method would simply return the current instance unchanged.

    • Check if the input title text had a leading colon (e.g., :Category:CSD).

      This method is exclusive to mwbot-ts.

      Returns boolean

    • Check if the title is in a talk namespace.

      Returns boolean

      Whether the title is in a talk namespace.

    • Determine whether the interwiki Title refers to a page within this project and is transcludable. If isExternal is false, this method always returns false.

      This method is exclusive to mwbot-ts.

      Returns boolean

      true if this is transcludable.

    • Alias of getPrefixedDb.

      This method does not accept output options, meaning the output will always include interwiki prefixes but will exclude the fragment and leading colon, if present. See TitleOutputOptions for details.

      Returns string

    • Alias of getPrefixedText.

      This method does not accept output options, meaning the output will always include interwiki prefixes but will exclude the fragment and leading colon, if present. See TitleOutputOptions for details.

      Returns string

    • Check if this Title had a local interwiki prefix (e.g., en:Main_page on enwiki).

      Such a prefix is erased on instance initialization (i.e., getPrefixedDb outputs Main_page).

      This method is exclusive to mwbot-ts.

      Returns boolean