@@ -11,9 +11,11 @@ const {
11
11
DEFAULT_LOCALE ,
12
12
} = require ( './utils.node' ) ;
13
13
14
- const processMdxEntry = ( { children : [ entry ] } , kind = 'docs' ) => {
14
+ const processMdxEntry = (
15
+ { children : [ entry ] , relativeDirectory } ,
16
+ kind = 'docs' ,
17
+ ) => {
15
18
const {
16
- fileAbsolutePath,
17
19
mdxAST,
18
20
objectID,
19
21
frontmatter : { title, redirect, slug : customSlug } ,
@@ -26,28 +28,24 @@ const processMdxEntry = ({ children: [entry] }, kind = 'docs') => {
26
28
* avoid indexing this section for a while to avoid
27
29
* search user's confusion
28
30
*/
29
- if ( / c l o u d r e s t a p i / i. test ( fileAbsolutePath ) ) {
31
+ if ( / c l o u d r e s t a p i / i. test ( relativeDirectory ) ) {
30
32
// eslint-disable-next-line no-console
31
- console . log ( 'exluded from algolia indecies pages:' , fileAbsolutePath ) ;
33
+ console . log ( 'exluded from algolia indecies pages:' , relativeDirectory ) ;
32
34
return [ ] ;
33
35
}
34
36
35
37
// @TODO : remove to enable sending spanish content to Algolia
36
38
if ( I18N_CONFIG . hideEsFromAlgoliaSearch ) {
37
- if ( / \/ e s \/ / i. test ( fileAbsolutePath ) ) {
39
+ if ( / \/ e s \/ / i. test ( relativeDirectory ) ) {
38
40
// eslint-disable-next-line no-console
39
- console . log ( 'exluded ES page from algolia indecies:' , fileAbsolutePath ) ;
41
+ console . log ( 'exluded ES page from algolia indecies:' , relativeDirectory ) ;
40
42
return [ ] ;
41
43
}
42
44
}
43
45
44
- const strippedDirectory = stripDirectoryPath ( fileAbsolutePath , kind ) ;
46
+ const strippedDirectory = stripDirectoryPath ( relativeDirectory , kind ) ;
45
47
// cut the last piece (the actual name of a file) to match the generation in node
46
- const cutStrippedDirectory = strippedDirectory
47
- . split ( '/' )
48
- . slice ( 0 , - 1 )
49
- . join ( '/' ) ;
50
- const path = `/${ cutStrippedDirectory } /${ title . replace ( / \/ / g, '-' ) } ` ;
48
+ const path = `/${ strippedDirectory } /${ title . replace ( / \/ / g, '-' ) } ` ;
51
49
52
50
const pageLocale =
53
51
SUPPORTED_LOCALES . find ( ( locale ) => path . startsWith ( `/${ locale } /` ) ) ||
@@ -56,7 +54,7 @@ const processMdxEntry = ({ children: [entry] }, kind = 'docs') => {
56
54
const slug =
57
55
pageLocale === DEFAULT_LOCALE
58
56
? getSlug ( path )
59
- : getTranslatedSlug ( cutStrippedDirectory , title , pageLocale , 'guides' ) ;
57
+ : getTranslatedSlug ( strippedDirectory , title , pageLocale , 'guides' ) ;
60
58
61
59
const pageSlug = customSlug || slug ;
62
60
const chunks = chunk ( mdxAstToPlainText ( mdxAST ) , 300 ) ;
@@ -67,7 +65,7 @@ const processMdxEntry = ({ children: [entry] }, kind = 'docs') => {
67
65
cache [ pointer ] = {
68
66
title,
69
67
objectID : `${ objectID } -${ pointer } ` ,
70
- slug : pageSlug ,
68
+ slug : pageSlug . startsWith ( '/' ) ? pageSlug : `/ ${ pageSlug } ` ,
71
69
content : chunks [ pointer ] ,
72
70
} ;
73
71
}
@@ -88,9 +86,10 @@ const flatten = (arr, kind = 'docs') => {
88
86
// main query
89
87
const docPagesQuery = `{
90
88
docPages: allFile(
91
- filter: { absolutePath : { regex: "/\/docs\//" }, ext:{in: [".md"]} }
89
+ filter: { relativeDirectory : { regex: "/\/docs\//" }, ext:{in: [".md"]} }
92
90
) {
93
91
nodes {
92
+ relativeDirectory
94
93
children {
95
94
... on Mdx {
96
95
objectID: id
@@ -100,7 +99,6 @@ const docPagesQuery = `{
100
99
slug
101
100
}
102
101
mdxAST
103
- fileAbsolutePath
104
102
}
105
103
}
106
104
}
@@ -110,9 +108,10 @@ const docPagesQuery = `{
110
108
// translated guides
111
109
const guidesPagesQuery = `{
112
110
guidesPages: allFile(
113
- filter: { absolutePath : { regex: "/\/translated-guides\//" }, ext:{in: [".md"]} }
111
+ filter: { relativeDirectory : { regex: "/\/translated-guides\//" }, ext:{in: [".md"]} }
114
112
) {
115
113
nodes {
114
+ relativeDirectory
116
115
children {
117
116
... on Mdx {
118
117
objectID: id
@@ -122,7 +121,6 @@ const guidesPagesQuery = `{
122
121
slug
123
122
}
124
123
mdxAST
125
- fileAbsolutePath
126
124
}
127
125
}
128
126
}
@@ -136,7 +134,7 @@ const settings = {
136
134
distinct : true ,
137
135
} ;
138
136
139
- const indexName = process . env . GATSBY_ALGOLIA_INDEX_NAME || 'dev_k6_docs ' ;
137
+ const indexName = process . env . GATSBY_ALGOLIA_INDEX_NAME || 'test-setup ' ;
140
138
141
139
const queries = [
142
140
{
0 commit comments