-
-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Pagefind weight frontmatter #2371
Open
lorenzolewis
wants to merge
10
commits into
main
Choose a base branch
from
lorenzo-pagefind-weight
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
980e14e
add pagefind weight
lorenzolewis f267313
add weight test
lorenzolewis 87aefc7
add additional check
lorenzolewis 9b4138c
add e2e tests
lorenzolewis b1c6d1a
update lockfile
lorenzolewis ead0890
Merge branch 'main' into lorenzo-pagefind-weight
lorenzolewis 9784394
add changeset
lorenzolewis 8f611d3
Revert "add weight test"
lorenzolewis 2d7ba3a
update guide docs
lorenzolewis 820161b
update references guide
lorenzolewis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/starlight': patch | ||
--- | ||
|
||
Adds the `pagefind.weight` frontmatter property for customizing how a page ranks in Pagefind search results. |
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
10 changes: 10 additions & 0 deletions
10
packages/starlight/__e2e__/fixtures/pagefind/astro.config.mjs
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,10 @@ | ||
import starlight from '@astrojs/starlight'; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
export default defineConfig({ | ||
integrations: [ | ||
starlight({ | ||
title: 'Pagefind', | ||
}), | ||
], | ||
}); |
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,9 @@ | ||
{ | ||
"name": "@e2e/pagefind", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/starlight": "workspace:*", | ||
"astro": "^4.15.3" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/starlight/__e2e__/fixtures/pagefind/src/content/config.ts
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,6 @@ | ||
import { defineCollection } from 'astro:content'; | ||
import { docsSchema } from '@astrojs/starlight/schema'; | ||
|
||
export const collections = { | ||
docs: defineCollection({ schema: docsSchema() }), | ||
}; |
7 changes: 7 additions & 0 deletions
7
packages/starlight/__e2e__/fixtures/pagefind/src/content/docs/custom-weight.mdx
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,7 @@ | ||
--- | ||
title: Index | ||
pagefind: | ||
weight: 5.5 | ||
--- | ||
|
||
This page has a custom weight of 5.5. |
6 changes: 6 additions & 0 deletions
6
packages/starlight/__e2e__/fixtures/pagefind/src/content/docs/ignored-page.mdx
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,6 @@ | ||
--- | ||
title: Index | ||
pagefind: false | ||
--- | ||
|
||
This page will NOT be indexed. |
5 changes: 5 additions & 0 deletions
5
packages/starlight/__e2e__/fixtures/pagefind/src/content/docs/pagefind.mdx
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,5 @@ | ||
--- | ||
title: Index | ||
--- | ||
|
||
This is a page that should be indexed with no special weight. |
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,28 @@ | ||
import { expect, testFactory } from './test-utils'; | ||
|
||
const test = testFactory('./fixtures/pagefind/'); | ||
|
||
test('page has pagefind data attribute', async ({ page, getProdServer }) => { | ||
const starlight = await getProdServer(); | ||
await starlight.goto('/pagefind'); | ||
|
||
const main = page.locator('main'); | ||
await expect(main).toHaveAttribute('data-pagefind-body'); | ||
}); | ||
|
||
test('page has no pagefind data attribute', async ({ page, getProdServer }) => { | ||
const starlight = await getProdServer(); | ||
await starlight.goto('/ignored-page'); | ||
|
||
const main = page.locator('main'); | ||
await expect(main).not.toHaveAttribute('data-pagefind-body'); | ||
}); | ||
|
||
test('page has custom weighting', async ({ page, getProdServer }) => { | ||
const starlight = await getProdServer(); | ||
await starlight.goto('/custom-weight'); | ||
|
||
const main = page.locator('main'); | ||
await expect(main).toHaveAttribute('data-pagefind-body'); | ||
await expect(main).toHaveAttribute('data-pagefind-weight', '5.5'); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to explain to users when they should change the ranking, and why. The docs of pagefind only explain some technical stuff, but from the point of view of a maintainer like myself, it would be nice to have some guidance on why I should use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ematipico Thanks! Do you think this gives a good example of the usage here? Happy for any suggestions if anything else comes to mind 🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting somewhere I think. Now we should explain when to increase the page weight and when decrease the page weight.