Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typos + title #568

Merged
merged 1 commit into from
Mar 27, 2024
Merged
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
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
2 changes: 1 addition & 1 deletion app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,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
})
Comment on lines +100 to +103
Copy link
Collaborator

@jrhender jrhender Mar 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ideally this as Question cast would be removed as it breaks type safety and makes it more likely that a bug would be introduced if the return type of the loader is changed. This seems better IMHO:

Suggested change
data.then((val) => {
const question = val as Question
if (question.title) document.title = question.title
})
data.then((val) => {
if ('title' in val && val.title) document.title = val.title
})

If a property is used in the conditional that doesn't help with the narrowing, then there is a TS error
image

If a property is used in the assignment that doesn't exist on the narrowed type, then there is also a TS error
image

}, [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
Loading