mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 01:05:58 +02:00
Rename archive components
This commit is contained in:
+8
-8
@@ -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 = "spotlights"
|
const LAYOUT_SPOTLIGHTS = "spotlights"
|
||||||
const LAYOUT_REGULAR = "regular"
|
const LAYOUT_REGULAR = "regular"
|
||||||
const LAYOUT_HOME = "home"
|
const LAYOUT_HOME = "home"
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ function resolveLayout(path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path.match(/spotlights/)) {
|
if (path.match(/spotlights/)) {
|
||||||
return LAYOUT_ARCHIVES
|
return LAYOUT_SPOTLIGHTS
|
||||||
}
|
}
|
||||||
|
|
||||||
return LAYOUT_REGULAR
|
return LAYOUT_REGULAR
|
||||||
@@ -128,11 +128,11 @@ 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: "spotlights" } }) {
|
allFile(filter: { sourceInstanceName: { eq: "spotlights" } }) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
@@ -151,10 +151,10 @@ 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("spotlights", 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,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -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 }),
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -9,7 +9,7 @@ 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 {
|
||||||
spotlights: allFile(
|
spotlights: allFile(
|
||||||
filter: { sourceInstanceName: { eq: "spotlights" } }
|
filter: { sourceInstanceName: { eq: "spotlights" } }
|
||||||
@@ -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, "/spotlights")
|
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 (
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import React, { FC } from "react"
|
import React, { FC } from "react"
|
||||||
|
|
||||||
import { ArchivesSidebar } from "../../components/ArchivesSidebar"
|
import { SpotlightsSidebar } from "../../components/SpotlightsSidebar"
|
||||||
import { ColumnLayout } from "../ColumnLayout"
|
import { ColumnLayout } from "../ColumnLayout"
|
||||||
|
|
||||||
export const ArchivesLayout: FC = ({ children }) => {
|
export const SpotlightsLayout: FC = ({ children }) => {
|
||||||
return (
|
return (
|
||||||
<ColumnLayout
|
<ColumnLayout
|
||||||
title="Spotlights"
|
title="Spotlights"
|
||||||
sidebar={ArchivesSidebar}
|
sidebar={SpotlightsSidebar}
|
||||||
content={children}
|
content={children}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -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"
|
||||||
@@ -22,7 +22,7 @@ const BaseLayout: FC<IBaseLayout> = (props) => {
|
|||||||
case "resources":
|
case "resources":
|
||||||
return ResourcesLayout
|
return ResourcesLayout
|
||||||
case "spotlights":
|
case "spotlights":
|
||||||
return ArchivesLayout
|
return SpotlightsLayout
|
||||||
case "regular":
|
case "regular":
|
||||||
return PageLayout
|
return PageLayout
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ 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" />
|
<SEO title="Tech Spotlights" />
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -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 {
|
||||||
Vendored
+3
-3
@@ -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[]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user