Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chibat committed Feb 21, 2024
1 parent 498de54 commit ae584f1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion islands/PostView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default function PostView(
referrerpolicy="no-referrer"
/>
<a
href={`/users/${post.user_id}`}
href={`/users/${post.account ?? post.user_id}`}
class="ms-2 me-2 noDecoration"
>
{post.name}
Expand Down
4 changes: 3 additions & 1 deletion routes/_middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export async function handler(
return new Response(
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${
users.map((user) =>
`<url><loc>${baseUrl}/users/${user.user_id}</loc><lastmod>${
`<url><loc>${baseUrl}/users/${
user.account ?? user.user_id
}</loc><lastmod>${
new Date(user.updated_at).toISOString()
}</lastmod></url>`
).join("") + posts.map((post) =>
Expand Down
1 change: 1 addition & 0 deletions server/database.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export type Database = {
}
user_view: {
Row: {
account: string | null
updated_at: string | null
user_id: number | null
}
Expand Down
4 changes: 3 additions & 1 deletion server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ export type PostViewType = {
source: string;
updated_at: string;
user_id: number;
account?: string | null;
};

export type UserViewType = {
user_id: number;
updated_at: string;
account?: string | null;
};

let supabase: SupabaseClient<Database>;
Expand Down Expand Up @@ -87,7 +89,7 @@ export async function selectUser(userKey: string) {

export async function selectUsers() {
const { data, error } = await supabase.from("user_view").select(
"user_id,updated_at",
"user_id,updated_at,account",
).returns<UserViewType[]>();
if (error) {
throw error;
Expand Down

0 comments on commit ae584f1

Please sign in to comment.