| 
									
										
										
										
											2022-08-16 09:29:15 +00:00
										 |  |  | import Head from 'next/head'; | 
					
						
							|  |  |  | import Link from "next/link"; | 
					
						
							| 
									
										
										
										
											2023-05-26 22:50:23 +00:00
										 |  |  | import { read } from 'xlsx'; | 
					
						
							|  |  |  | import base64 from "@/sheetjs.xlsx"; | 
					
						
							| 
									
										
										
										
											2022-08-16 09:29:15 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-26 22:50:23 +00:00
										 |  |  | export default function Index({type, snames}) { return ( <> | 
					
						
							| 
									
										
										
										
											2022-08-16 09:29:15 +00:00
										 |  |  |   <Head> | 
					
						
							|  |  |  |     <meta httpEquiv="Content-Type" content="text/html; charset=UTF-8" /> | 
					
						
							|  |  |  |     <title>{`SheetJS Next.JS ${type} Demo`}</title> | 
					
						
							|  |  |  |   </Head> | 
					
						
							| 
									
										
										
										
											2023-05-26 22:50:23 +00:00
										 |  |  |   <h3>{`SheetJS Next.JS ${type} Demo`}</h3> | 
					
						
							|  |  |  |   <p> | 
					
						
							|  |  |  |     This demo reads from <code>/sheetjs.xlsx</code><br/><br/> | 
					
						
							|  |  |  |     Each worksheet maps to a path:<br/> | 
					
						
							|  |  |  |   </p> | 
					
						
							|  |  |  |   <table><thead><tr key={0}><th>Sheet Name</th><th>URL</th></tr></thead><tbody> | 
					
						
							|  |  |  |     {snames.map((sname, idx) => (<tr key={idx+1}> | 
					
						
							|  |  |  |       <td><Link href="/sheets/[id]" as={`/sheets/${idx}`}>{sname}</Link></td> | 
					
						
							|  |  |  |       <td><code>/sheets/{idx}</code></td> | 
					
						
							|  |  |  |     </tr>))} | 
					
						
							|  |  |  |   </tbody></table> | 
					
						
							|  |  |  | </> ); } | 
					
						
							| 
									
										
										
										
											2022-08-16 09:29:15 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | export async function getStaticProps() { | 
					
						
							| 
									
										
										
										
											2023-05-26 22:50:23 +00:00
										 |  |  |   const wb = read(base64, {type: "base64"}); | 
					
						
							| 
									
										
										
										
											2022-08-16 09:29:15 +00:00
										 |  |  |   return { | 
					
						
							|  |  |  |     props: { | 
					
						
							|  |  |  |       type: "getStaticPaths", | 
					
						
							|  |  |  |       snames: wb.SheetNames, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |