-
- {library.name}
+
+ {data.name}
- {library.github && (
+ {data.github && (
)}
- {library.npm && (
+ {data.npm && (
)}
- {library.gem && (
+ {data.gem && (
)}
- {library.lastRelease && (
+ {data.lastRelease && (
Last Release
- {library.formattedLastRelease}
+ {data.formattedLastRelease}
)}
- {library.stars && (
+ {data.stars && (
Stars
- {library.formattedStars}
+ {data.formattedStars}
)}
- {library.license && (
+ {data.license && (
License
- {library.license}
+ {data.license}
)}
- {library.howto ? (
+ {data.howto ? (
- {library.description}
+ {data.description}
) : (
@@ -135,9 +127,7 @@ export function buildLibraryContent(
}
}}
>
-
- {library.howto || library.description}
-
+
{data.howto || data.description}
{overflown && (
- {libraries.map(library => buildLibraryContent(library, pageContext))}
+ {data.map(library => (
+
+ ))}
)
}
-export function buildLibraryCategoryContent(
- libraryCategories: any[],
- libraryCategoryName: string,
- slug: string,
- pageContext: any
-) {
- if (libraryCategoryName in libraryCategories) {
- const libraries = libraryCategories[libraryCategoryName as any]
- return (
-
-
{libraryCategoryName}
- {buildLibraryList(libraries, pageContext)}
-
- )
- }
- return
-}
-
const categorySlugMap = [
["Server", toSlug("Server")],
["Client", toSlug("Client")],
["Tools", toSlug("Tools")],
]
-export function buildLanguagesContent(pageContext: any) {
- const elements = []
- for (const languageObj of pageContext.languageList) {
- const languageName = languageObj.name
- const libraryCategories = languageObj.categoryMap
- const filteredCategorySlugMap = categorySlugMap.filter(
- ([libraryCategoryName]) =>
- libraryCategories[libraryCategoryName as any]?.length
- )
- const languageSlug = toSlug(languageName)
- elements.push(
-
-
-
{languageName}
- {filteredCategorySlugMap.length > 1 && (
-
- {filteredCategorySlugMap.map(
- ([libraryCategoryName, categorySlug], i) => (
- <>
-
- {libraryCategoryName}
-
- {i < filteredCategorySlugMap.length - 1 && " / "}
- >
- )
- )}
-
- )}
-
-
- {filteredCategorySlugMap.map(([categoryName, categorySlug]) =>
- buildLibraryCategoryContent(
- libraryCategories,
- categoryName,
- `${languageSlug}-${categorySlug}`,
- pageContext
- )
- )}
-
-
- )
- }
- return
{elements}
-}
-
export default ({ pageContext }: PageProps<{}, PageContext>) => {
return (
@@ -275,8 +200,84 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => {
Language Support
- {buildLanguagesMenu(pageContext)}
- {buildLanguagesContent(pageContext)}
+
+ {pageContext.languageList
+ ?.map(language => language?.name!)
+ .filter(Boolean)
+ .map(languageName => {
+ const slug = toSlug(languageName)
+ return (
+
+ {languageName}
+
+ )
+ })}
+
+
+ {pageContext.languageList.map(lang => {
+ const languageName = lang.name
+ const libraryCategories = lang.categoryMap
+ const filteredCategorySlugMap = categorySlugMap.filter(
+ ([libraryCategoryName]) =>
+ libraryCategories[
+ libraryCategoryName as "Client" | "Server"
+ ]?.length
+ )
+ const languageSlug = toSlug(languageName)
+ return (
+
+
+
{languageName}
+ {filteredCategorySlugMap.length > 1 && (
+
+ {filteredCategorySlugMap.map(
+ ([libraryCategoryName, categorySlug], i) => (
+
+
+ {libraryCategoryName}
+
+ {i < filteredCategorySlugMap.length - 1 &&
+ " / "}
+
+ )
+ )}
+
+ )}
+
+
+ {filteredCategorySlugMap.map(
+ ([categoryName, categorySlug]) =>
+ categoryName in libraryCategories && (
+
+
+ {categoryName}
+
+
+
+ )
+ )}
+
+
+ )
+ })}
+
Tools
@@ -284,10 +285,7 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => {
#
- {buildLibraryList(
- pageContext.otherLibraries?.Tools ?? [],
- pageContext
- )}
+
Services
@@ -295,10 +293,7 @@ export default ({ pageContext }: PageProps<{}, PageContext>) => {
#
- {buildLibraryList(
- pageContext.otherLibraries?.Services ?? [],
- pageContext
- )}
+
diff --git a/src/utils/useFAQAccordion.ts b/src/utils/useFAQAccordion.ts
index 73452c0abb..8d2c3aeee9 100644
--- a/src/utils/useFAQAccordion.ts
+++ b/src/utils/useFAQAccordion.ts
@@ -24,7 +24,7 @@ export const useFAQAccordion = () => {
}
useEffect(() => {
- const hash = window.location.hash ? window.location.hash.split("#")[1] : ""
+ const hash = location.hash ? location.hash.split("#")[1] : ""
if (hash && buttonCreated) {
const anchor = document && document.getElementById(hash)
@@ -57,19 +57,17 @@ export const useFAQAccordion = () => {
const element =
e.target.localName === "button" ? e.target : e.target.parentNode
-
window.history.replaceState(
{},
"",
"#" + e.target.getElementsByTagName("a")[0].id
)
window.history.scrollRestoration = "manual"
+ e.target.classList.toggle("open")
if (e.target.localName === "button") {
- e.target.classList.toggle("open")
e.target.getElementsByTagName("h3")[0].classList.toggle("open")
} else {
- e.target.classList.toggle("open")
e.target.parentNode.classList.toggle("open")
}
@@ -79,5 +77,5 @@ export const useFAQAccordion = () => {
document.addEventListener("click", toggleClasses)
return () => document.removeEventListener("click", toggleClasses)
- }, [typeof window !== 'undefined' ? window.location.hash : null])
-}
\ No newline at end of file
+ }, [typeof window !== 'undefined' ? location.hash : null])
+}