GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update tutorial content and enhance Markdown rendering · aidrivencoder/master-git-github@ba1e79c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • package-lock.json
  • package.json
  • src
    • app/tutorials/[id]
      • page.tsx
    • components/tutorials
      • MarkdownContent.tsx
    • lib/firebase/services
      • initializeTutorials.ts
      • tutorials.ts
    • styles
      • prism-theme.css
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎package-lock.json‎

Copy file name to clipboardExpand all lines: package-lock.json
+4Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,44 @@
1212
"@headlessui/react": "^1.7.17",
1313
"@heroicons/react": "^2.0.18",
1414
"@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",
1815
"@stripe/stripe-js": "^2.1.7",
1916
"@tanstack/react-query": "^4.36.1",
17+
"@uiw/react-markdown-preview": "^5.0.3",
18+
"@uiw/react-md-editor": "^4.0.1",
2019
"firebase": "^9.23.0",
2120
"firebase-admin": "^11.11.0",
2221
"firebase-tools": "^12.7.0",
2322
"next": "13.4.19",
23+
"prismjs": "^1.29.0",
2424
"react": "18.2.0",
2525
"react-dom": "18.2.0",
26-
"react-syntax-highlighter": "^15.5.0",
2726
"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",
2832
"stripe": "^13.9.0",
2933
"zustand": "^4.4.3"
3034
},
3135
"devDependencies": {
3236
"@babel/core": "^7.23.0",
3337
"@babel/plugin-proposal-class-properties": "^7.18.6",
34-
"@next/bundle-analyzer": "^13.5.4",
3538
"@babel/plugin-proposal-private-methods": "^7.18.6",
3639
"@babel/preset-env": "^7.22.20",
40+
"@next/bundle-analyzer": "^13.5.4",
3741
"@types/node": "^20.8.4",
3842
"@types/prismjs": "^1.26.3",
39-
"@types/react-syntax-highlighter": "^15.5.11",
4043
"@types/react": "18.2.0",
4144
"@types/react-dom": "18.2.0",
45+
"@types/react-syntax-highlighter": "^15.5.11",
4246
"autoprefixer": "^10.4.16",
4347
"babel-loader": "^9.1.3",
4448
"eslint": "^8.51.0",
4549
"eslint-config-next": "13.4.19",
4650
"postcss": "^8.4.31",
47-
"tailwindcss": "^3.3.3",
4851
"raw-loader": "^4.0.2",
52+
"tailwindcss": "^3.3.3",
4953
"typescript": "^5.2.2"
5054
}
5155
}
Collapse file

‎src/app/tutorials/[id]/page.tsx‎

Copy file name to clipboardExpand all lines: src/app/tutorials/[id]/page.tsx
+27-4Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,34 @@ interface TutorialPageProps {
1212
}
1313

1414
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+
1533
return (
1634
<div className="min-h-screen flex items-center justify-center bg-white dark:bg-gray-900">
1735
<div className="text-center space-y-4">
1836
<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>
2043
</div>
2144
</div>
2245
)
@@ -89,12 +112,12 @@ export default function TutorialPage({ params }: TutorialPageProps) {
89112
try {
90113
setLoading(true)
91114
setError(null)
92-
console.log('Fetching tutorial:', params.id) // Debug log
115+
console.log('Fetching tutorial:', params.id)
93116
const fetchedTutorial = await getTutorialById(params.id)
94-
console.log('Fetched tutorial:', fetchedTutorial) // Debug log
117+
console.log('Fetched tutorial:', fetchedTutorial)
95118

96119
if (!fetchedTutorial) {
97-
console.log('Tutorial not found') // Debug log
120+
console.log('Tutorial not found')
98121
setError('Tutorial not found')
99122
return
100123
}
Collapse file

‎src/components/tutorials/MarkdownContent.tsx‎

Copy file name to clipboardExpand all lines: src/components/tutorials/MarkdownContent.tsx
+29-25Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
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'
96

107
interface MarkdownContentProps {
118
content: string
@@ -21,31 +18,36 @@ type CodeComponentProps = {
2118
export function MarkdownContent({ content }: MarkdownContentProps) {
2219
return (
2320
<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]}
3024
components={{
31-
code: ({ inline, children = '', className }: CodeComponentProps) => {
25+
code: ({ inline, className, children }: CodeComponentProps) => {
3226
if (inline) {
3327
return (
3428
<code className="bg-gray-100 dark:bg-gray-800 px-1.5 py-0.5 rounded text-sm">
35-
{children}
29+
{String(children)}
3630
</code>
3731
)
3832
}
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+
4337
return (
44-
<div className="my-6">
45-
<CodeBlock
46-
code={codeContent}
38+
<div className="rounded-lg overflow-hidden my-4">
39+
<SyntaxHighlighter
4740
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>
4951
</div>
5052
)
5153
},
@@ -71,7 +73,9 @@ export function MarkdownContent({ content }: MarkdownContentProps) {
7173
<li className="ml-4">{children}</li>
7274
)
7375
}}
74-
/>
76+
>
77+
{content}
78+
</ReactMarkdown>
7579
</div>
7680
)
7781
}
Collapse file

‎src/lib/firebase/services/initializeTutorials.ts‎

Copy file name to clipboardExpand all lines: src/lib/firebase/services/initializeTutorials.ts
+13-63Lines changed: 13 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const tutorials = [
1717
{
1818
id: 'init',
1919
title: 'Initializing a Git Repository',
20-
content: `
21-
# Creating Your First Git Repository
20+
content: `# Creating Your First Git Repository
2221
2322
Git is a distributed version control system that helps you track changes in your code. Let's start with the basics.
2423
@@ -30,8 +29,7 @@ To start tracking your project with Git, you need to initialize a repository:
3029
git init
3130
\`\`\`
3231
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.`,
3533
type: 'interactive',
3634
gitVisualization: {
3735
type: 'commit',
@@ -49,8 +47,7 @@ This command creates a new Git repository in your current directory.
4947
{
5048
id: 'staging',
5149
title: 'Staging Changes',
52-
content: `
53-
# Understanding the Staging Area
50+
content: `# Understanding the Staging Area
5451
5552
Git uses a staging area (also called the index) to track which changes will be included in the next commit.
5653
@@ -61,8 +58,7 @@ To stage files:
6158
\`\`\`bash
6259
git add <filename> # Stage a specific file
6360
git add . # Stage all changes
64-
\`\`\`
65-
`,
61+
\`\`\``,
6662
type: 'interactive',
6763
gitVisualization: {
6864
type: 'commit',
@@ -108,60 +104,6 @@ git add . # Stage all changes
108104
],
109105
createdAt: Timestamp.now(),
110106
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(),
165107
}
166108
]
167109

@@ -170,7 +112,15 @@ export async function initializeTutorials() {
170112
const tutorialsRef = collection(db, TUTORIALS_COLLECTION)
171113

172114
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)
174124
}
175125

176126
Logger.info('Tutorials initialized successfully', 'TutorialService')
Collapse file

‎src/lib/firebase/services/tutorials.ts‎

Copy file name to clipboardExpand all lines: src/lib/firebase/services/tutorials.ts
+31-3Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ export async function getTutorials(): Promise<Tutorial[]> {
1616
try {
1717
const tutorialsRef = collection(db, TUTORIALS_COLLECTION)
1818
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+
})
2030
} catch (error) {
2131
Logger.error('Failed to fetch tutorials', 'TutorialService', error)
2232
return []
@@ -28,7 +38,17 @@ export async function getPublicTutorials(): Promise<Tutorial[]> {
2838
const tutorialsRef = collection(db, TUTORIALS_COLLECTION)
2939
const q = query(tutorialsRef, where('isPremium', '==', false))
3040
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+
})
3252
} catch (error) {
3353
Logger.error('Failed to fetch public tutorials', 'TutorialService', error)
3454
return []
@@ -44,7 +64,15 @@ export async function getTutorialById(id: string): Promise<Tutorial | null> {
4464
return null
4565
}
4666

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
4876
} catch (error) {
4977
Logger.error('Failed to fetch tutorial', 'TutorialService', error)
5078
return null

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.