| 24 | }; |
| 25 | |
| 26 | const handler = async ( |
| 27 | req: NextApiRequest, |
| 28 | res: NextApiResponse, |
| 29 | ): Promise<void> => { |
| 30 | if (req.method !== 'GET') { |
| 31 | res.status(405).send('Method not allowed'); |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | try { |
| 36 | const data = await gqlClient.request<SourceDirectoryData>( |
| 37 | SOURCE_DIRECTORY_QUERY, |
| 38 | ); |
| 39 | |
| 40 | const markdown = `--- |
| 41 | title: Sources Directory |
| 42 | url: ${appOrigin}/sources |
| 43 | description: 1,300+ curated content sources on daily.dev |
| 44 | --- |
| 45 | |
| 46 | > ## Documentation Index |
| 47 | > Fetch the complete documentation index at: ${llmsTxtUrl} |
| 48 | > Use this file to discover all available pages before exploring further. |
| 49 | |
| 50 | # Sources Directory |
| 51 | |
| 52 | > 1,300+ curated content sources on daily.dev |
| 53 | |
| 54 | Explore the top sources for developer content. Find trending blogs, publications, YouTube channels and more from our trusted developer network. |
| 55 | |
| 56 | ## Trending Sources |
| 57 | |
| 58 | ${data.trendingSources.map(formatSource).join('\n')} |
| 59 | |
| 60 | ## Popular Sources |
| 61 | |
| 62 | ${data.popularSources.map(formatSource).join('\n')} |
| 63 | |
| 64 | ## Recently Added Sources |
| 65 | |
| 66 | ${data.mostRecentSources.map(formatSource).join('\n')} |
| 67 | |
| 68 | ## Top Video Sources |
| 69 | |
| 70 | ${data.topVideoSources.map(formatSource).join('\n')} |
| 71 | |
| 72 | --- |
| 73 | |
| 74 | [View all sources on daily.dev](/sources) |
| 75 | `; |
| 76 | |
| 77 | res.setHeader('Content-Type', 'text/markdown; charset=utf-8'); |
| 78 | res.setHeader( |
| 79 | 'Cache-Control', |
| 80 | 'public, s-maxage=86400, stale-while-revalidate=604800', |
| 81 | ); |
| 82 | res.setHeader('X-Robots-Tag', 'noindex, nofollow'); |
| 83 | res.status(200).send(markdown); |