Skip to content

Commit

Permalink
typos + title
Browse files Browse the repository at this point in the history
  • Loading branch information
mruwnik committed Mar 23, 2024
1 parent f5c2781 commit 6a43db7
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/components/ContentBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const ContentBoxMain = () => (
action={questionUrl({pageid: '9OGZ'})}
actionTitle={
<>
<span className="default-bold">Start reading</span>
<span className="default-bold">Start here</span>
<ArrowRight />
</>
}
Expand Down
4 changes: 2 additions & 2 deletions app/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const FooterBar: FunctionComponent = () => {
<a href="/">AISafety.info</a>
</p>
<div>
We’re a global team of specialists supported by volunteers from various backgrounds who
are concerned about the possibility of human extinction from future AI.
We’re a global team of specialists and volunteers from various backgrounds who want to
ensure that the effects of future AI are beneficial rather than catastrophic.
</div>
</div>

Expand Down
1 change: 0 additions & 1 deletion app/components/Grid/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
text-align: left;
padding: var(--spacing-40);
width: 21.46vw;
height: 21.46vw;
min-width: var(--spacing-288);
min-height: var(--spacing-288);
text-decoration: none;
Expand Down
14 changes: 7 additions & 7 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import newStyles from '~/newRoot.css'
import Error from '~/components/Error'
import Page from '~/components/Page'
import {CachedObjectsProvider} from '~/hooks/useCachedObjects'
import {questionsOnPage} from '~/hooks/stateModifiers'
import {useTheme} from '~/hooks/theme'
import {loadQuestionDetail} from '~/server-utils/stampy'

Expand Down Expand Up @@ -47,15 +46,16 @@ const makeSocialPreviewText = (
*/
const fetchQuestion = async (request: Request) => {
const url = new URL(request.url)
const questions = questionsOnPage(url.searchParams.get('state') || '')

if (questions.length != 1) return null

const {data} = await loadQuestionDetail(request, questions[0][0])
return data
const [path, pageid] = url.pathname.slice(1).split('/') || []
if (path === 'questions') {
const {data} = await loadQuestionDetail(request, pageid)
return data
}
return null
}

const TITLE = 'Stampy'
const TITLE = 'AISafety.info'
const DESCRIPTION = 'AI Safety FAQ'
const twitterCreator = '@stampyai'
export const meta: MetaFunction<typeof loader> = ({data = {} as any}) => {
Expand Down
24 changes: 2 additions & 22 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import type {LoaderFunction} from '@remix-run/cloudflare'
import {ShouldRevalidateFunction, redirect} from '@remix-run/react'
import {QuestionState} from '~/server-utils/stampy'
import {ShouldRevalidateFunction} from '@remix-run/react'
import {ContentBoxMain, ContentBoxSecond, ContentBoxThird} from '~/components/ContentBox'
import useToC from '~/hooks/useToC'
import Grid from '~/components/Grid'
import Page from '~/components/Page'
import {getStateEntries} from '~/hooks/stateModifiers'
import {questionUrl} from '~/routesMapper'

export const loader = async ({request}: Parameters<LoaderFunction>[0]) => {
const url = new URL(request.url)
const stateFromUrl = url.searchParams.get('state')
if (stateFromUrl) {
const firstOpenId = getStateEntries(stateFromUrl).filter(
([_, state]) => state === QuestionState.OPEN
)[0]?.[0]
if (firstOpenId) {
url.searchParams.delete('state')
url.pathname = questionUrl({pageid: firstOpenId})
throw redirect(url.toString())
}
}
return null
}

export const shouldRevalidate: ShouldRevalidateFunction = () => false

Expand All @@ -31,7 +11,7 @@ export default function App() {
return (
<Page>
<div className="page-body">
<h1 className="padding-bottom-80 padding-top-56">Answers on all things AI safety</h1>
<h1 className="padding-bottom-80 padding-top-56">Your guide to AI safety</h1>

<ContentBoxMain />
<ContentBoxSecond />
Expand Down
7 changes: 7 additions & 0 deletions app/routes/questions.$questionId.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ export default function RenderArticle() {
setShowNav(false)
}, [location.key])

useEffect(() => {
data.then((val) => {
const question = val as Question
if (question.title) document.title = question.title
})
}, [data])

return (
<Page modal={showNav}>
<div className={`article-container ${showNav ? 'no-padding' : ''}`}>
Expand Down
5 changes: 4 additions & 1 deletion app/routes/questions.toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ export const loadToC = async (request: any): Promise<LoaderResp> => {
[k: string]: Question
}
const canBeShown = ({status}: Question) =>
status && [QuestionStatus.LIVE_ON_SITE, QuestionStatus.NOT_STARTED].includes(status)
status &&
[QuestionStatus.LIVE_ON_SITE, QuestionStatus.NOT_STARTED, QuestionStatus.SUBSECTION].includes(
status
)

data
.filter(canBeShown)
Expand Down
1 change: 1 addition & 0 deletions app/server-utils/stampy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export enum QuestionStatus {
IN_PROGRESS = 'In progress',
IN_REVIEW = 'In review',
LIVE_ON_SITE = 'Live on site',
SUBSECTION = 'Subsection',
UNKNOWN = 'Unknown',
}
export type Banner = {
Expand Down

0 comments on commit 6a43db7

Please sign in to comment.