GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — docs/script/graphql/utils/process-previews.js at main · runningcode/docs

Expand file tree

/

process-previews.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
35 lines (27 loc) · 1.21 KB
/

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 = /(Input|Payload)$/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
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.