GeezerVison is showing github.com — Update tutorial content and enhance Markdown rendering · aidrivencoder/master-git-github@ba1e79c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: package-lock.json +4Lines changed: 4 additions & 0 deletions Collapse file Copy file name to clipboardExpand all lines: package.json +11-7Lines changed: 11 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | "@headlessui/react": "^1.7.17", | 13 | 13 | "@heroicons/react": "^2.0.18", | 14 | 14 | "@mdx-js/react": "^3.0.0", | 15 | | - "@uiw/react-markdown-preview": "^5.0.3", | 16 | | - "@uiw/react-md-editor": "^4.0.1", | 17 | | - "prismjs": "^1.29.0", | 18 | 15 | "@stripe/stripe-js": "^2.1.7", | 19 | 16 | "@tanstack/react-query": "^4.36.1", | | 17 | + "@uiw/react-markdown-preview": "^5.0.3", | | 18 | + "@uiw/react-md-editor": "^4.0.1", | 20 | 19 | "firebase": "^9.23.0", | 21 | 20 | "firebase-admin": "^11.11.0", | 22 | 21 | "firebase-tools": "^12.7.0", | 23 | 22 | "next": "13.4.19", | | 23 | + "prismjs": "^1.29.0", | 24 | 24 | "react": "18.2.0", | 25 | 25 | "react-dom": "18.2.0", | 26 | | - "react-syntax-highlighter": "^15.5.0", | 27 | 26 | "react-error-boundary": "^4.0.11", | | 27 | + "react-markdown": "^9.0.1", | | 28 | + "react-syntax-highlighter": "^15.5.0", | | 29 | + "rehype-prism-plus": "^2.0.0", | | 30 | + "rehype-raw": "^7.0.0", | | 31 | + "remark-gfm": "^4.0.0", | 28 | 32 | "stripe": "^13.9.0", | 29 | 33 | "zustand": "^4.4.3" | 30 | 34 | }, | 31 | 35 | "devDependencies": { | 32 | 36 | "@babel/core": "^7.23.0", | 33 | 37 | "@babel/plugin-proposal-class-properties": "^7.18.6", | 34 | | - "@next/bundle-analyzer": "^13.5.4", | 35 | 38 | "@babel/plugin-proposal-private-methods": "^7.18.6", | 36 | 39 | "@babel/preset-env": "^7.22.20", | | 40 | + "@next/bundle-analyzer": "^13.5.4", | 37 | 41 | "@types/node": "^20.8.4", | 38 | 42 | "@types/prismjs": "^1.26.3", | 39 | | - "@types/react-syntax-highlighter": "^15.5.11", | 40 | 43 | "@types/react": "18.2.0", | 41 | 44 | "@types/react-dom": "18.2.0", | | 45 | + "@types/react-syntax-highlighter": "^15.5.11", | 42 | 46 | "autoprefixer": "^10.4.16", | 43 | 47 | "babel-loader": "^9.1.3", | 44 | 48 | "eslint": "^8.51.0", | 45 | 49 | "eslint-config-next": "13.4.19", | 46 | 50 | "postcss": "^8.4.31", | 47 | | - "tailwindcss": "^3.3.3", | 48 | 51 | "raw-loader": "^4.0.2", | | 52 | + "tailwindcss": "^3.3.3", | 49 | 53 | "typescript": "^5.2.2" | 50 | 54 | } | 51 | 55 | } |
Collapse file Copy file name to clipboardExpand all lines: src/app/tutorials/[id]/page.tsx +27-4Lines changed: 27 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,11 +12,34 @@ interface TutorialPageProps { | 12 | 12 | } | 13 | 13 |
| 14 | 14 | function LoadingState() { | | 15 | + const [loadingText, setLoadingText] = useState('Initializing Firebase...') | | 16 | + | | 17 | + useEffect(() => { | | 18 | + const loadingStates = [ | | 19 | + { text: 'Initializing Firebase...', delay: 0 }, | | 20 | + { text: 'Connecting to database...', delay: 1000 }, | | 21 | + { text: 'Fetching tutorial content...', delay: 2000 }, | | 22 | + { text: 'Preparing content for display...', delay: 3000 } | | 23 | + ] | | 24 | + | | 25 | + loadingStates.forEach(({ text, delay }) => { | | 26 | + const timer = setTimeout(() => { | | 27 | + setLoadingText(text) | | 28 | + }, delay) | | 29 | + return () => clearTimeout(timer) | | 30 | + }) | | 31 | + }, []) | | 32 | + | 15 | 33 | return ( | 16 | 34 | <div className="min-h-screen flex items-center justify-center bg-white dark:bg-gray-900"> | 17 | 35 | <div className="text-center space-y-4"> | 18 | 36 | <LoadingSpinner size="lg" /> | 19 | | - <p className="text-gray-600 dark:text-gray-400">Loading tutorial content...</p> | | 37 | + <div className="space-y-2"> | | 38 | + <p className="text-gray-600 dark:text-gray-400">{loadingText}</p> | | 39 | + <p className="text-sm text-gray-500 dark:text-gray-500"> | | 40 | + This may take a few moments... | | 41 | + </p> | | 42 | + </div> | 20 | 43 | </div> | 21 | 44 | </div> | 22 | 45 | ) | @@ -89,12 +112,12 @@ export default function TutorialPage({ params }: TutorialPageProps) { | 89 | 112 | try { | 90 | 113 | setLoading(true) | 91 | 114 | setError(null) | 92 | | - console.log('Fetching tutorial:', params.id) // Debug log | | 115 | + console.log('Fetching tutorial:', params.id) | 93 | 116 | const fetchedTutorial = await getTutorialById(params.id) | 94 | | - console.log('Fetched tutorial:', fetchedTutorial) // Debug log | | 117 | + console.log('Fetched tutorial:', fetchedTutorial) | 95 | 118 |
| 96 | 119 | if (!fetchedTutorial) { | 97 | | - console.log('Tutorial not found') // Debug log | | 120 | + console.log('Tutorial not found') | 98 | 121 | setError('Tutorial not found') | 99 | 122 | return | 100 | 123 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/components/tutorials/MarkdownContent.tsx +29-25Lines changed: 29 additions & 25 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import dynamic from 'next/dynamic' | 2 | | -import '@uiw/react-markdown-preview/markdown.css' | 3 | | -import { CodeBlock } from './CodeBlock' | 4 | | - | 5 | | -const MarkdownPreview = dynamic( | 6 | | - () => import('@uiw/react-markdown-preview'), | 7 | | - { ssr: false } | 8 | | -) | | 1 | +import ReactMarkdown from 'react-markdown' | | 2 | +import remarkGfm from 'remark-gfm' | | 3 | +import rehypeRaw from 'rehype-raw' | | 4 | +import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter' | | 5 | +import { tomorrow } from 'react-syntax-highlighter/dist/cjs/styles/prism' | 9 | 6 |
| 10 | 7 | interface MarkdownContentProps { | 11 | 8 | content: string | @@ -21,31 +18,36 @@ type CodeComponentProps = { | 21 | 18 | export function MarkdownContent({ content }: MarkdownContentProps) { | 22 | 19 | return ( | 23 | 20 | <div className="prose prose-lg dark:prose-invert max-w-none space-y-6"> | 24 | | - <MarkdownPreview | 25 | | - source={content} | 26 | | - style={{ | 27 | | - backgroundColor: 'transparent', | 28 | | - padding: 0, | 29 | | - }} | | 21 | + <ReactMarkdown | | 22 | + remarkPlugins={[remarkGfm]} | | 23 | + rehypePlugins={[rehypeRaw]} | 30 | 24 | components={{ | 31 | | - code: ({ inline, children = '', className }: CodeComponentProps) => { | | 25 | + code: ({ inline, className, children }: CodeComponentProps) => { | 32 | 26 | if (inline) { | 33 | 27 | return ( | 34 | 28 | <code className="bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm"> | 35 | | - {children} | | 29 | + {String(children)} | 36 | 30 | </code> | 37 | 31 | ) | 38 | 32 | } | 39 | | - const language = className?.replace('language-', '') || 'text' | 40 | | - const codeContent = Array.isArray(children) | 41 | | - ? children.join('') | 42 | | - : String(children).replace(/\n$/, '') | | 33 | + | | 34 | + const match = /language-(\w+)/.exec(className || '') | | 35 | + const language = match ? match[1] : '' | | 36 | + | 43 | 37 | return ( | 44 | | - <div className="my-6"> | 45 | | - <CodeBlock | 46 | | - code={codeContent} | | 38 | + <div className="rounded-lg overflow-hidden my-4"> | | 39 | + <SyntaxHighlighter | 47 | 40 | language={language} | 48 | | - /> | | 41 | + style={tomorrow} | | 42 | + customStyle={{ | | 43 | + margin: 0, | | 44 | + padding: '1rem', | | 45 | + backgroundColor: '#1a1a1a', | | 46 | + borderRadius: '0.5rem' | | 47 | + }} | | 48 | + > | | 49 | + {String(children).trim()} | | 50 | + </SyntaxHighlighter> | 49 | 51 | </div> | 50 | 52 | ) | 51 | 53 | }, | @@ -71,7 +73,9 @@ export function MarkdownContent({ content }: MarkdownContentProps) { | 71 | 73 | <li className="ml-4">{children}</li> | 72 | 74 | ) | 73 | 75 | }} | 74 | | - /> | | 76 | + > | | 77 | + {content} | | 78 | + </ReactMarkdown> | 75 | 79 | </div> | 76 | 80 | ) | 77 | 81 | } |
Collapse file Copy file name to clipboardExpand all lines: src/lib/firebase/services/initializeTutorials.ts +13-63Lines changed: 13 additions & 63 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,8 +17,7 @@ const tutorials = [ | 17 | 17 | { | 18 | 18 | id: 'init', | 19 | 19 | title: 'Initializing a Git Repository', | 20 | | - content: ` | 21 | | -# Creating Your First Git Repository | | 20 | + content: `# Creating Your First Git Repository | 22 | 21 |
| 23 | 22 | Git is a distributed version control system that helps you track changes in your code. Let's start with the basics. | 24 | 23 |
| @@ -30,8 +29,7 @@ To start tracking your project with Git, you need to initialize a repository: | 30 | 29 | git init | 31 | 30 | \`\`\` | 32 | 31 |
| 33 | | -This command creates a new Git repository in your current directory. | 34 | | - `, | | 32 | +This command creates a new Git repository in your current directory.`, | 35 | 33 | type: 'interactive', | 36 | 34 | gitVisualization: { | 37 | 35 | type: 'commit', | @@ -49,8 +47,7 @@ This command creates a new Git repository in your current directory. | 49 | 47 | { | 50 | 48 | id: 'staging', | 51 | 49 | title: 'Staging Changes', | 52 | | - content: ` | 53 | | -# Understanding the Staging Area | | 50 | + content: `# Understanding the Staging Area | 54 | 51 |
| 55 | 52 | Git uses a staging area (also called the index) to track which changes will be included in the next commit. | 56 | 53 |
| @@ -61,8 +58,7 @@ To stage files: | 61 | 58 | \`\`\`bash | 62 | 59 | git add <filename> # Stage a specific file | 63 | 60 | git add . # Stage all changes | 64 | | -\`\`\` | 65 | | - `, | | 61 | +\`\`\``, | 66 | 62 | type: 'interactive', | 67 | 63 | gitVisualization: { | 68 | 64 | type: 'commit', | @@ -108,60 +104,6 @@ git add . # Stage all changes | 108 | 104 | ], | 109 | 105 | createdAt: Timestamp.now(), | 110 | 106 | updatedAt: Timestamp.now(), | 111 | | - }, | 112 | | - { | 113 | | - id: 'branching-basics', | 114 | | - title: 'Git Branching', | 115 | | - description: 'Learn how to work with branches in Git', | 116 | | - difficulty: 'intermediate', | 117 | | - estimatedTime: 45, | 118 | | - isPremium: false, | 119 | | - steps: [ | 120 | | - { | 121 | | - id: 'create-branch', | 122 | | - title: 'Creating a Branch', | 123 | | - content: ` | 124 | | -# Working with Git Branches | 125 | | -
| 126 | | -Branches allow you to develop features, fix bugs, or experiment with new ideas in isolation. | 127 | | -
| 128 | | -## Create a New Branch | 129 | | -
| 130 | | -To create and switch to a new branch: | 131 | | -
| 132 | | -\`\`\`bash | 133 | | -git checkout -b feature/new-feature | 134 | | -\`\`\` | 135 | | - `, | 136 | | - type: 'interactive', | 137 | | - gitVisualization: { | 138 | | - type: 'branch', | 139 | | - nodes: [ | 140 | | - { | 141 | | - id: 'main', | 142 | | - type: 'branch', | 143 | | - label: 'main', | 144 | | - position: { x: 100, y: 100 } | 145 | | - }, | 146 | | - { | 147 | | - id: 'feature', | 148 | | - type: 'branch', | 149 | | - label: 'feature', | 150 | | - position: { x: 250, y: 50 } | 151 | | - } | 152 | | - ], | 153 | | - edges: [ | 154 | | - { | 155 | | - source: 'main', | 156 | | - target: 'feature', | 157 | | - type: 'branch' | 158 | | - } | 159 | | - ] | 160 | | - } | 161 | | - } | 162 | | - ], | 163 | | - createdAt: Timestamp.now(), | 164 | | - updatedAt: Timestamp.now(), | 165 | 107 | } | 166 | 108 | ] | 167 | 109 |
| @@ -170,7 +112,15 @@ export async function initializeTutorials() { | 170 | 112 | const tutorialsRef = collection(db, TUTORIALS_COLLECTION) | 171 | 113 |
| 172 | 114 | for (const tutorial of tutorials) { | 173 | | - await setDoc(doc(tutorialsRef, tutorial.id), tutorial) | | 115 | + // Process the tutorial content to ensure proper string handling | | 116 | + const processedTutorial = { | | 117 | + ...tutorial, | | 118 | + steps: tutorial.steps.map(step => ({ | | 119 | + ...step, | | 120 | + content: step.content.trim() | | 121 | + })) | | 122 | + } | | 123 | + await setDoc(doc(tutorialsRef, tutorial.id), processedTutorial) | 174 | 124 | } | 175 | 125 |
| 176 | 126 | Logger.info('Tutorials initialized successfully', 'TutorialService') | |
Collapse file Copy file name to clipboardExpand all lines: src/lib/firebase/services/tutorials.ts +31-3Lines changed: 31 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,7 +16,17 @@ export async function getTutorials(): Promise<Tutorial[]> { | 16 | 16 | try { | 17 | 17 | const tutorialsRef = collection(db, TUTORIALS_COLLECTION) | 18 | 18 | const snapshot = await getDocs(tutorialsRef) | 19 | | - return snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() } as Tutorial)) | | 19 | + return snapshot.docs.map(doc => { | | 20 | + const data = doc.data() | | 21 | + return { | | 22 | + id: doc.id, | | 23 | + ...data, | | 24 | + steps: data.steps.map((step: any) => ({ | | 25 | + ...step, | | 26 | + content: step.content?.toString() || '' | | 27 | + })) | | 28 | + } as Tutorial | | 29 | + }) | 20 | 30 | } catch (error) { | 21 | 31 | Logger.error('Failed to fetch tutorials', 'TutorialService', error) | 22 | 32 | return [] | @@ -28,7 +38,17 @@ export async function getPublicTutorials(): Promise<Tutorial[]> { | 28 | 38 | const tutorialsRef = collection(db, TUTORIALS_COLLECTION) | 29 | 39 | const q = query(tutorialsRef, where('isPremium', '==', false)) | 30 | 40 | const snapshot = await getDocs(q) | 31 | | - return snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() } as Tutorial)) | | 41 | + return snapshot.docs.map(doc => { | | 42 | + const data = doc.data() | | 43 | + return { | | 44 | + id: doc.id, | | 45 | + ...data, | | 46 | + steps: data.steps.map((step: any) => ({ | | 47 | + ...step, | | 48 | + content: step.content?.toString() || '' | | 49 | + })) | | 50 | + } as Tutorial | | 51 | + }) | 32 | 52 | } catch (error) { | 33 | 53 | Logger.error('Failed to fetch public tutorials', 'TutorialService', error) | 34 | 54 | return [] | @@ -44,7 +64,15 @@ export async function getTutorialById(id: string): Promise<Tutorial | null> { | 44 | 64 | return null | 45 | 65 | } | 46 | 66 |
| 47 | | - return { id: tutorialDoc.id, ...tutorialDoc.data() } as Tutorial | | 67 | + const data = tutorialDoc.data() | | 68 | + return { | | 69 | + id: tutorialDoc.id, | | 70 | + ...data, | | 71 | + steps: data.steps.map((step: any) => ({ | | 72 | + ...step, | | 73 | + content: step.content?.toString() || '' | | 74 | + })) | | 75 | + } as Tutorial | 48 | 76 | } catch (error) { | 49 | 77 | Logger.error('Failed to fetch tutorial', 'TutorialService', error) | 50 | 78 | return null | |
|