mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-06 16:06:12 +02:00
feat(resources): tweak external resources & visuals
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import React, { FC, Fragment } from "react"
|
import React, { FC } from "react"
|
||||||
|
|
||||||
import { ITocItem } from "../../types"
|
import { IExternalResource, ITocItem } from "../../types"
|
||||||
import { humanize } from "../../utils"
|
|
||||||
import { Container } from "../Container"
|
import { Container } from "../Container"
|
||||||
|
import { PageSidebarLink } from "../PageSidebarLink"
|
||||||
import { Toc } from "../Toc"
|
import { Toc } from "../Toc"
|
||||||
import * as SC from "./styles"
|
import * as SC from "./styles"
|
||||||
|
|
||||||
@@ -10,37 +10,7 @@ interface IPageContentProps {
|
|||||||
content: JSX.Element
|
content: JSX.Element
|
||||||
toc?: ITocItem[]
|
toc?: ITocItem[]
|
||||||
recommendedReading?: string[]
|
recommendedReading?: string[]
|
||||||
externalResources?: string[]
|
externalResources?: IExternalResource[]
|
||||||
}
|
|
||||||
|
|
||||||
function ExtraLink({
|
|
||||||
item,
|
|
||||||
external = false,
|
|
||||||
}: {
|
|
||||||
item: string
|
|
||||||
external?: boolean
|
|
||||||
}) {
|
|
||||||
const Inner = ({ text }: { text: string }) => (
|
|
||||||
<Fragment>
|
|
||||||
<SC.ExtraLinkText>{text}</SC.ExtraLinkText>
|
|
||||||
</Fragment>
|
|
||||||
)
|
|
||||||
|
|
||||||
if (external) {
|
|
||||||
return (
|
|
||||||
<SC.ExtraLinkExternal href={item} target="_blank">
|
|
||||||
<Inner text={item} />
|
|
||||||
</SC.ExtraLinkExternal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const [internalText] = item.split("/").slice(-1)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SC.ExtraLinkInternal to={`/resources/${item}.md`}>
|
|
||||||
<Inner text={humanize(internalText)} />
|
|
||||||
</SC.ExtraLinkInternal>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PageContent: FC<IPageContentProps> = ({
|
export const PageContent: FC<IPageContentProps> = ({
|
||||||
@@ -67,7 +37,7 @@ export const PageContent: FC<IPageContentProps> = ({
|
|||||||
<SC.RecommendedReading>
|
<SC.RecommendedReading>
|
||||||
<SC.SidebarHeader>Recommended reading</SC.SidebarHeader>
|
<SC.SidebarHeader>Recommended reading</SC.SidebarHeader>
|
||||||
{recommendedReading.map(item => {
|
{recommendedReading.map(item => {
|
||||||
return <ExtraLink key={item} item={item} />
|
return <PageSidebarLink key={item} href={item} type="internal" />
|
||||||
})}
|
})}
|
||||||
</SC.RecommendedReading>
|
</SC.RecommendedReading>
|
||||||
)}
|
)}
|
||||||
@@ -76,7 +46,7 @@ export const PageContent: FC<IPageContentProps> = ({
|
|||||||
<SC.ExternalResources>
|
<SC.ExternalResources>
|
||||||
<SC.SidebarHeader>External Resources</SC.SidebarHeader>
|
<SC.SidebarHeader>External Resources</SC.SidebarHeader>
|
||||||
{externalResources.map(item => {
|
{externalResources.map(item => {
|
||||||
return <ExtraLink key={item} item={item} external />
|
return <PageSidebarLink key={item.href} href={item.href} text={item.text} type="external" />
|
||||||
})}
|
})}
|
||||||
</SC.ExternalResources>
|
</SC.ExternalResources>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import styled, { css } from "styled-components"
|
import styled from "styled-components"
|
||||||
import { Link } from "gatsby"
|
|
||||||
import fontFamily from "../../design/typography"
|
import fontFamily from "../../design/typography"
|
||||||
import { darken } from "polished"
|
import { darken } from "polished"
|
||||||
|
|
||||||
@@ -53,6 +52,8 @@ export const SidebarHeader = styled.div`
|
|||||||
|
|
||||||
const ExtraLinks = styled.div`
|
const ExtraLinks = styled.div`
|
||||||
margin-top: 32px;
|
margin-top: 32px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
&:first-child {
|
&:first-child {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
@@ -62,53 +63,3 @@ const ExtraLinks = styled.div`
|
|||||||
export const RecommendedReading = styled(ExtraLinks)``
|
export const RecommendedReading = styled(ExtraLinks)``
|
||||||
|
|
||||||
export const ExternalResources = styled(ExtraLinks)``
|
export const ExternalResources = styled(ExtraLinks)``
|
||||||
|
|
||||||
const extraLink = css`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
color: ${props => (props.theme.name === "dark" ? "#f9f9f9" : "#172129")};
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: none;
|
|
||||||
|
|
||||||
& + & {
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: linear-gradient(92.97deg, #feaf6d 0%, #ff70a5 100%);
|
|
||||||
background-clip: text;
|
|
||||||
-webkit-background-clip: text;
|
|
||||||
-webkit-text-fill-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg {
|
|
||||||
width: 14px;
|
|
||||||
flex: 0 0 14px;
|
|
||||||
transform: rotate(90deg);
|
|
||||||
margin-left: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg path {
|
|
||||||
fill: ${props => (props.theme.name === "dark" ? "#f9f9f9" : "#172129")};
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
export const ExtraLinkInternal = styled(Link)`
|
|
||||||
${extraLink};
|
|
||||||
`
|
|
||||||
|
|
||||||
export const ExtraLinkExternal = styled.a`
|
|
||||||
${extraLink};
|
|
||||||
`
|
|
||||||
|
|
||||||
export const ExtraLinkText = styled.div`
|
|
||||||
word-break: break-word;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: 2px;
|
|
||||||
background: linear-gradient(92.97deg, #feaf6d 0%, #ff70a5 100%);
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
import React, { FC } from "react"
|
||||||
|
|
||||||
|
import { humanize } from "../../utils"
|
||||||
|
import * as SC from "./styles"
|
||||||
|
|
||||||
|
interface IPageSidebarLinkProps {
|
||||||
|
href: string
|
||||||
|
text?: string
|
||||||
|
external?: boolean
|
||||||
|
type?: "internal" | "external" | "anchor"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PageSidebarLink: FC<IPageSidebarLinkProps> = ({
|
||||||
|
href,
|
||||||
|
text,
|
||||||
|
type = "internal",
|
||||||
|
}) => {
|
||||||
|
if (type === "anchor") {
|
||||||
|
return <SC.Anchor to={href}>{text}</SC.Anchor>
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === "external") {
|
||||||
|
return (
|
||||||
|
<SC.External href={href} target="_blank">
|
||||||
|
{text}
|
||||||
|
</SC.External>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const [internalText] = href.split("/").slice(-1)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SC.Internal to={`/resources/${href}.md`}>
|
||||||
|
{text || humanize(internalText)}
|
||||||
|
</SC.Internal>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { AnchorLink } from "gatsby-plugin-anchor-links"
|
||||||
|
import styled, { css } from "styled-components"
|
||||||
|
import { Link } from "gatsby"
|
||||||
|
|
||||||
|
const extraLink = css`
|
||||||
|
color: ${props => props.theme.main.foreground};
|
||||||
|
text-decoration: none;
|
||||||
|
word-break: break-word;
|
||||||
|
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
export const Anchor = styled(AnchorLink)`
|
||||||
|
${extraLink};
|
||||||
|
`
|
||||||
|
|
||||||
|
export const Internal = styled(Link)`
|
||||||
|
${extraLink};
|
||||||
|
`
|
||||||
|
|
||||||
|
export const External = styled.a`
|
||||||
|
${extraLink};
|
||||||
|
`
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { FC } from "react"
|
import React, { FC } from "react"
|
||||||
|
import { PageSidebarLink } from "../PageSidebarLink"
|
||||||
import { ITocItem } from "../../types"
|
import { ITocItem } from "../../types"
|
||||||
import * as SC from "./styles"
|
import * as SC from "./styles"
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ export const Toc: FC<ITocProps> = ({ header, items }) => {
|
|||||||
return (
|
return (
|
||||||
<SC.TocItem key={item.link} className={`depth-${item.depth}`}>
|
<SC.TocItem key={item.link} className={`depth-${item.depth}`}>
|
||||||
{prefix}
|
{prefix}
|
||||||
<SC.TocLink to={`${pathname}${item.link}`}>{title}</SC.TocLink>
|
<PageSidebarLink href={`${pathname}${item.link}`} text={title} type="anchor" />
|
||||||
</SC.TocItem>
|
</SC.TocItem>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { AnchorLink } from "gatsby-plugin-anchor-links"
|
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
|
|
||||||
export const TocWrapper = styled.div`
|
export const TocWrapper = styled.div`
|
||||||
@@ -18,13 +17,3 @@ export const TocItem = styled.div`
|
|||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const TocLink = styled(AnchorLink)`
|
|
||||||
color: ${props => props.theme.main.foreground};
|
|
||||||
text-decoration: none;
|
|
||||||
|
|
||||||
&:hover,
|
|
||||||
&:focus {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ authors:
|
|||||||
created_at: "2020/04/22"
|
created_at: "2020/04/22"
|
||||||
title: "Deploying discord bots written in Kotlin to Heroku"
|
title: "Deploying discord bots written in Kotlin to Heroku"
|
||||||
external_resources:
|
external_resources:
|
||||||
- "https://devcenter.heroku.com/articles/getting-started-with-java#introduction"
|
- text: Getting Started on Heroku with Java
|
||||||
- "https://github.com/heroku/java-sample"
|
href: "https://devcenter.heroku.com/articles/getting-started-with-java#introduction"
|
||||||
|
- text: Java Sample (on GitHub)
|
||||||
|
href: "https://github.com/heroku/java-sample"
|
||||||
---
|
---
|
||||||
|
|
||||||
Over my time in TPH, I have noticed that a common woe aspiring bot developers have is that they are unable to host
|
Over my time in TPH, I have noticed that a common woe aspiring bot developers have is that they are unable to host
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ authors:
|
|||||||
title: "An introduction to Streams"
|
title: "An introduction to Streams"
|
||||||
created_at: 2019/12/15
|
created_at: 2019/12/15
|
||||||
external_resources:
|
external_resources:
|
||||||
- https://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
|
- text: Java8 Stream Tutorial
|
||||||
|
href: https://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
|
||||||
---
|
---
|
||||||
|
|
||||||
## An introduction to Streams
|
## An introduction to Streams
|
||||||
|
|||||||
@@ -4,9 +4,12 @@ authors:
|
|||||||
title: "Spread operator"
|
title: "Spread operator"
|
||||||
created_at: 2019/08/10
|
created_at: 2019/08/10
|
||||||
external_resources:
|
external_resources:
|
||||||
- "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax"
|
- text: MDN Spread Operator
|
||||||
- "https://javascript.info/rest-parameters-spread-operator"
|
href: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax"
|
||||||
- "https://www.freecodecamp.org/news/spread-operator-and-rest-parameter-in-javascript-es6-4416a9f47e5e/"
|
- text: Javascript.info Spread/rest
|
||||||
|
href: "https://javascript.info/rest-parameters-spread-operator"
|
||||||
|
- text: Freecodecamp.org Spread/rest
|
||||||
|
href: "https://www.freecodecamp.org/news/spread-operator-and-rest-parameter-in-javascript-es6-4416a9f47e5e/"
|
||||||
---
|
---
|
||||||
|
|
||||||
# An overview of the spread operator
|
# An overview of the spread operator
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ authors:
|
|||||||
created_at: "2019/08/23"
|
created_at: "2019/08/23"
|
||||||
title: "Creating C bindings with Kotlin/Native"
|
title: "Creating C bindings with Kotlin/Native"
|
||||||
external_resources:
|
external_resources:
|
||||||
- "https://kotlinlang.org/docs/reference/native/c_interop.html"
|
- text: KotlinLang.org C-interop reference
|
||||||
- "https://github.com/JetBrains/kotlin-native/releases"
|
href: "https://kotlinlang.org/docs/reference/native/c_interop.html"
|
||||||
|
- text: Kotlin releases on GitHub
|
||||||
|
href: "https://github.com/JetBrains/kotlin-native/releases"
|
||||||
---
|
---
|
||||||
|
|
||||||
## Interoperability with C
|
## Interoperability with C
|
||||||
|
|||||||
@@ -4,14 +4,22 @@ authors:
|
|||||||
created_at: "2019/07/27"
|
created_at: "2019/07/27"
|
||||||
title: Singletons
|
title: Singletons
|
||||||
external_resources:
|
external_resources:
|
||||||
- https://en.wikipedia.org/wiki/Singleton_pattern
|
- text: Wikipedia.org Singleton Pattern
|
||||||
- https://phpenthusiast.com/blog/the-singleton-design-pattern-in-php
|
href: https://en.wikipedia.org/wiki/Singleton_pattern
|
||||||
- https://phptherightway.com/pages/Design-Patterns.html#singleton
|
- text: phpenthusiast.com Singleton Pattern
|
||||||
- https://www.php.net/manual/en/language.oop5.static.php
|
href: https://phpenthusiast.com/blog/the-singleton-design-pattern-in-php
|
||||||
- https://www.php.net/manual/en/language.oop5.late-static-bindings.php
|
- text: phptherightway.com Singleton Pattern
|
||||||
- https://en.wikipedia.org/wiki/Static_(keyword)
|
href: https://phptherightway.com/pages/Design-Patterns.html#singleton
|
||||||
- https://en.wikipedia.org/wiki/Null_coalescing_operator
|
- text: php.net Static Keyword
|
||||||
- https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op
|
href: https://www.php.net/manual/en/language.oop5.static.php
|
||||||
|
- text: php.net Late Static Bindings
|
||||||
|
href: https://www.php.net/manual/en/language.oop5.late-static-bindings.php
|
||||||
|
- text: Wikipedia.org Static Keyword
|
||||||
|
href: https://en.wikipedia.org/wiki/Static_(keyword)
|
||||||
|
- text: Wikipedia.org Null Coalescing Operator
|
||||||
|
href: https://en.wikipedia.org/wiki/Null_coalescing_operator
|
||||||
|
- text: php.net Null coalescing operator
|
||||||
|
href: https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op
|
||||||
---
|
---
|
||||||
|
|
||||||
A singleton is a class which is only instantiated once during runtime. This is done by keeping a static property containing its instance on the singleton class.
|
A singleton is a class which is only instantiated once during runtime. This is done by keeping a static property containing its instance on the singleton class.
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ authors:
|
|||||||
created_at: "2019/08/07"
|
created_at: "2019/08/07"
|
||||||
title: Prepared Statements
|
title: Prepared Statements
|
||||||
external_resources:
|
external_resources:
|
||||||
- https://www.php.net/manual/en/class.pdostatement.php
|
- text: php.net The PDOStatement class
|
||||||
- https://phptherightway.com/#pdo_extension
|
href: https://www.php.net/manual/en/class.pdostatement.php
|
||||||
|
- text: phptherightway.com PDO Extension
|
||||||
|
href: https://phptherightway.com/#pdo_extension
|
||||||
---
|
---
|
||||||
|
|
||||||
The PDO driver supports prepared statements. A prepared statement is a template statement with placeholders which can be executed with real values. Prepared Statements are also essential for avoiding SQL-injection attacks.
|
The PDO driver supports prepared statements. A prepared statement is a template statement with placeholders which can be executed with real values. Prepared Statements are also essential for avoiding SQL-injection attacks.
|
||||||
|
|||||||
@@ -67,7 +67,10 @@ export const query = graphql`
|
|||||||
created_at
|
created_at
|
||||||
title
|
title
|
||||||
recommended_reading
|
recommended_reading
|
||||||
external_resources
|
external_resources {
|
||||||
|
text
|
||||||
|
href
|
||||||
|
}
|
||||||
}
|
}
|
||||||
timeToRead
|
timeToRead
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,10 @@ export const query = graphql`
|
|||||||
created_at
|
created_at
|
||||||
title
|
title
|
||||||
recommended_reading
|
recommended_reading
|
||||||
external_resources
|
external_resources {
|
||||||
|
text
|
||||||
|
href
|
||||||
|
}
|
||||||
}
|
}
|
||||||
timeToRead
|
timeToRead
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+5
@@ -56,6 +56,11 @@ export interface IAllArchivesQuery extends IAllFilesQuery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IExternalResource {
|
||||||
|
text: string
|
||||||
|
href: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface ITocItem {
|
export interface ITocItem {
|
||||||
depth: number
|
depth: number
|
||||||
link: string
|
link: string
|
||||||
|
|||||||
Reference in New Issue
Block a user