Merge pull request #436 from the-programmers-hangout/techspotlight-rename

rename archive to spotlights
This commit is contained in:
itsHobbes
2021-10-24 20:17:08 +01:00
committed by GitHub
35 changed files with 60 additions and 60 deletions
+2 -2
View File
@@ -68,8 +68,8 @@ module.exports = {
{ {
resolve: `gatsby-source-filesystem`, resolve: `gatsby-source-filesystem`,
options: { options: {
name: `what-is-archive`, name: `spotlights`,
path: `${__dirname}/src/content/archives`, path: `${__dirname}/src/content/spotlights`,
}, },
}, },
`gatsby-transformer-sharp`, `gatsby-transformer-sharp`,
+14 -14
View File
@@ -7,7 +7,7 @@ const fs = require("fs")
const requiredArticleFrontmatter = ["authors", "date"] const requiredArticleFrontmatter = ["authors", "date"]
const LAYOUT_RESOURCES = "resources" const LAYOUT_RESOURCES = "resources"
const LAYOUT_ARCHIVES = "archives" const LAYOUT_SPOTLIGHTS = "spotlights"
const LAYOUT_REGULAR = "regular" const LAYOUT_REGULAR = "regular"
const LAYOUT_HOME = "home" const LAYOUT_HOME = "home"
@@ -20,8 +20,8 @@ function resolveLayout(path) {
return LAYOUT_RESOURCES return LAYOUT_RESOURCES
} }
if (path.match(/archives/)) { if (path.match(/spotlights/)) {
return LAYOUT_ARCHIVES return LAYOUT_SPOTLIGHTS
} }
return LAYOUT_REGULAR return LAYOUT_REGULAR
@@ -128,12 +128,12 @@ const createResources = async ({ createPage, graphql }) => {
} }
} }
const createArchives = async ({ createPage, graphql }) => { const createSpotlights = async ({ createPage, graphql }) => {
const archive = path.resolve(`src/templates/archive.tsx`) const spotlights = path.resolve(`src/templates/spotlight.tsx`)
const result = await graphql(` const result = await graphql(`
query FetchArchives { query FetchSpotlights {
allFile(filter: { sourceInstanceName: { eq: "what-is-archive" } }) { allFile(filter: { sourceInstanceName: { eq: "spotlights" } }) {
edges { edges {
node { node {
relativePath relativePath
@@ -150,11 +150,11 @@ const createArchives = async ({ createPage, graphql }) => {
return result.data.allFile.edges.forEach(({ node }) => { return result.data.allFile.edges.forEach(({ node }) => {
createPage({ createPage({
path: path.posix.join("archives", node.relativePath), path: path.posix.join("spotlights", node.relativePath),
component: archive, component: spotlights,
context: { context: {
file: node.relativePath, file: node.relativePath,
layout: LAYOUT_ARCHIVES, layout: LAYOUT_SPOTLIGHTS,
}, },
}) })
}) })
@@ -163,7 +163,7 @@ const createArchives = async ({ createPage, graphql }) => {
exports.onCreateNode = async ({ node, getNode, actions }) => { exports.onCreateNode = async ({ node, getNode, actions }) => {
const { createPage, createNodeField } = actions const { createPage, createNodeField } = actions
// TODO: find a better way to avoid handling non-resources // TODO: find a better way to avoid handling non-resources
// or better, attach authors to what-is archives // or better, attach authors to spotlights
if (node.internal.type === "Mdx" && node.frontmatter.authors) { if (node.internal.type === "Mdx" && node.frontmatter.authors) {
const { frontmatter } = node const { frontmatter } = node
const isDoc = Boolean(!frontmatter.path) const isDoc = Boolean(!frontmatter.path)
@@ -197,9 +197,9 @@ exports.onCreatePage = async ({ page, actions }) => {
const oldPage = { ...page } const oldPage = { ...page }
page.matchPath = `/resources/*` page.matchPath = `/resources/*`
deletePage(oldPage) deletePage(oldPage)
} else if (page.path.match(/^\/archives\/404/)) { } else if (page.path.match(/^\/spotlights\/404/)) {
const oldPage = { ...page } const oldPage = { ...page }
page.matchPath = `/archives/*` page.matchPath = `/spotlights/*`
deletePage(oldPage) deletePage(oldPage)
} }
@@ -211,7 +211,7 @@ exports.createPages = ({ actions, graphql }) => {
const { createPage } = actions const { createPage } = actions
return Promise.all([ return Promise.all([
createArchives({ createPage, graphql }), createSpotlights({ createPage, graphql }),
createResources({ createPage, graphql }), createResources({ createPage, graphql }),
]) ])
} }
+1 -1
View File
@@ -2973,7 +2973,7 @@ export type Unnamed_1_QueryVariables = {};
export type Unnamed_1_Query = ( export type Unnamed_1_Query = (
{ __typename?: 'Query' } { __typename?: 'Query' }
& { archives: ( & { spotlights: (
{ __typename?: 'FileConnection' } { __typename?: 'FileConnection' }
& { edges: Array<( & { edges: Array<(
{ __typename?: 'FileEdge' } { __typename?: 'FileEdge' }
+1 -1
View File
@@ -78,7 +78,7 @@ export const Home: FC = () => {
<MenuItem to="/faq">faq</MenuItem> <MenuItem to="/faq">faq</MenuItem>
<MenuItem to="/bots">bots</MenuItem> <MenuItem to="/bots">bots</MenuItem>
<MenuItem to="/resources">resources</MenuItem> <MenuItem to="/resources">resources</MenuItem>
<MenuItem to="/archives">tech spotlights</MenuItem> <MenuItem to="/spotlights">tech spotlights</MenuItem>
</SC.Menu> </SC.Menu>
<DiscordButton>join us</DiscordButton> <DiscordButton>join us</DiscordButton>
<HomePartner /> <HomePartner />
+1 -1
View File
@@ -44,7 +44,7 @@ export const Sidebar: FC<HTMLAttributes<HTMLDivElement>> = (props) => {
<MenuItem to="/faq">faq</MenuItem> <MenuItem to="/faq">faq</MenuItem>
<MenuItem to="/bots">bots</MenuItem> <MenuItem to="/bots">bots</MenuItem>
<MenuItem to="/resources">resources</MenuItem> <MenuItem to="/resources">resources</MenuItem>
<MenuItem to="/archives">tech spotlights</MenuItem> <MenuItem to="/spotlights">tech spotlights</MenuItem>
</SC.Menu> </SC.Menu>
<ThemeToggler /> <ThemeToggler />
@@ -9,10 +9,10 @@ import { humanize } from "../../utils"
import { Sidebar } from "../Sidebar" import { Sidebar } from "../Sidebar"
import * as SC from "./styles" import * as SC from "./styles"
const ALL_ARCHIVES = graphql` const ALL_SPOTLIGHTS = graphql`
query { query {
archives: allFile( spotlights: allFile(
filter: { sourceInstanceName: { eq: "what-is-archive" } } filter: { sourceInstanceName: { eq: "spotlights" } }
) { ) {
edges { edges {
node { node {
@@ -42,9 +42,9 @@ function Tree({ item }: { item: IFileOrFolder }) {
) )
} }
export const ArchivesSidebar: FC<HTMLAttributes<HTMLDivElement>> = (props) => { export const SpotlightsSidebar: FC<HTMLAttributes<HTMLDivElement>> = (props) => {
const { archives } = useStaticQuery(ALL_ARCHIVES) const { spotlights } = useStaticQuery(ALL_SPOTLIGHTS)
const tree = useBuildTree(archives, "/archives") const tree = useBuildTree(spotlights, "/spotlights")
const sortedTree = sort((a, b) => a.title.localeCompare(b.title), tree) const sortedTree = sort((a, b) => a.title.localeCompare(b.title), tree)
return ( return (
-14
View File
@@ -1,14 +0,0 @@
import React, { FC } from "react"
import { ArchivesSidebar } from "../../components/ArchivesSidebar"
import { ColumnLayout } from "../ColumnLayout"
export const ArchivesLayout: FC = ({ children }) => {
return (
<ColumnLayout
title="Archives"
sidebar={ArchivesSidebar}
content={children}
/>
)
}
+14
View File
@@ -0,0 +1,14 @@
import React, { FC } from "react"
import { SpotlightsSidebar } from "../../components/SpotlightsSidebar"
import { ColumnLayout } from "../ColumnLayout"
export const SpotlightsLayout: FC = ({ children }) => {
return (
<ColumnLayout
title="Spotlights"
sidebar={SpotlightsSidebar}
content={children}
/>
)
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { WindowLocation } from "@reach/router" import { WindowLocation } from "@reach/router"
import React, { FC, useMemo } from "react" import React, { FC, useMemo } from "react"
import { LocationProvider } from "../LocationProvider" import { LocationProvider } from "../LocationProvider"
import { ArchivesLayout } from "./ArchivesLayout" import { SpotlightsLayout } from "./SpotlightsLayout"
import { HomeLayout } from "./HomeLayout" import { HomeLayout } from "./HomeLayout"
import { PageLayout } from "./PageLayout" import { PageLayout } from "./PageLayout"
import { ResourcesLayout } from "./ResourcesLayout" import { ResourcesLayout } from "./ResourcesLayout"
@@ -21,8 +21,8 @@ const BaseLayout: FC<IBaseLayout> = (props) => {
switch (props.pageContext.layout) { switch (props.pageContext.layout) {
case "resources": case "resources":
return ResourcesLayout return ResourcesLayout
case "archives": case "spotlights":
return ArchivesLayout return SpotlightsLayout
case "regular": case "regular":
return PageLayout return PageLayout
default: default:
@@ -14,12 +14,12 @@ const FourZeroFourPage: React.FC<{ data: { allFile: FileConnection } }> = ({
data, data,
}: ComponentQuery<{ allFile: FileConnection }>) => ( }: ComponentQuery<{ allFile: FileConnection }>) => (
<Fragment> <Fragment>
<SEO title="404: Archive Not found" /> <SEO title="404: Spotlight Not found" />
<FourZeroFour title="ARCHIVE NOT FOUND"> <FourZeroFour title="SPOTLIGHT NOT FOUND">
<Location> <Location>
{({ location }) => ( {({ location }) => (
<FourZeroFourHint <FourZeroFourHint
basepath="archives/" basepath="spotlights/"
location={location} location={location}
data={data} data={data}
/> />
@@ -33,7 +33,7 @@ export default FourZeroFourPage
export const query = graphql` export const query = graphql`
query { query {
allFile(filter: { sourceInstanceName: { eq: "what-is-archive" } }) { allFile(filter: { sourceInstanceName: { eq: "spotlights" } }) {
edges { edges {
node { node {
relativePath relativePath
@@ -5,18 +5,18 @@ import { Link } from "../../components/Link"
import { PageContent } from "../../components/PageContent" import { PageContent } from "../../components/PageContent"
import { SEO } from "../../components/SEO" import { SEO } from "../../components/SEO"
function ArchivesPage() { function SpotlightsPage() {
return ( return (
<Fragment> <Fragment>
<SEO title="Tech Spotlights Archives" /> <SEO title="Tech Spotlights" />
<HeaderBarebone title="Welcome to the TPH tech spotlights archives." /> <HeaderBarebone title="Welcome to the TPH tech spotlights." />
<PageContent <PageContent
content={ content={
<p> <p>
This regroups the archives of our occasional, temporary channels This is a collection of our technology spotlights that have been
that cover a piece of technology that might be unknown to part of highlighted in our discord server. Spotlights run for one month
our users. You can find those on{" "} within the server before appearing here. You can find those on{" "}
<Link to="/about">The Programmer&apos;s Hangout</Link>. <Link to="/about">The Programmer&apos;s Hangout</Link>.
</p> </p>
} }
@@ -25,4 +25,4 @@ function ArchivesPage() {
) )
} }
export default ArchivesPage export default SpotlightsPage
@@ -7,7 +7,7 @@ import { humanize } from "../utils"
import { PageContent } from "../components/PageContent" import { PageContent } from "../components/PageContent"
// @todo maybe find alternative type for data // @todo maybe find alternative type for data
const Archive: FC<any> = ({ data }) => { const Spotlight: FC<any> = ({ data }) => {
const { relativePath } = data.file const { relativePath } = data.file
const { body, excerpt, fields, timeToRead, frontmatter } = data.file.post const { body, excerpt, fields, timeToRead, frontmatter } = data.file.post
@@ -18,7 +18,7 @@ const Archive: FC<any> = ({ data }) => {
<SEO title={title} description={excerpt} /> <SEO title={title} description={excerpt} />
<Header <Header
relativePath={relativePath} relativePath={relativePath}
basePath="/archives" basePath="/spotlights"
title={title} title={title}
authors={fields.authors} authors={fields.authors}
createdAt={frontmatter.created_at} createdAt={frontmatter.created_at}
@@ -30,10 +30,10 @@ const Archive: FC<any> = ({ data }) => {
) )
} }
export default Archive export default Spotlight
export const query = graphql` export const query = graphql`
query Archive($file: String!) { query Spotlight($file: String!) {
file(relativePath: { eq: $file }) { file(relativePath: { eq: $file }) {
relativePath relativePath
post: childMdx { post: childMdx {
+3 -3
View File
@@ -32,7 +32,7 @@ export interface IFileResourceQuery {
} }
} }
export interface IFileArchiveQuery { export interface IFileSpotlightQuery {
node: { node: {
relativePath: string relativePath: string
} }
@@ -50,9 +50,9 @@ export interface IAllResourcesQuery extends IAllFilesQuery {
} }
} }
export interface IAllArchivesQuery extends IAllFilesQuery { export interface IAllSpotlightsQuery extends IAllFilesQuery {
allFile: { allFile: {
edges: IFileArchiveQuery[] edges: IFileSpotlightQuery[]
} }
} }