@@ -13,83 +13,80 @@ new Crawler({
1313 indexName: "nfdocs",
1414 pathsToMatch: ["https://netfoundry.io/docs/**"],
1515 recordExtractor: ({ $, helpers }) => {
16- // priority order: deepest active sub list header -> navbar active item -> 'Documentation'
17- const lvl0 =
18- $(
19- " .menu__link.menu__link--sublist.menu__link--active, .navbar__item.navbar__link--active" ,
20- )
21- .last()
22- .text() || "Documentation";
16+ // priority order: deepest active sub list header -> navbar active item -> 'Documentation'
17+ const lvl0 =
18+ $(
19+ " .menu__link.menu__link--sublist.menu__link--active, .navbar__item.navbar__link--active" ,
20+ )
21+ .last()
22+ .text() || "Documentation";
2323
24- const records = helpers.docsearch({
25- recordProps: {
26- lvl0: {
27- selectors: "",
28- defaultValue: lvl0,
29- },
30- lvl1: ["header h1", "article h1"],
31- lvl2: "article h2",
32- lvl3: "article h3",
33- lvl4: "article h4",
34- lvl5: "article h5, article td:first-child",
35- lvl6: "article h6",
36- content: "article p, article li, article td:last-child",
37- },
38- indexHeadings: false, // ends up with empty results?
39- aggregateContent: true ,
40- recordVersion: "v3",
41- }, );
24+ const records = helpers.docsearch({
25+ recordProps: {
26+ lvl0: {
27+ selectors: "",
28+ defaultValue: lvl0,
29+ },
30+ lvl1: ["header h1", "article h1"],
31+ lvl2: "article h2",
32+ lvl3: "article h3",
33+ lvl4: "article h4",
34+ lvl5: "article h5, article td:first-child",
35+ lvl6: "article h6",
36+ content: "article p, article li, article td:last-child",
37+ },
38+ indexHeadings: false, // ends up with empty results?
39+ aggregateContent: false ,
40+ recordVersion: "v3",
41+ } );
4242
43- return records.map((rec) => {
44- rec.product = "unknown";
45- if (rec.url_without_anchor.includes("/docs/frontdoor"))
46- rec.product = "frontdoor";
47- else if (rec.url_without_anchor.includes("/docs/openziti"))
48- rec.product = "openziti";
49- else if (rec.url_without_anchor.includes("/docs/onprem"))
50- rec.product = "onprem";
51- else if (rec.url_without_anchor.includes("/docs/zlan"))
52- rec.product = "zlan";
53- else if (rec.url_without_anchor.includes("/docs/zrok"))
54- rec.product = "zrok";
55- return rec;
56- });
57- },
58- },
43+ return records.map((rec) => {
44+ rec.product = "unknown";
45+
46+ const u = rec.url_without_anchor || rec.url || "";
47+ const path = u.startsWith("http") ? new URL(u).pathname : u;
48+
49+ const m = path.match(/^\/docs\/([^\/]+)/);
50+ if (m) rec.product = m[1];
51+
52+ return rec;
53+ });
54+ },
55+ },
5956 {
6057 indexName: "netfoundry.io-docs-markdown",
6158 pathsToMatch: ["https://netfoundry.io/docs/**"],
6259 recordExtractor: ({ $, url, helpers }) => {
63- const text = helpers.markdown("main");
64- if (text === "") return [];
60+ const text = helpers.markdown("main");
61+ if (text === "") return [];
6562
66- // Extract meta tag values. These are required for Docusaurus
67- const language =
68- $('meta[name="docsearch:language"]').attr("content") || "en";
69- const version =
70- $('meta[name="docsearch:version"]').attr("content") || "latest";
71- const docusaurus_tag =
72- $('meta[name="docsearch:docusaurus_tag"]').attr("content") || "";
63+ // Extract meta tag values. These are required for Docusaurus
64+ const language =
65+ $('meta[name="docsearch:language"]').attr("content") || "en";
66+ const version =
67+ $('meta[name="docsearch:version"]').attr("content") || "latest";
68+ const docusaurus_tag =
69+ $('meta[name="docsearch:docusaurus_tag"]').attr("content") || "";
7370
74- return helpers.splitTextIntoRecords({
75- text,
76- baseRecord: {
77- url,
78- objectID: url,
79- title: $("head > title").text(),
80- lang: language, // Required for Docusaurus
81- language, // Required for Docusaurus
82- version: version.split(","), // in case there are multiple versions. Required for Docusaurus
83- docusaurus_tag: docusaurus_tag // Required for Docusaurus
84- .split(",")
85- .map((tag) => tag.trim())
86- .filter(Boolean),
71+ return helpers.splitTextIntoRecords({
72+ text,
73+ baseRecord: {
74+ url,
75+ objectID: url,
76+ title: $("head > title").text(),
77+ lang: language, // Required for Docusaurus
78+ language, // Required for Docusaurus
79+ version: version.split(","), // in case there are multiple versions. Required for Docusaurus
80+ docusaurus_tag: docusaurus_tag // Required for Docusaurus
81+ .split(",")
82+ .map((tag) => tag.trim())
83+ .filter(Boolean),
84+ },
85+ maxRecordBytes: 100000,
86+ orderingAttributeName: "part",
87+ });
8788 },
88- maxRecordBytes: 100000,
89- orderingAttributeName: "part",
90- });
91- },
92- },
89+ },
9390 ],
9491 initialIndexSettings: {
9592 nfdocs: {
0 commit comments