The Pagination component is used to navigate between different pages of a search results set.

Note: If no maximum number of page links to display is configured in the HawkSearch admin, a default value of 9 will be used.

Tag

The tag for this component is <hawksearch-pagination>.

Event-Binding Attributes

Name Value
hawksearch-page number

When an element with this attribute is clicked, the current search will be updated to display the results from the specified page.

Handlebars Helpers

Name Parameter
pageUrl number

This helper function returns the URL for the specified page to enable crawling.

Default Template

The following is the default Handlebars template for this component. To create a custom template, it is recommended to use this as a starting point.

<div class="pagination">
{{#if strings.summary}}
<div class="pagination__summary">{{strings.summary}}</div>
{{/if}}
<div class="pagination__pages">
{{#if displayFirstLink}}
<span hawksearch-page="1" class="link pagination__page pagination__page--first" title="{{strings.first}}">
<hawksearch-icon name="chevron-back" size="1.2em"></hawksearch-icon>
</span>
{{/if}}
{{#if displayPreviousLink}}
<a
hawksearch-page="{{subtract page 1}}"
rel="prev"
href="{{pageUrl (subtract page 1)}}"
class="pagination__page pagination__page--previous"
title="{{strings.previous}}"
>
<hawksearch-icon name="chevron-left" size="1.2em"></hawksearch-icon>
</a>
{{/if}}
{{#each pages}}
{{#if (eq this @root.page)}}
<span class="pagination__page pagination__page--selected">{{this}}</span>
{{else}}
<a hawksearch-page="{{this}}" href="{{pageUrl this}}" class="pagination__page">{{this}}</a>
{{/if}}
{{/each}}
{{#if displayNextLink}}
<a
hawksearch-page="{{add page 1}}"
rel="next"
href="{{pageUrl (add page 1)}}"
class="pagination__page pagination__page--next"
title="{{strings.next}}"
>
<hawksearch-icon name="chevron-right" size="1.2em"></hawksearch-icon>
</a>
{{/if}}
{{#if displayLastLink}}
<span hawksearch-page="{{totalPages}}" class="link pagination__page pagination__page--last" title="{{strings.last}}">
<hawksearch-icon name="chevron-forward" size="1.2em"></hawksearch-icon>
</span>
{{/if}}
</div>
</div>

Hierarchy

Properties

bindFromEvent: boolean = true
componentName: keyof HawkSearchComponents = 'pagination'
configOverride?: PaginationComponentConfig

Optional instance-level configuration to override the global configuration

The data bound to the Handlebars template.

data?: Pagination

The data bound to the component.

defaultHtml: string = defaultHtml
handlebars: typeof Handlebars = HawkSearch.handlebars

The Handlebars reference shared by all HawkSearch components.

Accessors

  • get configuration(): undefined | TConfig
  • The optional configuration object for this component.

    Returns undefined | TConfig

  • get rootElement(): ParentNode
  • The root element which should be used for querying any child elements. This resolves to this.shadowRoot if the Shadow DOM is enabled, otherwise this.

    Returns ParentNode

Methods

  • After the component is rendered, this method is called to bind any child components.

    Returns void

  • Replaces placeholders in a given string with values from a data object.

    Parameters

    • template: string

      The template string.

    • values: Record<string, string>

      The object containing properties which will be bound to template.

    Returns string

    The template string with all placeholders replaced by the values specified in values.

  • After the component is rendered, this method is called for any additional processing (such as attaching event listeners) which needs to occur.

    Returns void

  • Optional method that can be overwritten to register Handlebars helper functions which can be accessed from the template. For more information, see Custom Helpers.

    Returns void

  • Determines whether the data meets the necessary conditions to perform data binding and render content.

    Returns boolean

    Whether the component should be rendered. If false, the component will have empty contents and be set to display: none;.

  • Parameters

    • page: number

    Returns Promise<void>

  • Type Parameters

    • T

    Parameters

    • name: string
    • data: T

    Returns void