Skip to content

Commit

Permalink
feat: setup new list (#22)
Browse files Browse the repository at this point in the history
* feat: setup new lists

* fix: missing index meta

* fix: ensure unauthroized routes to be treated as 404
  • Loading branch information
edmundhung authored Nov 21, 2022
1 parent c1cc3c0 commit b14135e
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 18 deletions.
18 changes: 13 additions & 5 deletions app/components/SidebarNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import discordIcon from '~/icons/discord.svg';
import timesIcon from '~/icons/times.svg';
import remixIcon from '~/icons/remix.svg';
import packageIcon from '~/icons/box-open.svg';
import repositoryIcon from '~/icons/map-signs.svg';
import showcaseIcon from '~/icons/map-signs.svg';
import officialIcon from '~/icons/bullhorn.svg';
import tutorialIcon from '~/icons/chalkboard-teacher.svg';
import templateIcon from '~/icons/layer-group.svg';
import othersIcon from '~/icons/mail-bulk.svg';
import exampleIcon from '~/icons/code.svg';
import eventIcon from '~/icons/calendar-alt.svg';
import opinionIcon from '~/icons/mail-bulk.svg';
import type { UserProfile } from '~/types';
import {
PaneContainer,
Expand Down Expand Up @@ -122,13 +124,19 @@ function getListIcon(slug: string): string {
case 'packages':
return packageIcon;
case 'examples':
return repositoryIcon;
return exampleIcon;
case 'tutorials':
return tutorialIcon;
case 'templates':
return templateIcon;
case 'events':
return eventIcon;
case 'opinions':
return opinionIcon;
case 'showcase':
return showcaseIcon;
default:
return othersIcon;
return opinionIcon;
}
}

Expand Down Expand Up @@ -192,7 +200,7 @@ function SidebarNavigation({
</SearchLink>
</List>
) : null}
<List title="Guide">
<List title="List">
{(lists ?? []).map((list) => (
<SearchLink key={list.slug} list={list.slug}>
<SvgIcon className="w-4 h-4" href={getListIcon(list.slug)} />{' '}
Expand Down
5 changes: 5 additions & 0 deletions app/icons/calendar-alt.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/icons/code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions app/routes/_layout.$list.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LoaderArgs, MetaFunction } from '@remix-run/cloudflare';
import { json, redirect } from '@remix-run/cloudflare';
import { json } from '@remix-run/cloudflare';
import { useLoaderData } from '@remix-run/react';
import type { ShouldReloadFunction } from '@remix-run/react';
import Feed from '~/components/Feed';
Expand All @@ -16,7 +16,7 @@ export async function loader({ request, params, context }: LoaderArgs) {
case 'bookmarks':
case 'history': {
if (!profile) {
throw redirect('/');
throw notFound();
}

const searchOptions = getSearchOptions(request.url);
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_layout.admin.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { LoaderArgs } from '@remix-run/cloudflare';
import { json } from '@remix-run/cloudflare';
import { Outlet, useLoaderData, useLocation } from '@remix-run/react';
import { useMemo } from 'react';
import menuIcon from '~/icons/menu.svg';
Expand All @@ -7,12 +8,11 @@ import { PaneContainer, PaneHeader, PaneFooter, PaneContent } from '~/layout';
import { toggleSearchParams } from '~/search';
import IconLink from '~/components/IconLink';
import { requireAdministrator } from '~/helpers';
import { ok } from '~/helpers';

export async function loader({ context }: LoaderArgs) {
await requireAdministrator(context);

return ok();
return json({});
}

export default function Admin() {
Expand Down
11 changes: 10 additions & 1 deletion app/routes/_layout.index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { LoaderArgs } from '@remix-run/cloudflare';
import type { LoaderArgs, MetaFunction } from '@remix-run/cloudflare';
import { json } from '@remix-run/cloudflare';
import { useLoaderData } from '@remix-run/react';
import About from '~/components/About';
import Feed from '~/components/Feed';
import { formatMeta } from '~/helpers';
import { search } from '~/resources';
import { getSearchOptions } from '~/search';

Expand All @@ -13,6 +14,14 @@ export async function loader({ request, context }: LoaderArgs) {
return json(search(list, searchOptions));
}

export const meta: MetaFunction<typeof loader> = () => {
return formatMeta({
title: 'Remix Guide',
description: 'A platform for the Remix community',
'og:url': `https://remix.guide`,
});
};

export default function Index() {
const { entries, count } = useLoaderData<typeof loader>();

Expand Down
20 changes: 12 additions & 8 deletions worker/store/ResourcesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,33 @@ const defaultLists: List[] = [
slug: 'official',
title: 'Official',
},
{
slug: 'tutorials',
title: 'Tutorials',
},
{
slug: 'packages',
title: 'Packages',
},
{
slug: 'tutorials',
title: 'Tutorials',
slug: 'events',
title: 'Events',
},
{
slug: 'templates',
title: 'Templates',
slug: 'showcase',
title: 'Showcase',
},
{
slug: 'talks',
title: 'Talks',
slug: 'templates',
title: 'Templates',
},
{
slug: 'examples',
title: 'Examples',
},
{
slug: 'integrations',
title: 'Integrations',
slug: 'opinions',
title: 'Opinions',
},
];

Expand Down

0 comments on commit b14135e

Please sign in to comment.