-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
237 lines (220 loc) Β· 11.7 KB
/
page.tsx
File metadata and controls
237 lines (220 loc) Β· 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
export default function Home() {
return (
<main style={{ maxWidth: '1200px', margin: '0 auto', padding: '2rem', fontFamily: 'system-ui, -apple-system, sans-serif' }}>
<div>
<h1 style={{ fontSize: '3rem', marginBottom: '1rem', color: '#333' }}>React Github Permalink</h1>
<p style={{ fontSize: '1.5rem', marginBottom: '2rem', color: '#666' }}>
Display Github permalinks as codeblocks and Github issue links in your React applications.
</p>
{/* Screenshots */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '1rem', marginBottom: '3rem' }}>
<img src="/screenshot-permalink-dark.png" alt="Github Permalink in dark mode" style={{ width: '100%', borderRadius: '8px', boxShadow: '0 4px 8px rgba(0,0,0,0.1)' }} />
<img src="/screenshot-permalink-light.png" alt="Github Permalink in light mode" style={{ width: '100%', borderRadius: '8px', boxShadow: '0 4px 8px rgba(0,0,0,0.1)' }} />
</div>
{/* Installation */}
<section style={{ marginBottom: '3rem' }}>
<h2 style={{ fontSize: '2rem', marginBottom: '1rem', color: '#333' }}>π¦ Installation</h2>
<div style={{ backgroundColor: '#f6f8fa', padding: '1rem', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<code style={{ fontSize: '1.1rem' }}>npm install react-github-permalink</code>
</div>
<p style={{ marginTop: '0.5rem', color: '#666' }}>
Also install the peer dependency: <code style={{ backgroundColor: '#f6f8fa', padding: '0.2rem 0.4rem', borderRadius: '4px' }}>npm install react</code>
</p>
</section>
{/* RSC Instructions */}
<section style={{ marginBottom: '3rem' }}>
<h2 style={{ fontSize: '2rem', marginBottom: '1rem', color: '#333' }}>βοΈ React Server Components (RSC)</h2>
<p style={{ marginBottom: '1rem', color: '#666' }}>
This package is compatible with Next.js 13+ and offers three variants of each component:
</p>
<ul style={{ listStyle: 'disc', paddingLeft: '2rem', marginBottom: '1.5rem', color: '#666' }}>
<li><strong>GithubPermalink/GithubIssueLink</strong> - Client component that fetches data in useEffect</li>
<li><strong>GithubPermalinkBase/GithubIssueLinkBase</strong> - Base component with no data fetching</li>
<li><strong>GithubPermalinkRsc/GithubIssueLinkRsc</strong> - React Server Component</li>
</ul>
<h3 style={{ fontSize: '1.5rem', marginBottom: '1rem', color: '#333' }}>Client Component Usage</h3>
<div style={{ backgroundColor: '#f6f8fa', padding: '1rem', borderRadius: '8px', border: '1px solid #d0d7de', marginBottom: '1.5rem' }}>
<pre style={{ margin: 0, overflow: 'auto' }}><code>{`import { GithubPermalink } from 'react-github-permalink';
import "react-github-permalink/dist/github-permalink.css";
export function MyApp() {
return (
<GithubPermalink
permalink="https://github.com/dwjohnston/react-github-permalink/blob/main/sample_files/sample1.go#L1-L5"
/>
);
}`}</code></pre>
</div>
<h3 style={{ fontSize: '1.5rem', marginBottom: '1rem', color: '#333' }}>RSC Usage</h3>
<div style={{ backgroundColor: '#f6f8fa', padding: '1rem', borderRadius: '8px', border: '1px solid #d0d7de', marginBottom: '1.5rem' }}>
<pre style={{ margin: 0, overflow: 'auto' }}><code>{`import { GithubPermalinkRsc } from 'react-github-permalink/dist/rsc';
import "react-github-permalink/dist/github-permalink.css";
export function MyApp() {
return (
<GithubPermalinkRsc
permalink="https://github.com/dwjohnston/react-github-permalink/blob/main/sample_files/sample1.go#L1-L5"
/>
);
}`}</code></pre>
</div>
<h3 style={{ fontSize: '1.5rem', marginBottom: '1rem', color: '#333' }}>Base Component with Custom Data</h3>
<div style={{ backgroundColor: '#f6f8fa', padding: '1rem', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<pre style={{ margin: 0, overflow: 'auto' }}><code>{`import { GithubPermalinkBase } from 'react-github-permalink';
import "react-github-permalink/dist/github-permalink.css";
export function MyApp() {
return (
<GithubPermalinkBase
permalink="https://github.com/dwjohnston/react-github-permalink/blob/main/sample_files/sample1.go#L1-L5"
data={{
lines: [
"package main",
"import \\"fmt\\"",
"func main() {",
" fmt.Println(\\"hello world\\")",
"}"
],
lineFrom: 1,
lineTo: 5,
commit: "5b15aa07e60af4e317086f391b28cadf9aae8e1b",
path: "sample_files/sample1.go",
owner: "dwjohnston",
repo: "react-github-permalink",
status: "ok"
}}
/>
);
}`}</code></pre>
</div>
</section>
{/* Demo Usage */}
<section style={{ marginBottom: '3rem' }}>
<h2 style={{ fontSize: '2rem', marginBottom: '1rem', color: '#333' }}>π Demo Usage</h2>
<p style={{ marginBottom: '1rem', color: '#666' }}>
Try out the components in this interactive CodeSandbox demo:
</p>
<a
href="https://codesandbox.io/s/exciting-nova-js5zlk?file=/src/App.js"
target="_blank"
rel="noopener noreferrer"
style={{
display: 'inline-block',
backgroundColor: '#0969da',
color: 'white',
padding: '0.75rem 1.5rem',
borderRadius: '6px',
textDecoration: 'none',
fontWeight: 'bold',
marginBottom: '1.5rem'
}}
>
π Open Interactive Demo
</a>
<h3 style={{ fontSize: '1.5rem', marginBottom: '1rem', color: '#333' }}>Issue Links</h3>
<p style={{ marginBottom: '1rem', color: '#666' }}>
You can also display GitHub issue links with status and reactions:
</p>
<div style={{ backgroundColor: '#f6f8fa', padding: '1rem', borderRadius: '8px', border: '1px solid #d0d7de', marginBottom: '1rem' }}>
<pre style={{ margin: 0, overflow: 'auto' }}><code>{`import { GithubIssueLink } from 'react-github-permalink';
// Block variant (default)
<GithubIssueLink issueLink="https://github.com/dwjohnston/react-github-permalink/issues/2" />
// Inline variant
<GithubIssueLink
issueLink="https://github.com/dwjohnston/react-github-permalink/issues/2"
variant="inline"
/>`}</code></pre>
</div>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '1rem' }}>
<img src="/screenshot-issuelink-dark.png" alt="Issue Link in dark mode" style={{ width: '100%', borderRadius: '8px', boxShadow: '0 4px 8px rgba(0,0,0,0.1)' }} />
<img src="/screenshot-issuelink-light.png" alt="Issue Link in light mode" style={{ width: '100%', borderRadius: '8px', boxShadow: '0 4px 8px rgba(0,0,0,0.1)' }} />
</div>
</section>
{/* Links */}
<section style={{ marginBottom: '3rem' }}>
<h2 style={{ fontSize: '2rem', marginBottom: '1rem', color: '#333' }}>π Resources</h2>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '1rem' }}>
<a
href="/storybook-static/index.html"
style={{
display: 'inline-block',
backgroundColor: '#ff4785',
color: 'white',
padding: '0.75rem 1.5rem',
borderRadius: '6px',
textDecoration: 'none',
fontWeight: 'bold'
}}
>
π View Storybook
</a>
<a
href="https://github.com/dwjohnston/ultimate-react-package-template"
target="_blank"
rel="noopener noreferrer"
style={{
display: 'inline-block',
backgroundColor: '#21262d',
color: 'white',
padding: '0.75rem 1.5rem',
borderRadius: '6px',
textDecoration: 'none',
fontWeight: 'bold'
}}
>
π οΈ Package Template
</a>
</div>
</section>
{/* Features */}
<section style={{ marginBottom: '3rem' }}>
<h2 style={{ fontSize: '2rem', marginBottom: '1rem', color: '#333' }}>β¨ Features</h2>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(250px, 1fr))', gap: '1rem' }}>
<div style={{ padding: '1.5rem', backgroundColor: '#f6f8fa', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<h3 style={{ fontSize: '1.25rem', marginBottom: '0.5rem', color: '#333' }}>π¨ Syntax Highlighting</h3>
<p style={{ color: '#666', margin: 0 }}>Beautiful code highlighting with automatic language detection</p>
</div>
<div style={{ padding: '1.5rem', backgroundColor: '#f6f8fa', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<h3 style={{ fontSize: '1.25rem', marginBottom: '0.5rem', color: '#333' }}>π Dark Mode</h3>
<p style={{ color: '#666', margin: 0 }}>Automatic dark/light mode support based on user preference</p>
</div>
<div style={{ padding: '1.5rem', backgroundColor: '#f6f8fa', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<h3 style={{ fontSize: '1.25rem', marginBottom: '0.5rem', color: '#333' }}>π± Responsive</h3>
<p style={{ color: '#666', margin: 0 }}>Mobile-friendly design that works on all screen sizes</p>
</div>
<div style={{ padding: '1.5rem', backgroundColor: '#f6f8fa', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<h3 style={{ fontSize: '1.25rem', marginBottom: '0.5rem', color: '#333' }}>β‘ RSC Compatible</h3>
<p style={{ color: '#666', margin: 0 }}>Full support for React Server Components in Next.js 13+</p>
</div>
<div style={{ padding: '1.5rem', backgroundColor: '#f6f8fa', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<h3 style={{ fontSize: '1.25rem', marginBottom: '0.5rem', color: '#333' }}>π Copy to Clipboard</h3>
<p style={{ color: '#666', margin: 0 }}>One-click copying of code snippets</p>
</div>
<div style={{ padding: '1.5rem', backgroundColor: '#f6f8fa', borderRadius: '8px', border: '1px solid #d0d7de' }}>
<h3 style={{ fontSize: '1.25rem', marginBottom: '0.5rem', color: '#333' }}>π Issue Links</h3>
<p style={{ color: '#666', margin: 0 }}>Display GitHub issues with status, reactions, and metadata</p>
</div>
</div>
</section>
{/* Footer */}
<footer style={{ marginTop: '4rem', paddingTop: '2rem', borderTop: '1px solid #d0d7de', textAlign: 'center', color: '#666' }}>
<p>
Built with β€οΈ by{' '}
<a href="https://github.com/dwjohnston" target="_blank" rel="noopener noreferrer" style={{ color: '#0969da' }}>
@dwjohnston
</a>
</p>
<p style={{ marginTop: '0.5rem' }}>
Recommended: Use the{' '}
<a
href="https://marketplace.visualstudio.com/items?itemName=hogashi.vscode-copy-github-permalink"
target="_blank"
rel="noopener noreferrer"
style={{ color: '#0969da' }}
>
vscode-copy-github-permalink
</a>
{' '}plugin for easy permalink generation in VS Code.
</p>
</footer>
</div>
</main>
);
}