@@ -23,7 +23,7 @@ import type {
2323} from '../CustomRoadmap/CustomRoadmap' ;
2424import { markdownToHtml , sanitizeMarkdown } from '../../lib/markdown' ;
2525import { cn } from '../../lib/classname' ;
26- import { Ban , FileText , X } from 'lucide-react' ;
26+ import { Ban , FileText , HeartHandshake , X } from 'lucide-react' ;
2727import { getUrlParams } from '../../lib/browser' ;
2828import { Spinner } from '../ReactIcons/Spinner' ;
2929import { GitHubIcon } from '../ReactIcons/GitHubIcon.tsx' ;
@@ -58,6 +58,7 @@ export function TopicDetail(props: TopicDetailProps) {
5858 const [ isContributing , setIsContributing ] = useState ( false ) ;
5959 const [ error , setError ] = useState ( '' ) ;
6060 const [ topicHtml , setTopicHtml ] = useState ( '' ) ;
61+ const [ hasContent , setHasContent ] = useState ( false ) ;
6162 const [ topicTitle , setTopicTitle ] = useState ( '' ) ;
6263 const [ topicHtmlTitle , setTopicHtmlTitle ] = useState ( '' ) ;
6364 const [ links , setLinks ] = useState < RoadmapContentDocument [ 'links' ] > ( [ ] ) ;
@@ -177,6 +178,9 @@ export function TopicDetail(props: TopicDetailProps) {
177178
178179 const titleElem : HTMLElement = topicDom . querySelector ( 'h1' ) ! ;
179180
181+ const otherElems = topicDom . querySelectorAll ( 'body > *:not(h1, div)' ) ;
182+
183+ setHasContent ( otherElems . length > 0 ) ;
180184 setContributionUrl ( contributionUrl ) ;
181185 setHasEnoughLinks ( links . length >= 3 ) ;
182186 setTopicHtmlTitle ( titleElem ?. textContent || '' ) ;
@@ -187,6 +191,8 @@ export function TopicDetail(props: TopicDetailProps) {
187191 const sanitizedMarkdown = sanitizeMarkdown (
188192 ( response as RoadmapContentDocument ) . description || '' ,
189193 ) ;
194+
195+ setHasContent ( sanitizedMarkdown ?. length > 0 ) ;
190196 topicHtml = markdownToHtml ( sanitizedMarkdown , false ) ;
191197 }
192198
@@ -207,7 +213,6 @@ export function TopicDetail(props: TopicDetailProps) {
207213 return null ;
208214 }
209215
210- const hasContent = topicHtml ?. length > 0 || links ?. length > 0 || topicTitle ;
211216 const resourceTitleForSearch = resourceTitle
212217 ?. toLowerCase ( )
213218 ?. replace ( / \s + ?r o a d m a p / gi, '' ) ;
@@ -225,7 +230,7 @@ export function TopicDetail(props: TopicDetailProps) {
225230 className = "fixed right-0 top-0 z-40 flex h-screen w-full flex-col overflow-y-auto bg-white p-4 focus:outline-0 sm:max-w-[600px] sm:p-6"
226231 >
227232 { isLoading && (
228- < div className = "flex w -full h -full items-center justify-center" >
233+ < div className = "flex h -full w -full items-center justify-center" >
229234 < Spinner
230235 outerFill = "#d1d5db"
231236 className = "h-6 w-6 sm:h-8 sm:w-8"
@@ -242,7 +247,11 @@ export function TopicDetail(props: TopicDetailProps) {
242247 < div className = "mb-2" >
243248 { ! isEmbed && (
244249 < TopicProgressButton
245- topicId = { topicId }
250+ topicId = {
251+ topicId . indexOf ( '@' ) !== - 1
252+ ? topicId . split ( '@' ) [ 1 ]
253+ : topicId
254+ }
246255 resourceId = { resourceId }
247256 resourceType = { resourceType }
248257 onClose = { ( ) => {
@@ -265,20 +274,48 @@ export function TopicDetail(props: TopicDetailProps) {
265274
266275 { /* Topic Content */ }
267276 { hasContent ? (
268- < div className = "prose prose-quoteless prose-h1:mb-2.5 prose-h1:mt-7 prose-h1:text-balance prose-h2:mb-3 prose-h2:mt-0 prose-h3:mb-[5px] prose-h3:mt-[10px] prose-p:mb-2 prose-p:mt-0 prose-blockquote:font-normal prose-blockquote:not-italic prose-blockquote:text-gray-700 prose-li:m-0 prose-li:mb-0.5" >
269- { topicTitle && < h1 > { topicTitle } </ h1 > }
270- < div
271- id = "topic-content"
272- dangerouslySetInnerHTML = { { __html : topicHtml } }
273- />
274- </ div >
277+ < >
278+ < div className = "prose prose-quoteless prose-h1:mb-2.5 prose-h1:mt-7 prose-h1:text-balance prose-h2:mb-3 prose-h2:mt-0 prose-h3:mb-[5px] prose-h3:mt-[10px] prose-p:mb-2 prose-p:mt-0 prose-blockquote:font-normal prose-blockquote:not-italic prose-blockquote:text-gray-700 prose-li:m-0 prose-li:mb-0.5" >
279+ { topicTitle && < h1 > { topicTitle } </ h1 > }
280+ < div
281+ id = "topic-content"
282+ dangerouslySetInnerHTML = { { __html : topicHtml } }
283+ />
284+ </ div >
285+ </ >
275286 ) : (
276- < div className = "flex h-[calc(100%-38px)] flex-col items-center justify-center" >
277- < FileText className = "h-16 w-16 text-gray-300" />
278- < p className = "mt-2 text-lg font-medium text-gray-500" >
279- Empty Content
280- </ p >
281- </ div >
287+ < >
288+ { ! canSubmitContribution && (
289+ < div className = "flex h-[calc(100%-38px)] flex-col items-center justify-center" >
290+ < FileText className = "h-16 w-16 text-gray-300" />
291+ < p className = "mt-2 text-lg font-medium text-gray-500" >
292+ Empty Content
293+ </ p >
294+ </ div >
295+ ) }
296+ { canSubmitContribution && (
297+ < div className = "mx-auto flex h-[calc(100%-38px)] max-w-[400px] flex-col items-center justify-center text-center" >
298+ < HeartHandshake className = "mb-2 h-16 w-16 text-gray-300" />
299+ < p className = "text-lg font-semibold text-gray-900" >
300+ Help us write this content
301+ </ p >
302+ < p className = "mb-3 mt-2 text-sm text-gray-500" >
303+ Write a brief introduction to this topic and submit a
304+ link to a good article, podcast, video, or any other
305+ self-vetted resource that helped you understand this
306+ topic better.
307+ </ p >
308+ < a
309+ href = { contributionUrl }
310+ target = { '_blank' }
311+ className = "flex w-full items-center justify-center rounded-md bg-gray-800 p-2 text-sm text-white transition-colors hover:bg-black hover:text-white disabled:bg-green-200 disabled:text-black"
312+ >
313+ < GitHubIcon className = "mr-2 inline-block h-4 w-4 text-white" />
314+ Edit this Content
315+ </ a >
316+ </ div >
317+ ) }
318+ </ >
282319 ) }
283320
284321 { links . length > 0 && (
@@ -313,8 +350,7 @@ export function TopicDetail(props: TopicDetailProps) {
313350 < div className = "mb-12 mt-3 border-t text-sm text-gray-400" >
314351 < div className = "mb-4 mt-3" >
315352 < p className = "" >
316- Can't find what you're looking for? Try these pre-filled
317- search queries:
353+ Find more resources using these pre-filled search queries:
318354 </ p >
319355 < div className = "mt-3 flex gap-2 text-gray-700" >
320356 < a
0 commit comments