### Install MkDocs Dependencies Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/build-the-doc.md Installs the required documentation dependencies using pip from the specified requirements file. Ensure Python is installed and added to your PATH. ```bash python -m pip install -r requirements-docs.txt ``` -------------------------------- ### Install Dependencies for Search Parts Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/how-to-contribute.md Run this command from the `search-parts` or `search-extensibility-demo` project to install necessary npm packages. ```bash npm i ``` -------------------------------- ### Build Project Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/how-to-contribute.md Use this command to build the SPFx project after installing dependencies or making changes. ```bash npm run build ``` -------------------------------- ### Serve the Solution Locally Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/how-to-contribute.md Start the SPFx Fast Serve Tool from the `search-parts` folder to enable quick development and debugging. ```bash npm run serve ``` -------------------------------- ### Serve Documentation Locally Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/build-the-doc.md Starts a local web server to preview the documentation. Open your browser to the provided address to see the changes. ```bash python -m mkdocs serve ``` -------------------------------- ### Template Example with Item Selection Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/templating.md This example shows how to apply a 'selected' CSS class to items based on their selection state using the `isItemSelected` Handlebars helper. It also demonstrates the use of `data-is-focusable`, `data-selection-index`, and `data-selection-toggle` attributes for item selection functionality. ```html ... {{#each data.items as |item|}}
{{slot item @root.slots.Title}}
{{/each}} ``` -------------------------------- ### Example Filter URL Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/scenarios/clickable-column-filter-link.md This is an example of a URL with a filter parameter appended to the query string. This format is used when a user clicks a filter link. ```url https://yourtenant.sharepoint.com/sites/YourSite?f_4b43307b-8891-42d5-9a62-7bfb83c11de9=%5B%7B%22filterName%22%3A%22RefinableString109%22%2C%22values%22%3A%5B%7B%22name%22%3A%22Trouble%20Brewing%22%2C%22value%22%3A%22%5C%22%C7%82%C7%8254726f75626c652042726577696e67%5C%22%22%2C%22operator%22%3A0%2C%22disabled%22%3Afalse%7D%5D%2C%22operator%22%3A%22or%22%7D%5D# ``` -------------------------------- ### Debug Library Component with Heft Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/index.md Use 'heft start' to debug library components with SPFx v1.22 and later. ```console heft start ``` -------------------------------- ### Get Summary with getSummary Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/templating.md Returns the formatted value for rendering, typically used with the HitHighlightedSummary managed property from SharePoint Search. ```handlebars {{getSummary "HitHighlightedSummary"}} ``` -------------------------------- ### Register Custom Layout Information Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/custom_layout.md Implement the `getCustomLayouts()` method in your `IExtensibilityLibrary` to return an array of `ILayoutDefinition` objects. This example shows how to define a custom layout with HTML and Handlebars rendering. ```typescript public getCustomLayouts(): ILayoutDefinition[] { /* eslint-disable @typescript-eslint/no-var-requires */ return [ { name: 'My custom layout', iconName: 'Color', key: 'CustomLayout', type: LayoutType.Results, renderType: LayoutRenderType.Handlebars, templateContent: require('../custom-layout.html').default.toString(), serviceKey: ServiceKey.create('MyCompany:CustomLayout', Customlayout) } ]; } ``` -------------------------------- ### Deep Link Example for Search Filters Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/templating.md Constructs a deep link to a search results page with a pre-selected filter. Requires the Search Filters web part instance ID and correctly formatted hex-encoded values. ```handlebars {{!-- Example for a Search Filters web part whose instance ID is known --}} {{!-- Replace the GUID below with the instance ID of your Search Filters web part --}} {{slot item @root.slots.Title}} ``` -------------------------------- ### Optional Generic Typing for DataSource Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/search-extensibility/README.md Use optional generic typing for `BaseDataSource` to get full intellisense for `this.context`. This is recommended for new code. ```typescript import { BaseDataSource } from '@pnp/modern-search-extensibility'; import { WebPartContext } from '@microsoft/sp-webpart-base'; export class MyDataSource extends BaseDataSource { public async getData() { // `this.context` is now typed as WebPartContext — full intellisense const url = this.context.pageContext.web.absoluteUrl; // ... } } ``` -------------------------------- ### Define Custom Adaptive Card Actions Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/adaptivecards_customizations.md Define custom actions within your Adaptive Card's JSON structure. This example shows how to include 'Action.Submit' and 'Action.OpenUrl' actions, which can then be handled by the `invokeCardAction` method in your TypeScript implementation. ```json { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.3", "body": [ { "type": "TextBlock", "text": "**${$root.data.totalItemsCount}** results", "size": "Medium", "wrap": true, "$when": "${$root.properties.showResultsCount == true}" }, { "type": "Container", "$data": "${data.items}", "items": [ { "type": "ColumnSet", "id": "${hitId}", "columns": [ { "type": "Column", "items": [ { "type": "TextBlock", "wrap": true, "text": "" } ], "width": "auto" }, { "type": "Column", "items": [ { "type": "TextBlock", "wrap": true, "text": "[${string(jPath($data, concat('.',$root.slots['Title']))[0])}](${string(jPath($data, concat('.',$root.slots['Path']))[0])})" } ], "width": "auto" }, { "type": "Column", "items": [ { "type": "ActionSet", "actions": [ { "type": "Action.Submit", "title": "Click on item", "style": "positive", "data": { "id": "123" } } ], "spacing": "medium" } ], "width": "auto" } ] } ] } ], "actions": [ { "type": "Action.Submit", "title": "Global click", "data": { "id": "456" } }, { "type": "Action.OpenUrl", "title": "Open URL", "url": "https://pnp.github.io/" } ] } ``` -------------------------------- ### getUniqueCount Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/templating.md Get the unique count of a property over the result set or get the unique count of objects in an array. ```APIDOC ## getUniqueCount ### Description Get the unique count of a property over the result set (or another array) or get the unique count of objects in an array. Example: [1,1,1,2,2,4] would return `3`. ### Example `{{getUniqueCount [1,1,1,2,2,4]}}` ``` -------------------------------- ### Deploy Documentation Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/build-the-doc.md Deploys the documentation using MkDocs. This command is typically run from the main branch. ```bash python -m mkdocs gh-deploy ``` -------------------------------- ### Create Symbolic Link for Search Extensibility Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/how-to-contribute.md After building the `search-extensibility` project, run this command to create a symbolic link for local development. ```bash npm link ``` -------------------------------- ### Get Tag Name with getTagName Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/templating.md Extracts the name of a tag from a tag field string, removing the ID component. ```handlebars {{getTagName "Tag"}} ``` -------------------------------- ### Build Project with Gulp Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/how-to-contribute.md An alternative command to build the SPFx project using Gulp. ```bash gulp bundle ``` -------------------------------- ### Build and package with Gulp Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/index.md Bundle and package the SPFx solution for deployment using the Gulp build toolchain. This command generates the necessary files for the app catalog. ```bash gulp bundle --ship gulp package-solution --ship ``` -------------------------------- ### Get URL Parameter Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/templating.md Extracts a query parameter value from a URL. If the URL is omitted, the current browser URL is used. ```handlebars {{getUrlParameter "k"}} ``` ```handlebars {{getUrlParameter "k" "https://foo?k=test"}} ``` -------------------------------- ### Get Unique Items with getUnique Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/templating.md Returns a new array containing only the unique values of a specified property from an array of objects. ```handlebars {{getUnique items "NewsCategory"}} ``` -------------------------------- ### Display a Panel with Content Source: https://github.com/microsoft-search/pnp-modern-search/blob/main/docs/extensibility/web_components_list.md Use `` to display a collapsible panel. Configure its appearance and behavior using attributes like `data-is-open`, `data-is-light-dismiss`, `data-is-blocking`, `data-size`, and `data-panel-header-text`. Content for the panel trigger and the panel itself are defined within `