MCPcopy Create free account
hub / github.com/github/docs / showPlatformSpecificContent

Function showPlatformSpecificContent

components/article/PlatformPicker.tsx:19–37  ·  view source on GitHub ↗
(platform: string)

Source from the content-addressed store, hash-verified

17// find all platform-specific *block* elements and hide or show as appropriate
18// example: {% mac %} block content {% endmac %}
19function showPlatformSpecificContent(platform: string) {
20 const markdowns = Array.from(document.querySelectorAll<HTMLElement>('.extended-markdown'))
21 markdowns
22 .filter((el) => platforms.some((platform) => el.classList.contains(platform.value)))
23 .forEach((el) => {
24 el.style.display = el.classList.contains(platform) ? '' : 'none'
25 })
26
27 // find all platform-specific *inline* elements and hide or show as appropriate
28 // example: <span class="platform-mac">inline content</span>
29 const platformEls = Array.from(
30 document.querySelectorAll<HTMLElement>(
31 platforms.map((platform) => `.platform-${platform.value}`).join(', ')
32 )
33 )
34 platformEls.forEach((el) => {
35 el.style.display = el.classList.contains(`platform-${platform}`) ? '' : 'none'
36 })
37}
38
39export const PlatformPicker = () => {
40 const { defaultPlatform, detectedPlatforms } = useArticleContext()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected