ui(resources): tweak resource list for single page

This commit is contained in:
Jean-Philippe Sirois
2020-05-26 03:49:17 -04:00
parent 826294fd84
commit 4d7dd1bb5e
9 changed files with 45 additions and 40 deletions
+16 -11
View File
@@ -26,7 +26,7 @@ const ALL_RESOURCES = graphql`
} }
` `
function plantTree(item: IFileOrFolder, index?: number) { function plantTree(item: IFileOrFolder, single?: boolean) {
if (item.type === "file") { if (item.type === "file") {
// remove the first elements, treat as hardcoded // remove the first elements, treat as hardcoded
const [, , , ...cleanedUpPath] = item.path.split("/") const [, , , ...cleanedUpPath] = item.path.split("/")
@@ -42,17 +42,21 @@ function plantTree(item: IFileOrFolder, index?: number) {
) )
} }
return <Language key={item.title} item={item} index={index!} /> return <Language key={item.title} item={item} single={Boolean(single)} />
} }
const Language = memo(({ item }: { item: IFolder; index: number }) => { const Language = memo(
return ( ({ item, single }: { item: IFolder; single: boolean }) => {
<SC.TreeWrapper> return (
<SC.LanguageLabel>{humanize(item.title)}</SC.LanguageLabel> <SC.TreeWrapper>
<SC.Children>{item.children.map((node) => plantTree(node))}</SC.Children> {!single && <SC.LanguageLabel>{humanize(item.title)}</SC.LanguageLabel>}
</SC.TreeWrapper> <SC.Children>
) {item.children.map((node) => plantTree(node))}
}) </SC.Children>
</SC.TreeWrapper>
)
}
)
interface IResourcesList extends HTMLAttributes<HTMLDivElement> { interface IResourcesList extends HTMLAttributes<HTMLDivElement> {
relativeDirectory?: string relativeDirectory?: string
@@ -78,10 +82,11 @@ export const ResourcesList: FC<IResourcesList> = (props) => {
const tree = useBuildTree(filteredResources) const tree = useBuildTree(filteredResources)
const sortedTree = sort((a, b) => a.title.localeCompare(b.title), tree) const sortedTree = sort((a, b) => a.title.localeCompare(b.title), tree)
const isSingle = Boolean(props.relativeDirectory)
return ( return (
<SC.ResourcesListWrapper {...props}> <SC.ResourcesListWrapper {...props}>
{sortedTree.map((node, index) => plantTree(node, index))} {sortedTree.map((node) => plantTree(node, isSingle))}
</SC.ResourcesListWrapper> </SC.ResourcesListWrapper>
) )
} }
@@ -5,6 +5,6 @@ created_at: 2020/04/20
title: Bot Development title: Bot Development
--- ---
## About ###### About
In TPH, we employ the use of various Discord bots to help with a myriad of tasks such as moderation and managing embeds. In TPH, we employ the use of various Discord bots to help with a myriad of tasks such as moderation and managing embeds.
+5 -5
View File
@@ -5,28 +5,28 @@ created_at: 2019/12/15
title: C++ title: C++
--- ---
## Beginner ###### Beginner
- [Get started](https://isocpp.org/get-started) - [Get started](https://isocpp.org/get-started)
- [Learn C++](http://www.learncpp.com/) - [Learn C++](http://www.learncpp.com/)
- [C++ tutorial](http://www.cplusplus.com/doc/tutorial/) - [C++ tutorial](http://www.cplusplus.com/doc/tutorial/)
## Documentation ###### Documentation
- [C++ reference](http://en.cppreference.com/w/) - [C++ reference](http://en.cppreference.com/w/)
- [https://isocpp.org/std/the-standard](https://isocpp.org/std/the-standard) - [https://isocpp.org/std/the-standard](https://isocpp.org/std/the-standard)
- [http://eel.is/c++draft/](http://eel.is/c++draft/) - [http://eel.is/c++draft/](http://eel.is/c++draft/)
## Books ###### Books
- [The definitive C books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list/388282#388282) - [The definitive C books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list/388282#388282)
## Video ###### Video
- [TPH Picks](https://goo.gl/emLpwP) - [TPH Picks](https://goo.gl/emLpwP)
- [Cherno](https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb) - [Cherno](https://www.youtube.com/playlist?list=PLlrATfBNZ98dudnM48yfGUldqGD0S4FFb)
## Other ###### Other
- [Super FAQ](https://isocpp.org/wiki/faq) - [Super FAQ](https://isocpp.org/wiki/faq)
- [Compilers](http://www.stroustrup.com/compilers.html) - [Compilers](http://www.stroustrup.com/compilers.html)
+3 -3
View File
@@ -5,17 +5,17 @@ created_at: 2020/04/23
title: Introduction to Cryptography title: Introduction to Cryptography
--- ---
## Popular Science Books ###### Popular Science Books
- [The Codebreakers](https://www.amazon.com/Codebreakers-Comprehensive-History-Communication-Internet/dp/0684831309) - [The Codebreakers](https://www.amazon.com/Codebreakers-Comprehensive-History-Communication-Internet/dp/0684831309)
- [Seizing the Enigma: The Race to Break the German U-Boats Codes](https://www.amazon.com/Seizing-Enigma-German-U-Boats-1939-1943/dp/0395427398) - [Seizing the Enigma: The Race to Break the German U-Boats Codes](https://www.amazon.com/Seizing-Enigma-German-U-Boats-1939-1943/dp/0395427398)
## Books ###### Books
- [Handbook of Applied Cryptography - Free](http://cacr.uwaterloo.ca/hac/) - [Handbook of Applied Cryptography - Free](http://cacr.uwaterloo.ca/hac/)
- [Serious Cryptography](https://nostarch.com/seriouscrypto) - [Serious Cryptography](https://nostarch.com/seriouscrypto)
- [Cryptograpy Engineering](https://www.schneier.com/books/cryptography_engineering/) - [Cryptograpy Engineering](https://www.schneier.com/books/cryptography_engineering/)
## Video ###### Video
- [Coursera](https://www.coursera.org/learn/crypto) - [Coursera](https://www.coursera.org/learn/crypto)
+6 -6
View File
@@ -5,30 +5,30 @@ created_at: 2019/12/15
title: Java title: Java
--- ---
## Documentation ###### Documentation
- [Java docs](https://docs.oracle.com/en/java/javase/11/) - [Java docs](https://docs.oracle.com/en/java/javase/11/)
## Free Books ###### Free Books
- [https://goo.gl/WZTC9C](https://goo.gl/WZTC9C) - [https://goo.gl/WZTC9C](https://goo.gl/WZTC9C)
## Video ###### Video
- [EJ Media](https://goo.gl/tC1KwC) - [EJ Media](https://goo.gl/tC1KwC)
- [Derek Banas](https://goo.gl/9eVFkE) - [Derek Banas](https://goo.gl/9eVFkE)
- [Free With Registration | Cave of Programming](https://goo.gl/NXTo4H) - [Free With Registration | Cave of Programming](https://goo.gl/NXTo4H)
## Guides ###### Guides
- [Learn By Examples | Beginnersbook.com](https://goo.gl/3nDWeQ) - [Learn By Examples | Beginnersbook.com](https://goo.gl/3nDWeQ)
## Useful Repositories ###### Useful Repositories
- [Frameworks](https://goo.gl/EoLvrH) - [Frameworks](https://goo.gl/EoLvrH)
- [Design patterns](https://goo.gl/wT7SfQ) - [Design patterns](https://goo.gl/wT7SfQ)
## Other ###### Other
- [History of Java](https://en.wikipedia.org/wiki/Java_version_history) - [History of Java](https://en.wikipedia.org/wiki/Java_version_history)
- [Wikibooks](https://en.wikibooks.org/wiki/Java_Programming/History) - [Wikibooks](https://en.wikibooks.org/wiki/Java_Programming/History)
+4 -4
View File
@@ -5,7 +5,7 @@ created_at: 2019/12/15
title: Javascript title: Javascript
--- ---
## Documentation ###### Documentation
- [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript) - [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
- [jQuery](https://contribute.jquery.org/documentation/) - [jQuery](https://contribute.jquery.org/documentation/)
@@ -13,7 +13,7 @@ title: Javascript
- [Typescript](https://www.typescriptlang.org/docs/home.html) - [Typescript](https://www.typescriptlang.org/docs/home.html)
- [Discord.js](https://discord.js.org/#/docs/main/stable/general/welcome) - [Discord.js](https://discord.js.org/#/docs/main/stable/general/welcome)
## Tutorials ###### Tutorials
- [Eloquent](https://eloquentjavascript.net/) - [Eloquent](https://eloquentjavascript.net/)
- [You Don't Know JS](https://github.com/getify/You-Dont-Know-JS) - [You Don't Know JS](https://github.com/getify/You-Dont-Know-JS)
@@ -21,12 +21,12 @@ title: Javascript
- [Modern JS](https://javascript.info/) - [Modern JS](https://javascript.info/)
- [Evie's Accelerated JS Tutorial](https://evie.gitbook.io/js/) - [Evie's Accelerated JS Tutorial](https://evie.gitbook.io/js/)
## Discord.js ###### Discord.js
- [An Idiot's Guide](https://anidiots.guide/) - [An Idiot's Guide](https://anidiots.guide/)
- [Discord.js Guide](https://discordjs.guide/) - [Discord.js Guide](https://discordjs.guide/)
## Other ###### Other
- [You might not need jQuery](https://youmightnotneedjquery.com/) - [You might not need jQuery](https://youmightnotneedjquery.com/)
- [You might not need jQuery 2](https://github.com/you-dont-need-x/you-dont-need-jquery) - [You might not need jQuery 2](https://github.com/you-dont-need-x/you-dont-need-jquery)
+3 -3
View File
@@ -5,17 +5,17 @@ created_at: 2019/12/15
title: Kotlin title: Kotlin
--- ---
## About ###### About
One line language description: Kotlin is a general-purpose programming language that can run on a JVM or be transpiled to Javascript code. It can use functional, procedural, and OO paradigms, and can interleave them. Primarily developed by JetBrains. One line language description: Kotlin is a general-purpose programming language that can run on a JVM or be transpiled to Javascript code. It can use functional, procedural, and OO paradigms, and can interleave them. Primarily developed by JetBrains.
## Links ###### Links
- [Official Website](https://www.kotlinlang.org/) - [Official Website](https://www.kotlinlang.org/)
- [Official Docs](https://kotlinlang.org/docs/reference/) - [Official Docs](https://kotlinlang.org/docs/reference/)
- [Tutorials](https://kotlinlang.org/docs/tutorials/) - [Tutorials](https://kotlinlang.org/docs/tutorials/)
- [Mooc (not free)](https://www.udemy.com/kotlin-course/) - [Mooc (not free)](https://www.udemy.com/kotlin-course/)
## Recommended reading ###### Recommended reading
- Kotlin in Action by Dmitry Jemerov and Svetlana Isakova - Kotlin in Action by Dmitry Jemerov and Svetlana Isakova
+2 -2
View File
@@ -5,7 +5,7 @@ created_at: 2019/12/15
title: PHP title: PHP
--- ---
## Useful links and documentation ###### Useful links and documentation
- [Official documentation](https://secure.php.net/manual/en/) - [Official documentation](https://secure.php.net/manual/en/)
- [Laracasts PHP tutorials](http://laracasts.com/) - [Laracasts PHP tutorials](http://laracasts.com/)
@@ -13,7 +13,7 @@ title: PHP
- [PHP Standard Recommendations](https://www.php-fig.org/psr/) - [PHP Standard Recommendations](https://www.php-fig.org/psr/)
- [OWASP Cheatsheet](https://cheatsheetseries.owasp.org/) - [OWASP Cheatsheet](https://cheatsheetseries.owasp.org/)
## Useful Libraries ###### Useful Libraries
- [Composer package manager](https://getcomposer.org/) - [Composer package manager](https://getcomposer.org/)
- [phpDocumentor](https://www.phpdoc.org/) - [phpDocumentor](https://www.phpdoc.org/)
+5 -5
View File
@@ -5,29 +5,29 @@ created_at: 2019/12/15
title: Python title: Python
--- ---
## Beginner ###### Beginner
- [Official tutorial](https://docs.python.org/3/tutorial/) - [Official tutorial](https://docs.python.org/3/tutorial/)
- [Automate the boring stuff](https://automatetheboringstuff.com/) - [Automate the boring stuff](https://automatetheboringstuff.com/)
- [Beginner's guide](https://wiki.python.org/moin/BeginnersGuide/NonProgrammers) - [Beginner's guide](https://wiki.python.org/moin/BeginnersGuide/NonProgrammers)
## Documentation ###### Documentation
- [https://docs.python.org/3/](https://docs.python.org/3/) - [https://docs.python.org/3/](https://docs.python.org/3/)
- [https://www.python.org/dev/](https://www.python.org/dev/) - [https://www.python.org/dev/](https://www.python.org/dev/)
## Video ###### Video
- [Socratica](https://goo.gl/8xKVKE) - [Socratica](https://goo.gl/8xKVKE)
- [thenewboston](https://goo.gl/9EqF2J) - [thenewboston](https://goo.gl/9EqF2J)
## Books ###### Books
- [Free](https://goo.gl/Lxhp7i) - [Free](https://goo.gl/Lxhp7i)
- [Python Crash Course - paid](https://goo.gl/XQ7Nx6) - [Python Crash Course - paid](https://goo.gl/XQ7Nx6)
- [Advanced - paid](https://wiki.python.org/moin/AdvancedBooks) - [Advanced - paid](https://wiki.python.org/moin/AdvancedBooks)
## Other ###### Other
- [TalkPython | Podcast](https://goo.gl/xwieUA) - [TalkPython | Podcast](https://goo.gl/xwieUA)
- [Exercises](http://www.practicepython.org/) - [Exercises](http://www.practicepython.org/)