Skip to content

Commit

Permalink
filter advanced content
Browse files Browse the repository at this point in the history
  • Loading branch information
mruwnik committed Mar 1, 2024
1 parent 21f62de commit feb4466
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
10 changes: 10 additions & 0 deletions app/components/Article/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ article .footer-comtainer > * {
margin: var(--spacing-8, 8px);
}

article a.see-more:not(.visible) + div.see-more-contents {
display: none;
}
article a.see-more:after {
content: 'See more...';
}
article a.see-more.visible:after {
content: 'See less';
}

@media only screen and (max-width: 640px) {
article {
max-width: 100%;
Expand Down
23 changes: 10 additions & 13 deletions app/components/Grid/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ export const GridBox = ({title, subtitle, icon, pageid}: TOCItem) => (
interface GridProps {
gridBoxes: TOCItem[]
}
export const Grid = ({gridBoxes}: GridProps) => {
console.log(gridBoxes)
return (
<div className="grid">
{gridBoxes
.filter(({category}) => category)
.slice(0, 6)
.map((gridBoxProps) => (
<GridBox key={gridBoxProps.title} {...gridBoxProps} />
))}
</div>
)
}
export const Grid = ({gridBoxes}: GridProps) => (
<div className="grid">
{gridBoxes
.filter(({category}) => category)
.slice(0, 6)
.map((gridBoxProps) => (
<GridBox key={gridBoxProps.title} {...gridBoxProps} />
))}
</div>
)
export default Grid
4 changes: 0 additions & 4 deletions app/hooks/useSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ export const useSearch = (
runningQueryRef.current = undefined
if (data.searchResults) setResults(data.searchResults)
setIsPendingSearch(false)
// TODO: temporary debug, remove if search works well for some time
console.debug('tfWorker search results for:', data.userQuery, data.searchResults)
}
})
}
Expand Down Expand Up @@ -169,8 +167,6 @@ export const useSearch = (
runningQueryRef.current = undefined
setResults(searchResults)
setIsPendingSearch(false)
// TODO: temporary debug, remove if search works well for some time
console.debug('baseline search results for:', userQuery, searchResults)
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/hooks/useToC.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TOCItem} from '~/routes/questions.toc'
import {TOCItem, ADVANCED} from '~/routes/questions.toc'
import {useToC as useCachedToC} from '~/hooks/useCachedObjects'

const identity = (i: any) => i
Expand Down Expand Up @@ -52,6 +52,7 @@ const useToC = () => {

return {
toc: toc || [],
advanced: (toc || []).filter(({category}) => category === ADVANCED),
getArticle,
findSection,
getPath,
Expand Down
4 changes: 2 additions & 2 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const loader = async ({request}: Parameters<LoaderFunction>[0]) => {
export const shouldRevalidate: ShouldRevalidateFunction = () => false

export default function App() {
const {toc} = useToC()
const {advanced} = useToC()
return (
<Page>
<div className="page-body">
Expand All @@ -41,7 +41,7 @@ export default function App() {
<WidgetStampy />

<h3 className="grey large-bold padding-bottom-32">Advanced sections</h3>
<Grid gridBoxes={toc} />
<Grid gridBoxes={advanced} />
</div>
</Page>
)
Expand Down
1 change: 0 additions & 1 deletion app/routes/questions.$questionId.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export default function RenderArticle() {
}, [setGlossary])

useEffect(() => {
console.log('locatiopn change', location.key)
setShowNav(false)
}, [location.key])

Expand Down
2 changes: 1 addition & 1 deletion app/routes/questions.toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const loadToC = async (request: any): Promise<LoaderResp> => {
})
return {
data: data
.filter(({parents, children}) => (!parents || parents.length === 0) && children)
.filter(({tags}) => tags.includes(INTRODUCTORY) || tags.includes(ADVANCED))
.map(formatQuestion(1)),
timestamp,
}
Expand Down

0 comments on commit feb4466

Please sign in to comment.