-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #774 from CloudCannon/feat/playground
Pagefind Playground
- Loading branch information
Showing
56 changed files
with
4,099 additions
and
1,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
npx -y pagefind@latest --site docs/public | ||
npx -y pagefind@latest --site docs/public --write-playground |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
title: "Pagefind Playground" | ||
nav_title: "Pagefind Playground" | ||
nav_section: References | ||
weight: 72 | ||
--- | ||
|
||
Pagefind provides a playground page that can be used to take a deeper look into how Pagefind searches your content. | ||
You can explore the playground for this documentation site at [/pagefind/playground/](/pagefind/playground/). | ||
|
||
Use the playground to: | ||
- Determine the ideal ranking parameters to configure for your content. | ||
- Debug any issues with how your content is being searched. | ||
- Explore all data returned from Pagefind for your content. | ||
|
||
The playground is always available at `/pagefind/playground/` when running Pagefind with the [serve](/docs/config-options/#serve) option, e.g. with `--serve` via the Pagefind CLI. | ||
|
||
Setting the [write playground](/docs/config-options/#write-playground) option when indexing will write the playground files to your bundle, allowing them to be hosted as part of your site. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
pagefind/integration_tests/node_api/node_base/pagefind-playground-via-api.toolproof.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Node API Base Tests > Pagefind playground can be built via the API | ||
platforms: | ||
- linux | ||
- mac | ||
|
||
steps: | ||
- ref: ./background.toolproof.yml | ||
- step: I have a "public/index.js" file with the content {js} | ||
js: |- | ||
import * as pagefind from "pagefind"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
const run = async () => { | ||
const { index } = await pagefind.createIndex({ | ||
writePlayground: true | ||
}); | ||
await index.addCustomRecord({ | ||
url: "/one/", | ||
content: "Testing file #1", | ||
language: "en" | ||
}); | ||
await index.addHTMLFile({sourcePath: "two/index.html", content: "<html lang='en'><body><h1>Testing file #2</h1></body></html>"}); | ||
await index.writeFiles(); | ||
console.log("✨!"); | ||
} | ||
run(); | ||
- macro: I run Pagefind Node as "index.js" in "public" | ||
- step: stdout should contain "✨!" | ||
- step: I serve the directory "public" | ||
- step: In my browser, I load "/pagefind/playground/" | ||
- step: In my browser, I evaluate {js} | ||
js: |- | ||
let heading = await toolproof.querySelector("h1"); | ||
toolproof.assert_eq(heading.innerText, `Pagefind Playground`); | ||
let val = await toolproof.querySelector("details > summary"); | ||
toolproof.assert_eq(val.innerText, `Details`); |
34 changes: 34 additions & 0 deletions
34
pagefind/integration_tests/playground/pagefind-ui-can-programmatically-filter.toolproof.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Pagefind Playground can be output | ||
steps: | ||
- step: I have the environment variable "PAGEFIND_SITE" set to "public" | ||
- step: I have a "public/res-zero/index.html" file with the content {html} | ||
html: >- | ||
<!DOCTYPE html><html lang="en"><head></head><body><h1>title title title</h1></body></html> | ||
- step: I have a "public/res-one/index.html" file with the content {html} | ||
html: >- | ||
<!DOCTYPE html><html lang="en"><head></head><body><h1>title res one</h1></body></html> | ||
- step: I have a "public/res-two/index.html" file with the content {html} | ||
html: >- | ||
<!DOCTYPE html><html lang="en"><head></head><body><h1>title res two</h1></body></html> | ||
- macro: I run Pagefind with "--write-playground" | ||
- step: stdout should contain "Running Pagefind" | ||
- step: The file "public/pagefind/pagefind.js" should not be empty | ||
- step: I serve the directory "public" | ||
- step: In my browser, I load "/pagefind/playground/" | ||
- step: In my browser, I evaluate {js} | ||
js: |- | ||
let val = await toolproof.querySelector("details > summary"); | ||
toolproof.assert_eq(val.innerText, `Details`); | ||
let search = await toolproof.querySelector("input[type='search']"); | ||
search.value = "title"; | ||
search.dispatchEvent(new Event('input', { bubbles: true })); | ||
- snapshot: In my browser, the result of {js} | ||
js: |- | ||
// Only exists when the result data loads | ||
let pinButton = await toolproof.querySelector(".result > code > button"); | ||
let title = await toolproof.querySelector(".result > code"); | ||
return title.innerText; | ||
snapshot_content: |- | ||
╎0: [0.29812253] ☆ /res-zero/ — title title title |
47 changes: 47 additions & 0 deletions
47
pagefind/integration_tests/python_api/py-pagefind-playground-via-api.toolproof.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Python API > Pagefind playground can be built via the API | ||
platforms: | ||
- linux | ||
- mac | ||
|
||
steps: | ||
- ref: ./background.toolproof.yml | ||
- step: I have a "public/run.py" file with the content {python} | ||
python: |2- | ||
import sys | ||
sys.path.append('%toolproof_process_directory%/wrappers/python/src') | ||
import asyncio | ||
import json | ||
import logging | ||
import os | ||
from pagefind.index import PagefindIndex, IndexConfig | ||
async def main(): | ||
config = IndexConfig( | ||
write_playground=True, | ||
) | ||
async with PagefindIndex(config=config) as index: | ||
await index.add_custom_record( | ||
url="/one/", | ||
content="Testing file #1", | ||
language="en", | ||
) | ||
await index.add_html_file( | ||
source_path="two/index.html", | ||
content="<html lang='en'><body><h1>Testing file #2</h1></body></html>", | ||
) | ||
print("Complete") | ||
if __name__ == "__main__": | ||
asyncio.run(main()) | ||
- macro: I run Pagefind Python as "run.py" in "public" | ||
- step: stdout should contain "Complete" | ||
- step: I serve the directory "public" | ||
- step: In my browser, I load "/pagefind/playground/" | ||
- step: In my browser, I evaluate {js} | ||
js: |- | ||
let heading = await toolproof.querySelector("h1"); | ||
toolproof.assert_eq(heading.innerText, `Pagefind Playground`); | ||
let val = await toolproof.querySelector("details > summary"); | ||
toolproof.assert_eq(val.innerText, `Details`); |
Oops, something went wrong.