Skip to content

Commit 948584b

Browse files
Merge pull request #26 from qlemaire22:tools-page
[#15] Tools page
2 parents b7047e8 + ae317f3 commit 948584b

File tree

8 files changed

+93
-16
lines changed

8 files changed

+93
-16
lines changed

src/assets/content/luminite.png

99.6 KB
Loading

src/assets/content/replay-renamer.png

149 KB
Loading

src/components/Card.astro

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import NewsMeta from "./sources/NewsMeta.astro"
55
import RedditMeta from "./sources/RedditMeta.astro"
66
import TwitterMeta from "./sources/TwitterMeta.astro"
77
import YoutubeMeta from "./sources/YoutubeMeta.astro"
8+
import ToolMeta from "./sources/ToolMeta.astro"
89
export interface Props {
910
data: Content
1011
}
1112
1213
const { data } = Astro.props
1314
14-
const isStormgatenexus = data.source == "news" && data.author_url.includes("stormgatenexus.com")
15+
const isStormgatenexus = data.source == "news" && data.author_url?.includes("stormgatenexus.com")
1516
---
1617

1718
<div
@@ -43,7 +44,7 @@ const isStormgatenexus = data.source == "news" && data.author_url.includes("stor
4344
}
4445
<div class="flex flex-auto flex-col p-6">
4546
{
46-
["twitter"].includes(data.source) ? (
47+
data.source && ["twitter"].includes(data.source) ? (
4748
<a
4849
class:list={[
4950
"text-gray-100 whitespace-pre-wrap text-md line-clamp-5",
@@ -91,6 +92,8 @@ const isStormgatenexus = data.source == "news" && data.author_url.includes("stor
9192
<YoutubeMeta data={data} />
9293
) : data.source === "news" ? (
9394
<NewsMeta data={data} />
95+
) : data.source === "tool" ? (
96+
<ToolMeta data={data} />
9497
) : (
9598
<slot>
9699
</slot>

src/components/sources/ToolMeta.astro

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
import type { ToolContent } from "../../lib/content"
3+
import { styles } from "../../lib/theme"
4+
5+
export interface Props {
6+
data: ToolContent
7+
}
8+
9+
const { data } = Astro.props
10+
---
11+
12+
{data.metadata?.tags.map((tag) => <div class={styles.tag.base}>{tag}</div>)}

src/layouts/Layout.astro

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const navLinks = [
1515
{ href: "/stats", text: "Stats" },
1616
{ href: "/social", text: "Content" },
1717
{ href: "/api", text: "API" },
18+
{ href: "/tools", text: "Tools" },
1819
// { href: "/creators", text: "Creators" },
1920
]
2021
---
@@ -48,7 +49,7 @@ const navLinks = [
4849
<a
4950
href={href}
5051
class:list={[
51-
"font-bold rounded px-2 md:px-3 py-1 md:py-1.5",
52+
"font-bold rounded px-2 text-sm xs:text-base md:px-3 py-1 md:py-1.5",
5253
currentRoute === href ? "bg-white/5 text-gray-50" : "hover:bg-white/5 text-gray-200 ",
5354
]}
5455
>

src/lib/content.ts

+17-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { debugLog } from "./utils"
22

33
export const validContentOrders = ["score_relevant", "score_popular", "published_at"] as const
44
export const validCreatorsOrders = ["popular", "active"] as const
5-
export const validSources = ["youtube", "twitter", "reddit", "news"] as const
5+
export const validSources = ["youtube", "twitter", "reddit", "news", "tool"] as const
66
export const validLanguages = ["any", "en", "es", "fr", "de", "it", "pt", "ru", "zh"] as const
77

88
export type FetchContentOrder = (typeof validContentOrders)[number]
@@ -53,7 +53,7 @@ export async function fetchContent<S extends Content["source"][] = []>(sources:
5353
})
5454

5555
if (sources.length > 0) {
56-
sources.forEach((s) => urlParams.append("sources[]", s))
56+
sources.forEach((s) => urlParams.append("sources[]", s || ""))
5757
}
5858

5959
const url = `https://api.stormgateworld.com/v0/content?${urlParams.toString()}`
@@ -66,21 +66,21 @@ export async function fetchContent<S extends Content["source"][] = []>(sources:
6666
}
6767

6868
export type SourceData<Source extends string, T = undefined> = {
69-
id: number
69+
id?: number
7070
source: Source
71-
source_id: string
72-
metadata: T
73-
score: number
71+
source_id?: string
72+
metadata?: T
73+
score?: number
7474
title: string
7575
description: string
7676
url: string
7777
image_url: string
78-
author: string
79-
author_url: string
80-
author_image_url: string
81-
published_at: string
82-
updated_at: string
83-
created_at: string
78+
author?: string
79+
author_url?: string
80+
author_image_url?: string
81+
published_at?: string
82+
updated_at?: string
83+
created_at?: string
8484
}
8585

8686
export type TwitterData = {
@@ -103,11 +103,15 @@ export type RedditData = {
103103
upvotes_count: number
104104
}
105105

106+
export type ToolData = {
107+
tags: string[]
108+
}
106109

107110
export type YoutubeContent = SourceData<"youtube", YoutubeData>
108111
export type TwitterContent = SourceData<"twitter", TwitterData>
109112
export type RedditContent = SourceData<"reddit", RedditData>
110113
export type NewsContent = SourceData<"news">
111-
export type Content = YoutubeContent | TwitterContent | RedditContent | NewsContent
114+
export type ToolContent = SourceData<"tool", ToolData>
115+
export type Content = YoutubeContent | TwitterContent | RedditContent | NewsContent | ToolContent
112116

113117
type FilteredContentType<T extends Content["source"]> = Extract<Content, { source: T }>

src/lib/theme.ts

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export const styles = {
3030
hover:bg-gray-500/50 ui-highlighted:bg-gray-600/20 ui-highlighted:!ring-0
3131
outline-none focus-visible:ring-2 focus-visible:ring-gray-300 focus-visible:ring-opacity-50
3232
`,
33+
},
34+
tag: {
35+
base: `inline-flex items-center justify-center rounded-sm
36+
bg-gray-700/50 border border-gray-500 backdrop-blur-sm rounded-xl
37+
text-gray-100 font-semibold whitespace-nowrap
38+
outline-none
39+
transition duration-200 px-3 py-1.5 text-sm`,
3340
}
3441
}
3542

src/pages/tools.astro

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
import Layout from "../layouts/Layout.astro"
3+
import Card from "../components/Card.astro"
4+
import type { ToolContent } from "../lib/content"
5+
import luminiteImage from "../assets/content/luminite.png"
6+
import replayRenamerImage from "../assets/content/replay-renamer.png"
7+
8+
const toolsContent: ToolContent[] = [
9+
{
10+
title: "Streamer Overlay",
11+
source: "tool",
12+
description: "A tool for streamers to display information about ongoing games in their broadcasts.",
13+
url: "https://overlay.stormgateworld.com/",
14+
image_url: "https://raw.githubusercontent.com/stormgateworld/overlay/main/Preview.png",
15+
metadata: { tags: ["Overlay", "By SGW"] },
16+
},
17+
{
18+
title: "Luminite.gg",
19+
source: "tool",
20+
description: "Discover and share build orders. View unit information and ladder stats.",
21+
url: "https://luminite.gg/",
22+
image_url: luminiteImage.src,
23+
metadata: { tags: ["Build orders", "Stats", "External"] },
24+
},
25+
{
26+
title: "Replay Renamer",
27+
source: "tool",
28+
description: "Python script to rename replays.",
29+
url: "https://gist.github.com/acarapetis/b5e9cf199ea2a468ace2f756ac287268",
30+
image_url: replayRenamerImage.src,
31+
metadata: { tags: ["Replays", "External"] },
32+
},
33+
]
34+
---
35+
36+
<Layout title="Tools">
37+
<div class="w-full bg-gray-800/50 backdrop-blur-lg border-b border-gray-700/50">
38+
<div class="mx-auto max-w-screen-lg px-4 lg:px-0 py-8 gap-4 flex items-center flex-wrap justify-between">
39+
<div>
40+
<p class="font-bold text-gray-500">Community</p>
41+
<h1 class="text-2xl text-white font-bold flex-auto">Tools and Projects</h1>
42+
</div>
43+
</div>
44+
</div>
45+
<div class="mx-auto max-w-screen-lg w-full py-4 md:py-8 px-8 lg:px-0">
46+
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3">
47+
{toolsContent.map((c) => <Card data={c} />)}
48+
</div>
49+
</div>
50+
</Layout>

0 commit comments

Comments
 (0)