Skip to content

Commit

Permalink
docs(core): Create embeddings fix null url paths (#18716)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham authored Aug 18, 2023
1 parent 44b2d3f commit 476c133
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tools/documentation/create-embeddings/src/main.mts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import manifestsPackages from '../../../../docs/generated/manifests/packages.jso
import manifestsRecipes from '../../../../docs/generated/manifests/recipes.json' assert { type: 'json' };
import manifestsTags from '../../../../docs/generated/manifests/tags.json' assert { type: 'json' };

let identityMap = {};

dotenv.config();

type ProcessedMdx = {
Expand Down Expand Up @@ -184,11 +186,14 @@ async function generateEmbeddings() {
}
);

const allFilesPaths = [
// Ensures that indentityMap gets populated first
let allFilesPaths = [...getAllFilesWithItemList(manifestsNx)];

allFilesPaths = [
...allFilesPaths,
...getAllFilesFromMapJson(mapJson),
...getAllFilesWithItemList(manifestsCloud),
...getAllFilesWithItemList(manifestsExtending),
...getAllFilesWithItemList(manifestsNx),
...getAllFilesWithItemList(manifestsPackages),
...getAllFilesWithItemList(manifestsRecipes),
...getAllFilesWithItemList(manifestsTags),
Expand Down Expand Up @@ -370,14 +375,16 @@ function delay(ms: number) {

function getAllFilesFromMapJson(doc): WalkEntry[] {
const files: WalkEntry[] = [];

function traverse(itemList) {
for (const item of itemList) {
if (item.file && item.file.length > 0) {
// we can exclude some docs here, eg. the deprecated ones
// the path is the relative path to the file within the nx repo
// the url_partial is the relative path to the file within the docs site - under nx.dev
files.push({ path: `docs/${item.file}.md`, url_partial: item.path });
files.push({
path: `docs/${item.file}.md`,
url_partial: identityMap[item.id]?.path || '',
});
}

if (item.itemList) {
Expand All @@ -401,6 +408,9 @@ function getAllFilesWithItemList(data): WalkEntry[] {
// the path is the relative path to the file within the nx repo
// the url_partial is the relative path to the file within the docs site - under nx.dev
files.push({ path: `docs/${item.file}.md`, url_partial: item.path });
if (!identityMap[item.id]) {
identityMap = { ...identityMap, [item.id]: item };
}
}

if (item.itemList) {
Expand Down

1 comment on commit 476c133

@vercel
Copy link

@vercel vercel bot commented on 476c133 Aug 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.