Skip to content

Commit bc163cf

Browse files
committed
Fully customized doc pages
1 parent a2546e3 commit bc163cf

File tree

24 files changed

+208
-1508
lines changed

24 files changed

+208
-1508
lines changed

apps/docs/src/app/docs/architecture-guide/page.md

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Basic Usage
3+
nextjs:
4+
metadata:
5+
title: Basic Usage
6+
description: How to quickly embed a PDF.
7+
---
8+
9+
The library uses a headless philosophy and allows you to more easily customize the
10+
embedding of your PDFs. You can draw your own canvas and then render to it by providing it's ref to
11+
the `usePdf` hook.
12+
13+
---
14+
15+
## Basic Code
16+
17+
Here is a basic implementation of our library. It also has pagination built-in,
18+
using simple back/next buttons. You can extend this however you want, you just need to set the page
19+
variable that's passed to the hook.
20+
21+
```typescript
22+
import { useState, useRef } from 'react';
23+
import { usePdf } from '@mikecousins/react-pdf';
24+
25+
const MyPdfViewer = () => {
26+
const [page, setPage] = useState(1);
27+
const canvasRef = useRef(null);
28+
29+
const { pdfDocument, pdfPage } = usePdf({
30+
file: 'test.pdf',
31+
page,
32+
canvasRef,
33+
});
34+
35+
return (
36+
<div>
37+
{!pdfDocument && <span>Loading...</span>}
38+
<canvas ref={canvasRef} />
39+
{Boolean(pdfDocument && pdfDocument.numPages) && (
40+
<nav>
41+
<ul className="pager">
42+
<li className="previous">
43+
<button disabled={page === 1} onClick={() => setPage(page - 1)}>
44+
Previous
45+
</button>
46+
</li>
47+
<li className="next">
48+
<button
49+
disabled={page === pdfDocument.numPages}
50+
onClick={() => setPage(page + 1)}
51+
>
52+
Next
53+
</button>
54+
</li>
55+
</ul>
56+
</nav>
57+
)}
58+
</div>
59+
);
60+
};
61+
```

apps/docs/src/app/docs/basics-of-time-travel/page.md

Lines changed: 0 additions & 74 deletions
This file was deleted.

apps/docs/src/app/docs/cacheadvance-flush/page.md

Lines changed: 0 additions & 74 deletions
This file was deleted.

apps/docs/src/app/docs/cacheadvance-predict/page.md

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)