Skip to content

Commit

Permalink
Merge pull request #754 from StampyAI/section-in-progress
Browse files Browse the repository at this point in the history
hide in-progress banner in sub-sections #753
  • Loading branch information
Aprillion authored Aug 16, 2024
2 parents aaf66c7 + 08821d2 commit 1297443
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
17 changes: 11 additions & 6 deletions app/components/Article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,24 @@ type ArticleProps = {
}
export const Article = ({question, glossary, className}: ArticleProps) => {
const {title, text, pageid} = question
console.debug('gg')

return (
<article className={`${className} ${isLoading(question) ? 'loading' : ''}`}>
<h1 className="teal-500 padding-bottom-24">{title}</h1>
{question.banners?.filter((b) => b.title).map(Banner)}
<ArticleMeta question={question} className="padding-bottom-56" />

<Contents
className="padding-bottom-80"
pageid={pageid}
html={text || ''}
glossary={glossary || {}}
/>
{text ? (
<Contents
className="padding-bottom-80"
pageid={pageid}
html={text}
glossary={glossary || {}}
/>
) : (
<div className="padding-bottom-32" />
)}

<KeepGoing {...question} />

Expand Down
13 changes: 11 additions & 2 deletions app/routes/questions.$questionId.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ const updateRelated = (question: Question, allQuestions?: Question[]) => {
}
}

const updateFields = (question: Question, tags?: Tag[], allQuestions?: Question[]) =>
updateTags(updateRelated(question, allQuestions), tags)
const updateBanners = (question: Question, hideBanners?: boolean) =>
hideBanners ? {...question, banners: []} : question

const updateFields = (
question: Question,
hideBanners?: boolean,
tags?: Tag[],
allQuestions?: Question[]
) => updateTags(updateRelated(updateBanners(question, hideBanners), allQuestions), tags)

export default function RenderArticle() {
const location = useLocation()
Expand All @@ -80,6 +87,7 @@ export default function RenderArticle() {
const {question} = useLoaderData<typeof loader>()
const {toc, findSection, getArticle, getPath} = useToC()
const section = findSection(location?.state?.section || pageid)
const hideBannersIfSubsection = section?.children?.some((c) => c.pageid === pageid)

useEffect(() => {
setShowNav(false)
Expand Down Expand Up @@ -153,6 +161,7 @@ export default function RenderArticle() {
<Article
question={updateFields(
resolvedQuestion.data as Question,
hideBannersIfSubsection,
tags,
onSiteQuestions
)}
Expand Down

0 comments on commit 1297443

Please sign in to comment.