FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docs/script/graphql/utils/prerender-objects.js at main · vb2ae/docs · GitHub
vb2ae
/
docs
Public
forked from
github/docs
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
docs
/
script
/
graphql
/
utils
/
prerender-objects.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (26 loc) · 1.1 KB
Breadcrumbs
docs
/
script
/
graphql
/
utils
/
prerender-objects.js
Copy path
File metadata and controls
30 lines (26 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
import
fs
from
'fs/promises'
import
path
from
'path'
import
cheerio
from
'cheerio'
import
{
liquid
}
from
'../../../lib/render-content/index.js'
import
getMiniTocItems
from
'../../../lib/get-mini-toc-items.js'
import
rewriteLocalLinks
from
'../../../lib/rewrite-local-links.js'
const
includes
=
path
.
join
(
process
.
cwd
(
)
,
'includes'
)
const
objectIncludeFile
=
await
fs
.
readFile
(
path
.
join
(
includes
,
'graphql-object.html'
)
,
'utf8'
)
export
default
async
function
prerenderObjects
(
context
)
{
const
objectsArray
=
[
]
// render the graphql-object.html layout for every object
for
(
const
object
of
context
.
graphql
.
schemaForCurrentVersion
.
objects
)
{
context
.
item
=
object
const
objectHtml
=
await
liquid
.
parseAndRender
(
objectIncludeFile
,
context
)
const
$
=
cheerio
.
load
(
objectHtml
,
{
xmlMode
:
true
}
)
rewriteLocalLinks
(
$
,
context
.
currentVersion
,
context
.
currentLanguage
)
const
htmlWithVersionedLinks
=
$
.
html
(
)
objectsArray
.
push
(
htmlWithVersionedLinks
)
}
const
objectsHtml
=
objectsArray
.
join
(
'\n'
)
return
{
html
:
objectsHtml
,
miniToc
:
getMiniTocItems
(
objectsHtml
)
,
}
}
Back
|
FazBrowse Home
|
New Git URL