From f252e81de25eb6cc89e2fd86ff1a2c8f7e084268 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 24 Oct 2021 17:22:23 +0100 Subject: [PATCH] Rename archive components --- gatsby-node.js | 16 ++++++++-------- .../index.tsx | 8 ++++---- .../styles.tsx | 0 .../index.tsx | 6 +++--- src/layouts/index.tsx | 4 ++-- src/pages/{archives => spotlights}/404.tsx | 0 src/pages/{archives => spotlights}/index.tsx | 4 ++-- src/templates/{archive.tsx => spotlight.tsx} | 6 +++--- src/types/index.d.ts | 6 +++--- 9 files changed, 25 insertions(+), 25 deletions(-) rename src/components/{ArchivesSidebar => SpotlightsSidebar}/index.tsx (84%) rename src/components/{ArchivesSidebar => SpotlightsSidebar}/styles.tsx (100%) rename src/layouts/{ArchivesLayout => SpotlightsLayout}/index.tsx (52%) rename src/pages/{archives => spotlights}/404.tsx (100%) rename src/pages/{archives => spotlights}/index.tsx (93%) rename src/templates/{archive.tsx => spotlight.tsx} (92%) diff --git a/gatsby-node.js b/gatsby-node.js index b73d3cd..9d119a1 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -7,7 +7,7 @@ const fs = require("fs") const requiredArticleFrontmatter = ["authors", "date"] const LAYOUT_RESOURCES = "resources" -const LAYOUT_ARCHIVES = "spotlights" +const LAYOUT_SPOTLIGHTS = "spotlights" const LAYOUT_REGULAR = "regular" const LAYOUT_HOME = "home" @@ -21,7 +21,7 @@ function resolveLayout(path) { } if (path.match(/spotlights/)) { - return LAYOUT_ARCHIVES + return LAYOUT_SPOTLIGHTS } return LAYOUT_REGULAR @@ -128,11 +128,11 @@ const createResources = async ({ createPage, graphql }) => { } } -const createArchives = async ({ createPage, graphql }) => { - const archive = path.resolve(`src/templates/archive.tsx`) +const createSpotlights = async ({ createPage, graphql }) => { + const spotlights = path.resolve(`src/templates/spotlight.tsx`) const result = await graphql(` - query FetchArchives { + query FetchSpotlights { allFile(filter: { sourceInstanceName: { eq: "spotlights" } }) { edges { node { @@ -151,10 +151,10 @@ const createArchives = async ({ createPage, graphql }) => { return result.data.allFile.edges.forEach(({ node }) => { createPage({ path: path.posix.join("spotlights", node.relativePath), - component: archive, + component: spotlights, context: { file: node.relativePath, - layout: LAYOUT_ARCHIVES, + layout: LAYOUT_SPOTLIGHTS, }, }) }) @@ -211,7 +211,7 @@ exports.createPages = ({ actions, graphql }) => { const { createPage } = actions return Promise.all([ - createArchives({ createPage, graphql }), + createSpotlights({ createPage, graphql }), createResources({ createPage, graphql }), ]) } diff --git a/src/components/ArchivesSidebar/index.tsx b/src/components/SpotlightsSidebar/index.tsx similarity index 84% rename from src/components/ArchivesSidebar/index.tsx rename to src/components/SpotlightsSidebar/index.tsx index ea65ab9..7e77220 100644 --- a/src/components/ArchivesSidebar/index.tsx +++ b/src/components/SpotlightsSidebar/index.tsx @@ -9,7 +9,7 @@ import { humanize } from "../../utils" import { Sidebar } from "../Sidebar" import * as SC from "./styles" -const ALL_ARCHIVES = graphql` +const ALL_SPOTLIGHTS = graphql` query { spotlights: allFile( filter: { sourceInstanceName: { eq: "spotlights" } } @@ -42,9 +42,9 @@ function Tree({ item }: { item: IFileOrFolder }) { ) } -export const ArchivesSidebar: FC> = (props) => { - const { archives } = useStaticQuery(ALL_ARCHIVES) - const tree = useBuildTree(archives, "/spotlights") +export const SpotlightsSidebar: FC> = (props) => { + const { spotlights } = useStaticQuery(ALL_SPOTLIGHTS) + const tree = useBuildTree(spotlights, "/spotlights") const sortedTree = sort((a, b) => a.title.localeCompare(b.title), tree) return ( diff --git a/src/components/ArchivesSidebar/styles.tsx b/src/components/SpotlightsSidebar/styles.tsx similarity index 100% rename from src/components/ArchivesSidebar/styles.tsx rename to src/components/SpotlightsSidebar/styles.tsx diff --git a/src/layouts/ArchivesLayout/index.tsx b/src/layouts/SpotlightsLayout/index.tsx similarity index 52% rename from src/layouts/ArchivesLayout/index.tsx rename to src/layouts/SpotlightsLayout/index.tsx index 52e2fd8..5f9813f 100644 --- a/src/layouts/ArchivesLayout/index.tsx +++ b/src/layouts/SpotlightsLayout/index.tsx @@ -1,13 +1,13 @@ import React, { FC } from "react" -import { ArchivesSidebar } from "../../components/ArchivesSidebar" +import { SpotlightsSidebar } from "../../components/SpotlightsSidebar" import { ColumnLayout } from "../ColumnLayout" -export const ArchivesLayout: FC = ({ children }) => { +export const SpotlightsLayout: FC = ({ children }) => { return ( ) diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 9b1644f..2e972cd 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -1,7 +1,7 @@ import { WindowLocation } from "@reach/router" import React, { FC, useMemo } from "react" import { LocationProvider } from "../LocationProvider" -import { ArchivesLayout } from "./ArchivesLayout" +import { SpotlightsLayout } from "./SpotlightsLayout" import { HomeLayout } from "./HomeLayout" import { PageLayout } from "./PageLayout" import { ResourcesLayout } from "./ResourcesLayout" @@ -22,7 +22,7 @@ const BaseLayout: FC = (props) => { case "resources": return ResourcesLayout case "spotlights": - return ArchivesLayout + return SpotlightsLayout case "regular": return PageLayout default: diff --git a/src/pages/archives/404.tsx b/src/pages/spotlights/404.tsx similarity index 100% rename from src/pages/archives/404.tsx rename to src/pages/spotlights/404.tsx diff --git a/src/pages/archives/index.tsx b/src/pages/spotlights/index.tsx similarity index 93% rename from src/pages/archives/index.tsx rename to src/pages/spotlights/index.tsx index 31d4990..cb77517 100644 --- a/src/pages/archives/index.tsx +++ b/src/pages/spotlights/index.tsx @@ -5,7 +5,7 @@ import { Link } from "../../components/Link" import { PageContent } from "../../components/PageContent" import { SEO } from "../../components/SEO" -function ArchivesPage() { +function SpotlightsPage() { return ( @@ -25,4 +25,4 @@ function ArchivesPage() { ) } -export default ArchivesPage +export default SpotlightsPage diff --git a/src/templates/archive.tsx b/src/templates/spotlight.tsx similarity index 92% rename from src/templates/archive.tsx rename to src/templates/spotlight.tsx index e8a9cb9..07f0168 100644 --- a/src/templates/archive.tsx +++ b/src/templates/spotlight.tsx @@ -7,7 +7,7 @@ import { humanize } from "../utils" import { PageContent } from "../components/PageContent" // @todo maybe find alternative type for data -const Archive: FC = ({ data }) => { +const Spotlight: FC = ({ data }) => { const { relativePath } = data.file const { body, excerpt, fields, timeToRead, frontmatter } = data.file.post @@ -30,10 +30,10 @@ const Archive: FC = ({ data }) => { ) } -export default Archive +export default Spotlight export const query = graphql` - query Archive($file: String!) { + query Spotlight($file: String!) { file(relativePath: { eq: $file }) { relativePath post: childMdx { diff --git a/src/types/index.d.ts b/src/types/index.d.ts index cd3d248..8e3a8dd 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -32,7 +32,7 @@ export interface IFileResourceQuery { } } -export interface IFileArchiveQuery { +export interface IFileSpotlightQuery { node: { relativePath: string } @@ -50,9 +50,9 @@ export interface IAllResourcesQuery extends IAllFilesQuery { } } -export interface IAllArchivesQuery extends IAllFilesQuery { +export interface IAllSpotlightsQuery extends IAllFilesQuery { allFile: { - edges: IFileArchiveQuery[] + edges: IFileSpotlightQuery[] } }