Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
},
"devDependencies": {
"@eslint/js": "^9.23.0",
"@tailwindcss/container-queries": "^0.1.1",
"@types/lodash": "^4.17.16",
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
Expand Down
12 changes: 12 additions & 0 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions web/src/api/schema.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,52 @@ export interface paths {
patch?: never;
trace?: never;
};
"/webhook/discourse": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/**
* /webhook/discourse
* @description Handle Discourse webhook events
*/
post: {
parameters: {
query?: never;
header: {
"X-Discourse-Instance": string;
"X-Discourse-Event": string;
"X-Discourse-Event-Signature": string;
};
path?: never;
cookie?: never;
};
requestBody: {
content: {
"application/octet-stream": string;
};
};
responses: {
200: {
headers: {
[name: string]: unknown;
};
content: {
"text/plain; charset=utf-8": string;
};
};
};
};
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
Expand Down
53 changes: 53 additions & 0 deletions web/src/components/topic/SmallTopicPreview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Link } from '@tanstack/react-router';
import { FC } from 'react';

import { Topic } from '@/api/topics';
import { decodeCategory } from '@/util/category';

import { CategoryTag } from '../CategoryTag';
import { DiscourseInstanceIcon } from '../DiscourseInstanceIcon';

export const SmallTopicPreview: FC<{ topic: Topic }> = ({ topic }) => {
const extra = (topic.extra || {}) as Record<string, unknown>;
const tag = [
...decodeCategory(extra?.['category_id'] as number),
...(extra?.['tags'] as string[]),
"no-category",
][0]

return (
<Link
to="/t/$discourseId/$topicId"
params={{ discourseId: topic.discourse_id, topicId: topic.topic_id.toString() }}
className="flex items-start justify-between gap-2 py-1"
>
{/* Wide layout - inline */}
<div className="flex-1 min-w-0 hidden @[28rem]:block">
<div className="flex items-center gap-2">
{tag && (
<div className="w-36 flex justify-end flex-shrink-0">
<CategoryTag tag={tag} />
</div>
)}
<div className="font-bold">
{topic.title}
</div>
</div>
</div>

{/* Narrow layout - stacked */}
<div className="flex-1 min-w-0 @[28rem]:hidden space-y-1">
{tag && (
<div className="flex justify-start">
<CategoryTag tag={tag} />
</div>
)}
<div className="font-bold">
{topic.title}
</div>
</div>

<DiscourseInstanceIcon discourse_id={topic.discourse_id} />
</Link>
);
};
29 changes: 19 additions & 10 deletions web/src/components/topic/TopicsTrending.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import { FC } from 'react';

import { useTopicsTrending } from '@/api/topics';
import { SmallTopicPreview } from './SmallTopicPreview';

import { MicroInfo } from '../tooltip/MicroInfo';
import { TopicPreview } from './TopicPreview';

export const TopicsTrending: FC = () => {
const { data, isLoading } = useTopicsTrending();

if (isLoading) {
return <div>Loading...</div>;
}

const sortedTopics = data
?.slice(0, 6)
.sort(
(a, b) =>
new Date(b.last_post_at ?? '').getTime() -
new Date(a.last_post_at ?? '').getTime()
);

return (
<div className="space-y-4">
<div className="text-lg font-bold border-b border-b-primary flex justify-between items-baseline">
Expand All @@ -22,15 +31,15 @@ export const TopicsTrending: FC = () => {
</div>
</MicroInfo>
</div>
<div className="grid gap-2 grid-cols-1 md:grid-cols-2 mx-auto">
{data
?.slice(0, 6)
.sort(
(a, b) =>
new Date(b.last_post_at ?? '').getTime() -
new Date(a.last_post_at ?? '').getTime()
)
.map((topic) => <TopicPreview key={topic.topic_id} topic={topic} />)}
<div className="mx-auto @container">
<div className="space-y-1">
{sortedTopics?.map((topic) => (
<SmallTopicPreview
key={topic.topic_id}
topic={topic}
/>
))}
</div>
</div>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions web/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default {
},
},
plugins: [
require('@tailwindcss/container-queries'),
function ({ addUtilities }) {
const newUtilities = {
'.animation-delay-0': {
Expand Down