-
Notifications
You must be signed in to change notification settings - Fork 189
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
index videos and add external data to search #1266
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
38f0ad5
centralize articles, video, and external data into global 11ty data
e111077 f64f2d9
Delete tutorials index.html and
e111077 2626920
Update .prettierignore file.
e111077 a3aa341
address PR suggestions
e111077 9243887
update screenshot golden
e111077 1bde9a5
index videos and add external data to search
e111077 12343d5
Merge branch 'main' into index-videos-and-extra
e111077 eae7d10
Refactor search indexers and update video search
e111077 dd2affb
run formatter
e111077 eef4d32
remove duplicate doctypes
e111077 1331ba5
remove optional chaining to fail fast
e111077 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
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,5 @@ | ||
--- | ||
permalink: external-search-data/data.json | ||
--- | ||
|
||
{% if not env.DEV %}{{ externalSearchData | dump | safe }}{% endif %} |
7 changes: 7 additions & 0 deletions
7
packages/lit-dev-content/site/external-search-data/videos.html
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 @@ | ||
--- | ||
permalink: external-search-data/videos.json | ||
--- | ||
|
||
{% if not env.DEV %} | ||
{{ videos | videosToAlgoliaRecords | dump | safe }} | ||
{% endif %} |
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,19 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import {html} from 'lit'; | ||
|
||
// Source: https://fonts.google.com/icons?selected=Material+Symbols+Outlined:open_in_new:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=open_in_new | ||
export const openInNewIcon = html` <svg | ||
height="24px" | ||
viewBox="0 -960 960 960" | ||
width="24px" | ||
fill="currentcolor" | ||
> | ||
<path | ||
d="M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h280v80H200v560h560v-280h80v280q0 33-23.5 56.5T760-120H200Zm188-212-56-56 372-372H560v-80h280v280h-80v-144L388-332Z" | ||
/> | ||
</svg>`; |
33 changes: 33 additions & 0 deletions
33
packages/lit-dev-tools-cjs/src/search/indexers/index-external-data.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,33 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
e111077 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import * as fs from 'fs/promises'; | ||
import * as path from 'path'; | ||
import type {UserFacingPageData} from '../plugin'; | ||
|
||
export async function indexExternalData( | ||
outputDir: '_dev' | '_site', | ||
idOffset = 0 | ||
) { | ||
if (outputDir === '_dev') { | ||
return []; | ||
} | ||
|
||
// Path of the external data index. | ||
const EXTERNAL_DATA_INDEX_PATH = path.resolve( | ||
__dirname, | ||
`../../../../lit-dev-content/${outputDir}/external-search-data/data.json` | ||
); | ||
|
||
const fileContents = await fs.readFile(EXTERNAL_DATA_INDEX_PATH, 'utf-8'); | ||
const data = JSON.parse(fileContents) as UserFacingPageData[]; | ||
data.forEach((searchRecord) => { | ||
searchRecord.objectID = `${++idOffset}`; | ||
searchRecord.isExternal = true; | ||
}); | ||
|
||
return data; | ||
} |
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
29 changes: 29 additions & 0 deletions
29
packages/lit-dev-tools-cjs/src/search/indexers/index-videos.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,29 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
e111077 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import * as fs from 'fs/promises'; | ||
import * as path from 'path'; | ||
import type {UserFacingPageData} from '../plugin'; | ||
|
||
export async function indexVideos(outputDir: '_dev' | '_site', idOffset = 0) { | ||
if (outputDir === '_dev') { | ||
return []; | ||
} | ||
|
||
// Path of the video index. | ||
const VIDEO_INDEX_PATH = path.resolve( | ||
__dirname, | ||
`../../../../lit-dev-content/${outputDir}/external-search-data/videos.json` | ||
); | ||
|
||
const fileContents = await fs.readFile(VIDEO_INDEX_PATH, 'utf-8'); | ||
const videos = JSON.parse(fileContents) as UserFacingPageData[]; | ||
videos.forEach((video) => { | ||
video.objectID = `${++idOffset}`; | ||
}); | ||
|
||
return videos; | ||
} |
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
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.
Is this maybe a bit long? Will Algolia return this whole block of text for the search -option text snippet?
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 only returns the relevant snippet like in the first image