FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
docs/script/graphql/utils/process-previews.js at main · uny/docs · GitHub
uny
/
docs
Public
forked from
github/docs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
/
process-previews.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (27 loc) · 1.21 KB
Breadcrumbs
docs
/
script
/
graphql
/
utils
/
process-previews.js
Copy path
File metadata and controls
35 lines (27 loc) · 1.21 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
31
32
33
34
35
#!/usr/bin/env node
import
{
sentenceCase
}
from
'change-case'
import
GithubSlugger
from
'github-slugger'
const
slugger
=
new
GithubSlugger
(
)
const
inputOrPayload
=
/
(
I
n
p
u
t
|
P
a
y
l
o
a
d
)
$
/
m
export
default
function
processPreviews
(
previews
)
{
// clean up raw yml data
previews
.
forEach
(
(
preview
)
=>
{
// remove any extra info that follows a hyphen
preview
.
title
=
sentenceCase
(
preview
.
title
.
replace
(
/
-
.
+
/
,
''
)
)
.
replace
(
'it hub'
,
'itHub'
)
// fix overcorrected `git hub` from sentenceCasing
// Add `preview` to the end of titles if needed
preview
.
title
=
preview
.
title
.
endsWith
(
'preview'
)
?
preview
.
title
:
`
${
preview
.
title
}
preview`
// filter out schema members that end in `Input` or `Payload`
preview
.
toggled_on
=
preview
.
toggled_on
.
filter
(
(
schemaMember
)
=>
!
inputOrPayload
.
test
(
schemaMember
)
)
// remove unnecessary leading colon
preview
.
toggled_by
=
preview
.
toggled_by
.
replace
(
':'
,
''
)
// add convenience properties
preview
.
accept_header
=
`application/vnd.github.
${
preview
.
toggled_by
}
+json`
delete
preview
.
announcement
delete
preview
.
updates
slugger
.
reset
(
)
preview
.
href
=
`/graphql/overview/schema-previews#
${
slugger
.
slug
(
preview
.
title
)
}
`
}
)
return
previews
}
Back
|
FazBrowse Home
|
New Git URL