hyperbook 0.5.6 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -15
- package/dist/templates/default/.hyperbook/package.json +42 -0
- package/dist/templates/default/.hyperbook/src/colors.css +187 -0
- package/dist/templates/default/.hyperbook/src/components/Drawer.js +1 -0
- package/dist/templates/default/.hyperbook/src/components/Layout.js +1 -0
- package/dist/templates/default/.hyperbook/src/components/Links.js +1 -0
- package/dist/templates/default/.hyperbook/src/components/Navigation.js +1 -0
- package/dist/templates/default/.hyperbook/src/components/Toc.js +1 -0
- package/dist/templates/default/.hyperbook/src/pages/[[...page]].js +1 -0
- package/dist/templates/default/.hyperbook/src/pages/_app.js +1 -0
- package/dist/templates/default/.hyperbook/src/pages/_document.js +1 -0
- package/dist/templates/default/.hyperbook/src/pages/api/save.js +1 -0
- package/dist/templates/default/.hyperbook/src/pages/glossary/[...term].js +1 -0
- package/dist/templates/default/.hyperbook/src/pages/glossary/index.js +2 -0
- package/dist/templates/default/.hyperbook/src/reset.css +267 -0
- package/dist/templates/default/.hyperbook/src/styles.css +439 -0
- package/dist/templates/default/.hyperbook/src/szh-menu.css +269 -0
- package/dist/templates/default/.hyperbook/src/utils/files.js +1 -0
- package/dist/templates/default/.hyperbook/src/utils/hyperbook.js +1 -0
- package/dist/templates/default/.hyperbook/src/utils/navigation.js +4 -0
- package/dist/templates/default/.hyperbook/src/utils/toc.js +2 -0
- package/dist/templates/default/.hyperbook/src/utils/useMountTransition.js +1 -0
- package/dist/templates/default/.hyperbook/src/utils/useOnScreen.js +1 -0
- package/dist/templates/default/.hyperbook/src/utils/useOverflow.js +1 -0
- package/dist/templates/default/.hyperbook/src/utils/usePreferesColorScheme.js +1 -0
- package/package.json +7 -5
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hyperbook-simple-template",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@hyperbook/element-alert": "0.1.7",
|
|
7
|
+
"@hyperbook/element-bitflow": "0.1.8",
|
|
8
|
+
"@hyperbook/element-bookmarks": "0.2.2",
|
|
9
|
+
"@hyperbook/element-collapsible": "0.2.3",
|
|
10
|
+
"@hyperbook/element-dl": "0.1.7",
|
|
11
|
+
"@hyperbook/element-excalidraw": "0.2.2",
|
|
12
|
+
"@hyperbook/element-mermaid": "0.1.7",
|
|
13
|
+
"@hyperbook/element-protect": "0.2.2",
|
|
14
|
+
"@hyperbook/element-qr": "0.1.8",
|
|
15
|
+
"@hyperbook/element-struktog": "0.1.7",
|
|
16
|
+
"@hyperbook/element-tabs": "0.1.8",
|
|
17
|
+
"@hyperbook/element-term": "0.1.7",
|
|
18
|
+
"@hyperbook/element-youtube": "0.1.7",
|
|
19
|
+
"@hyperbook/markdown": "0.3.2",
|
|
20
|
+
"@hyperbook/provider": "0.1.7",
|
|
21
|
+
"@hyperbook/store": "0.1.2",
|
|
22
|
+
"@hyperbook/styles": "0.1.7",
|
|
23
|
+
"@szhsin/react-menu": "3.2.0",
|
|
24
|
+
"classnames": "2.3.2",
|
|
25
|
+
"gray-matter": "4.0.3",
|
|
26
|
+
"next": "12.3.1",
|
|
27
|
+
"react": "18.2.0",
|
|
28
|
+
"react-collapsed": "3.4.0",
|
|
29
|
+
"react-dom": "18.2.0",
|
|
30
|
+
"react-icons": "4.6.0",
|
|
31
|
+
"react-redux": "8.0.4",
|
|
32
|
+
"redux": "4.2.0",
|
|
33
|
+
"redux-persist": "6.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@hyperbook/next-watch": "0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"next:dev": "next-hyperbook-watch",
|
|
40
|
+
"next:build": "next build && next export"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--internal-color-error: #d26466;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
html,
|
|
6
|
+
body {
|
|
7
|
+
background: var(--color-background);
|
|
8
|
+
color: var(--color-text);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
a {
|
|
12
|
+
color: var(--color-brand);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.sidebar,
|
|
16
|
+
#mobile-sidebar {
|
|
17
|
+
background: var(--color-nav);
|
|
18
|
+
border-right-color: var(--color-nav-border);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#toc-sidebar {
|
|
22
|
+
background: var(--color-nav);
|
|
23
|
+
border-left-color: var(--color-nav-border);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sidebar > .author,
|
|
27
|
+
#mobile-sidebar > .author {
|
|
28
|
+
color: var(--color-author-color);
|
|
29
|
+
background: var(--color-author-background);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sidebar > .author:hover,
|
|
33
|
+
#mobile-sidebar > .author:hover {
|
|
34
|
+
color: var(--color-brand);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Three bars for burger menu */
|
|
38
|
+
.toggle > .bar1,
|
|
39
|
+
.toggle > .bar2,
|
|
40
|
+
.toggle > .bar3 {
|
|
41
|
+
background-color: var(--color-brand-text);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.inverted .toggle > .bar1,
|
|
45
|
+
.inverted .toggle > .bar2,
|
|
46
|
+
.inverted .toggle > .bar3 {
|
|
47
|
+
background-color: var(--color-brand);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.toc-toggle > .bar1,
|
|
51
|
+
.toc-toggle > .bar2,
|
|
52
|
+
.toc-toggle > .bar3,
|
|
53
|
+
.toc-toggle > .bar4 {
|
|
54
|
+
background-color: var(--color-text);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.toc-toggle {
|
|
58
|
+
background: var(--color-background);
|
|
59
|
+
border-color: var(--color-nav-border);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
header {
|
|
63
|
+
background: var(--color-brand);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
header.inverted {
|
|
67
|
+
background: var(--color-brand-text);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.branding {
|
|
71
|
+
color: var(--color-brand-text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
header.inverted > .branding {
|
|
75
|
+
color: var(--color-brand);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.meta {
|
|
79
|
+
border-top-color: var(--color-spacer);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.section > .name {
|
|
83
|
+
color: var(--color-text);
|
|
84
|
+
border-color: var(--color-spacer);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.section .name.empty {
|
|
88
|
+
color: var(--color-text-deactivated);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.section > .name:hover {
|
|
92
|
+
background: var(--color-spacer);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.section > .name.empty:hover {
|
|
96
|
+
background: none;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.section > .name.active {
|
|
100
|
+
background: var(--color-background);
|
|
101
|
+
color: var(--color-brand);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.page {
|
|
105
|
+
color: var(--color-text);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.page:hover {
|
|
109
|
+
background: var(--color-spacer);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.page.active {
|
|
113
|
+
background: var(--color-background);
|
|
114
|
+
color: var(--color-brand);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.section > .links {
|
|
118
|
+
border-left-color: var(--color-spacer);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
a.jump {
|
|
122
|
+
border-color: var(--color-brand);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
a.jump:hover {
|
|
126
|
+
background: var(--color-nav);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
a.jump {
|
|
130
|
+
text-decoration: none;
|
|
131
|
+
flex: 1;
|
|
132
|
+
text-align: center;
|
|
133
|
+
border-style: solid;
|
|
134
|
+
border-width: 1px;
|
|
135
|
+
padding: 8px 16px;
|
|
136
|
+
width: 100%;
|
|
137
|
+
border-radius: 8px;
|
|
138
|
+
box-shadow: rgba(0, 0, 0, 0.24) 0px 1px 2px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
a.jump.next {
|
|
142
|
+
margin-left: 8px;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
a.jump.next::after {
|
|
146
|
+
content: " →";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
a.jump.previous {
|
|
150
|
+
margin-right: 8px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
a.jump.previous::before {
|
|
154
|
+
content: "← ";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@media screen and (max-width: 800px) {
|
|
158
|
+
.jump-container {
|
|
159
|
+
flex-direction: column;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
a.jump.next {
|
|
163
|
+
margin-left: 0px;
|
|
164
|
+
margin-top: 16px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
a.jump.previous {
|
|
168
|
+
margin-right: 0px;
|
|
169
|
+
margin-top: 16px;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.drawer {
|
|
174
|
+
background: #fff;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.border {
|
|
178
|
+
border-color: var(--color-spacer);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.loading {
|
|
182
|
+
background: var(--color-nav);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.glossary .terms {
|
|
186
|
+
border-left-color: var(--color-spacer);
|
|
187
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as u,useEffect as a}from"react";import{createPortal as m}from"react-dom";import l from"classnames";import{useMountTransition as v}from"../utils/useMountTransition";function w(){const e=document.createElement("div");return e.setAttribute("id","drawer-root"),e}const y=({isOpen:e,children:i,onClose:n,position:s="left",removeWhenClosed:f=!0})=>{const r=u(),o=u(),d=v(e,300);return a(()=>{o.current=document.getElementById("drawer-root")||w(),r.current=document.querySelector("body"),r.current.appendChild(o.current);const t=o.current,c=r.current;return()=>{t.remove(),c.style.overflow=""}},[]),a(()=>{(()=>{e?r.current.style.overflow="hidden":r.current.style.overflow=""})()},[e]),a(()=>{const t=c=>{c.key==="Escape"&&n()};return e&&window.addEventListener("keyup",t),()=>{window.removeEventListener("keyup",t)}},[e,n]),!d&&f&&!e?null:m(<div aria-hidden={e?"false":"true"}className={l("drawer-container",{open:e,in:d})}><div className={l("drawer",s)}role="dialog">{i}</div><div className="backdrop"onClick={n}/></div>,o.current)};var g=y;export{g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useLink as C}from"@hyperbook/provider";import Y from"next/head";import{Fragment as L,useState as P}from"react";import{getHyperbook as B}from"../utils/hyperbook";import T from"./Drawer";import{Links as H}from"./Links";import{Navigation as D}from"./Navigation";import{Toc as $}from"./Toc";const e=B(),F=o=>{const N=C();let a,t;switch(o.toLowerCase()){case"cc0":{a="https://creativecommons.org/publicdomain/zero/1.0/",t="CC0";break}case"cc-by":{a="https://creativecommons.org/licenses/by/4.0",t="CC BY";break}case"cc-by-sa":{a="https://creativecommons.org/licenses/by-sa/4.0",t="CC BY-SA";break}case"cc-by-nd":{a="https://creativecommons.org/licenses/by-nd/4.0",t="CC BY-ND";break}case"cc-by-nc":{a="https://creativecommons.org/licenses/by-nc/4.0",t="CC BY-NC";break}case"cc-by-nc-sa":{a="https://creativecommons.org/licenses/by-nc-sa/4.0",t="CC BY-NC-SA";break}case"cc-by-nc-nd":{a="https://creativecommons.org/licenses/by-nc-nd/4.0",t="CC BY-NC-ND";break}}return a?<N href={a}rel="license">Licensed under {t}</N>:o},S=o=>{const{basePath:N}=e;return process.env.NODE_ENV!=="production"&&N&&o.startsWith("/")?N.endsWith("/")?N.slice(0,-1)+o:N+o:o};function K({toc:o,navigation:N,page:a,children:t}){const O=C(),[y,k]=P(!1),[u,f]=P(!1);return<L><Y><title>{`${a.name} - ${e.name}`}</title><meta property="og:title"content={`${a.name} - ${e.name}`}key="title"/>{e.description&&<><meta name="description"content={e.description}/><meta name="og:description"content={e.description}/></>}{a.description&&<><meta name="description"content={a.description}/><meta name="og:description"content={a.description}/></>}{a.keywords&&<meta name="keywords"content={a.keywords.join(",")}/>}</Y><div className="main-grid"><header className={e?.colors?.inverted?"inverted":void 0}><div className="mobile-nav"><button aria-label="Nav Toggle"className={y?"toggle change":"toggle"}onClick={()=>k(!y)}><div className="bar1"/><div className="bar2"/><div className="bar3"/></button><T isOpen={y}onClose={()=>k(!1)}position="left"><div id="mobile-sidebar"><D{...N}/>{e.author?<a className="author"href={e.author.url}>{e.author.name}</a>:<a className="author"href="https://hyperbook.openpatch.org">Powered by <b>Hyperbook</b></a>}</div></T></div><O className="branding"href="/">{e.logo&&<div className="logo"><img alt="Logo"src={S(e.logo)}/></div>}<div className="name">{e.name}</div></O>{e.links&&<H links={e.links}/>}</header><div className="sidebar"><D{...N}/><a className="author"href="https://hyperbook.openpatch.org">Powered by <b>Hyperbook</b></a></div>{o&&<L><button className={u?"toc-toggle open":"toc-toggle"}onClick={()=>f(!u)}title="Table of Contents"><div className="bar1"/><div className="bar2"/><div className="bar3"/><div className="bar4"/></button><T isOpen={u}onClose={()=>f(!1)}position="right"><div id="toc-sidebar"><${...o}/></div></T></L>}<main>{t}<div className="meta">{a.repo&&<a className="edit-github"href={a.repo}>{"\u270E GitHub"}</a>}{e.vercel&&<a className="vercel"href={"https://vercel.com/?utm_source=openpatch&utm_campaign=oss"}><img src="https://www.openpatch.org/static/powered-by-vercel-black.svg"width={212}height={44}/></a>}<span className="copyright">{e.license?F(e.license):`\xA9 Copyright ${new Date().getFullYear()}`}{e.author&&<> by <a href={e.author.url}>{e.author.name}</a></>}.</span></div></main></div></L>}export{K as Layout};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useLink as B}from"@hyperbook/provider";import{Menu as F,MenuItem as N,SubMenu as I,MenuButton as H}from"@szhsin/react-menu";import{Fragment as R,useRef as W}from"react";import{useOnScreen as S}from"../utils/useOnScreen";const M=({label:n,icon:e})=><R>{e&&<div className="icon">{e}</div>}<div className="label">{n}</div></R>,D=({label:n,links:e,icon:i})=><I label={<M label={n}icon={i}/>}>{e.map((L,s)=><P key={s}{...L}/>)}</I>,E=({label:n,icon:e,href:i})=><N href={i}><M label={n}icon={e}/></N>,P=n=>"links"in n?<D{...n}/>:<E{...n}/>,J=({label:n,href:e,icon:i})=>{const L=B();return<L className="szh-menu-link"href={e}><M label={n}icon={i}/></L>},U=({links:n})=>{const e=W(),i=W(),L=S(e,i);return<div className="custom-links"ref={i}>{L?<div className="container"ref={e}>{n.map((s,p)=>"links"in s?<F key={p}menuButton={<H><M{...s}/></H>}transition>{s.links?.map((y,C)=><P{...y}key={C}/>)}</F>:<J key={p}{...s}/>)}</div>:<F menuButton={<H className="icon"><svg focusable="false"aria-hidden="true"viewBox="0 0 24 24"data-testid="MoreVertIcon"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg></H>}transition>{n?.map((s,p)=><P{...s}key={p}/>)}</F>}</div>};export{U as Links};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import P from"next/link";import A from"react-collapsed";const N=({name:t,href:a,current:s})=><li><P href={a}><a className={s?.href===a?"page active":"page"}>{t}</a></P></li>,S=({isEmpty:t,virtual:a,name:s,href:e,pages:n,sections:b,expanded:x,current:o})=>{const C=o?.href.startsWith(e),{getCollapseProps:L,getToggleProps:j,isExpanded:r}=A({defaultExpanded:C||x});return<div className={a?"virtual-section":"section"}><div className={["name",a||t?"empty":"",o?.href===e?"active":""].join(" ")}>{a?null:t?<span className="label">{s}</span>:<P href={e}><a className="label">{s}</a></P>}{a?null:<button className="toggle"{...j()}aria-label={r?"Close":"Open"}>{r?"\u2796":"\u2795"}</button>}</div><div className="links"{...a?[]:L()}>{n.length>0&&<ul className="pages">{n.filter(i=>!i.hide).map(i=><N key={i.href}{...i}current={o}/>)}</ul>}{b.filter(i=>!i.hide).map(i=><S key={i.href}{...i}current={o}/>)}</div></div>},z=({pages:t,sections:a,current:s})=><nav><ul>{t.filter(e=>!e.hide).map(e=><N key={e.href}{...e}current={s}/>)}</ul>{a.filter(e=>!e.hide).map(e=><S key={e.href}{...e}current={s}/>)}</nav>;export{z as Navigation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const r=({headings:l})=><nav className="toc"><ul>{l.map((a,o)=><li key={o}className={`level-${a.level}`}><a href={`#${a.anchor}`}>{a.label}</a></li>)}</ul></nav>;export{r as Toc};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import h from"fs";import x from"gray-matter";import r from"path";import{Layout as N}from"../components/Layout";import{getAllFiles as S}from"../utils/files";import{getNavigation as w}from"../utils/navigation";import{getToc as b}from"../utils/toc";import{Markdown as L}from"@hyperbook/markdown";import{useActivePageId as F,useLink as G}from"@hyperbook/provider";import{getHyperbook as I}from"../utils/hyperbook";import{Fragment as T}from"react";const A=I();function B({markdown:a,navigation:e,toc:o}){const t=e.current,P=G();return F(),<T><N navigation={e}page={t}toc={t.toc==!1?null:o}><article><L children={a}/></article><div className="jump-container">{e.previous?<P className="jump previous"href={e.previous.href}>{e.previous.name}</P>:<div className="flex"/>}{e.next?<P className="jump next"href={e.next.href}>{e.next.name}</P>:<div className="flex"/>}</div></N></T>}const Y=async({params:a})=>{let e,o=r.join(process.env.root??process.cwd(),"book"),t="/";a.page&&(o=r.join(o,...a.page),t="/"+r.join(...a.page));try{e=h.readFileSync(o+".md")}catch{e=h.readFileSync(r.join(o,"index")+".md")}const{content:P,data:k}=x(e),v=await w(t);return{props:{locale:k?.lang||A.language,markdown:P,toc:b(P),navigation:v}}},Z=async()=>({paths:S(r.join(process.env.root??process.cwd(),"book")).map(o=>{const t=r.relative(r.join(process.env.root??process.cwd(),"book"),o).replace(/\.mdx?$/,"").split("/");return t[t.length-1]==="index"&&t.pop(),{params:{page:t}}}),fallback:!1});export{B as default,Z as getStaticPaths,Y as getStaticProps};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../reset.css";import"../styles.css";import"../colors.css";import"../szh-menu.css";import"@hyperbook/markdown/katex.css";import"@hyperbook/markdown/index.css";import{Provider as O}from"@hyperbook/provider";import T from"@hyperbook/element-tabs";import"@hyperbook/element-tabs/index.css";import b from"@hyperbook/element-alert";import"@hyperbook/element-alert/index.css";import w from"@hyperbook/element-term";import"@hyperbook/element-term/index.css";import x from"@hyperbook/element-youtube";import"@hyperbook/element-youtube/index.css";import A from"@hyperbook/element-protect";import"@hyperbook/element-protect/index.css";import D from"@hyperbook/element-collapsible";import"@hyperbook/element-collapsible/index.css";import M from"@hyperbook/element-dl";import"@hyperbook/element-dl/index.css";import U from"@hyperbook/element-bookmarks";import"@hyperbook/element-bookmarks/index.css";import h from"@hyperbook/element-struktog";import"@hyperbook/element-struktog/index.css";import B from"@hyperbook/element-qr";import"@hyperbook/element-qr/index.css";import C from"@hyperbook/element-mermaid";import"@hyperbook/element-mermaid/index.css";import F from"@hyperbook/element-excalidraw";import"@hyperbook/element-excalidraw/index.css";import V from"@hyperbook/element-bitflow";import"@hyperbook/element-bitflow/index.css";import W from"next/link";import{Styles as _}from"@hyperbook/styles";import{localStorage as j}from"@hyperbook/store";import{useRouter as H}from"next/router";import{getHyperbook as I}from"../utils/hyperbook";import{useEffect as J}from"react";const Q=I(),R=({href:E,children:r,...P})=><W href={E}><a{...P}>{r}</a></W>,Y=({basePath:E})=>r=>(process.env.NODE_ENV==="production"&&E&&r.startsWith("/")&&(E.endsWith("/")?r=E.slice(0,-1)+r:r=E+r),r);function q({Component:E,pageProps:r}){const P=H();return J(()=>{document.documentElement.lang=r.locale},[r.locale]),<O Link={R}config={Q}makeUrl={Y}env={process.env.NODE_ENV==="production"?"production":"development"}elements={[T,b,w,x,D,A,M,U,h,B,C,F,V]}router={P}storage={j}loadFile={()=>async L=>fetch(L).then(N=>N.text())}saveFile={()=>async(L,N,S)=>{await fetch("/api/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:L,content:N,rootFolder:S})})}}getActivePageId={async()=>P.asPath.split("#")?.[0]||"/"}><_/><E{...r}/></O>}export{q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{Html as _,Head as D,Main as H,NextScript as A}from"next/document";class M extends e{render(){return<_ lang={this.props.__NEXT_DATA__.props.pageProps.locale}><D/><body><H/><A/></body></_>}}var h=M;export{h as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import s from"fs/promises";import i from"path";async function o(a){var t=i.dirname(a);try{return await s.access(t),!0}catch{s.mkdir(t).then(async()=>o(t))}}const l={api:{bodyParser:{sizeLimit:"32mb"}}};async function c(a,t){process.env.NODE_ENV!=="development"&&t.status(404).json({status:"failed"});let{path:e,content:r,rootFolder:n}=a.body;n&&(e=i.join(n,e)),e=i.join(__dirname,"..","..","..","..",e);try{await o(e),await s.writeFile(e,r),t.status(202).json({status:"saved"})}catch(p){t.status(400).json(p)}}export{l as config,c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"path";import L from"fs";import{Layout as G}from"../../components/Layout";import{getAllFiles as S}from"../../utils/files";import N from"gray-matter";import{getNavigation as $,readFile as I}from"../../utils/navigation";import{Fragment as A}from"react";import{getHyperbook as E}from"../../utils/hyperbook";import{getToc as H}from"../../utils/toc";import{useActivePageId as M,useLink as R}from"@hyperbook/provider";import{Markdown as B}from"@hyperbook/markdown";const u=E();function C({markdown:o,navigation:r,term:t,toc:s}){const P=R();return M(),<G navigation={r}page={t}toc={t?.toc===!0?s:null}><article><B children={o}/><div className="pages">{t.pages.map((a,y)=><A key={a.href}>{y>0&&", "}<P href={a.href}>{a.name}</P></A>)}</div></article></G>}const it=async({params:o})=>{let r=e.join(process.env.root??process.cwd(),"glossary");r=e.join(r,...o.term);const t="/glossary/"+e.join(...o.term),s=L.readFileSync(r+".md"),{content:P,data:a}=N(s),y=await $(t),b=S(e.join(process.env.root??process.cwd(),"book")),x=[];for(const w of b){const{content:j,data:k}=I(w),F=new RegExp(`:t\\[.*\\]\\{#${o.term}(..*)?\\}|:t\\[${o.term}\\]`);if(j.match(F)&&!k.hide&&k.name){const v=e.relative(e.join(process.env.root??process.cwd(),"book"),w).replace(/\.mdx?$/,"").split("/");v[v.length-1]==="index"&&v.pop(),x.push({...k,href:"/"+v.join("/")})}}const T={...a,pages:x};return u?.repo&&(T.repo=u.repo+t+".md"),{props:{locale:a?.lang||u.language,term:T,markdown:P,toc:H(P),navigation:y,hyperbook:u}}},ct=async()=>({paths:S("glossary").map(t=>({params:{term:e.relative("glossary",t).replace(/\.mdx?$/,"").split("/")}})),fallback:!1});export{C as default,ct as getStaticPaths,it as getStaticProps};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import x from"fs";import{getAllFiles as L}from"../../utils/files";import w from"gray-matter";import S from"chalk";import{Layout as $}from"../../components/Layout";import{getNavigation as b}from"../../utils/navigation";import P from"path";import{useActivePageId as j,useLink as A}from"@hyperbook/provider";import F from"../../../hyperbook.json";function T({terms:a,navigation:o}){const G=A();return j(),<$ navigation={o}page={{name:"Glossary"}}><article className="glossary">{Object.keys(a).map(e=><div key={e}className="container"><div className="letter">{e}</div><ul className="terms">{a[e].map(r=><li key={r.href}><G className="term"href={r.href}>{r.name}</G></li>)}</ul></div>)}</article></$>}const K=async()=>{const a=L(P.join(process.env.root??process.cwd(),"glossary")),o={};for(const e of a){const r=x.readFileSync(e),{data:N}=w(r);let s=P.basename(e,".md");N.name?s=N.name:console.log(`
|
|
2
|
+
${S.yellow("warn ")}- Glossary page ${e} does not specify a name. Defaulting to the filename ${s}.`);const k=s[0].toUpperCase();o[k]||(o[k]=[]),o[k].push({name:s,href:e.replace(/\.mdx?$/,"")})}const G=await b();return{props:{locale:F.language,terms:o,navigation:G}}};export{T as default,K as getStaticProps};
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/*
|
|
2
|
+
HTML5 Reset :: style.css
|
|
3
|
+
----------------------------------------------------------
|
|
4
|
+
We have learned much from/been inspired by/taken code where offered from:
|
|
5
|
+
|
|
6
|
+
Eric Meyer :: http://meyerweb.com
|
|
7
|
+
HTML5 Doctor :: http://html5doctor.com
|
|
8
|
+
and the HTML5 Boilerplate :: http://html5boilerplate.com
|
|
9
|
+
|
|
10
|
+
-------------------------------------------------------------------------------*/
|
|
11
|
+
|
|
12
|
+
/* Let's default this puppy out
|
|
13
|
+
-------------------------------------------------------------------------------*/
|
|
14
|
+
|
|
15
|
+
html,
|
|
16
|
+
body,
|
|
17
|
+
body div,
|
|
18
|
+
span,
|
|
19
|
+
object,
|
|
20
|
+
iframe,
|
|
21
|
+
h1,
|
|
22
|
+
h2,
|
|
23
|
+
h3,
|
|
24
|
+
h4,
|
|
25
|
+
h5,
|
|
26
|
+
h6,
|
|
27
|
+
p,
|
|
28
|
+
blockquote,
|
|
29
|
+
pre,
|
|
30
|
+
abbr,
|
|
31
|
+
address,
|
|
32
|
+
cite,
|
|
33
|
+
code,
|
|
34
|
+
del,
|
|
35
|
+
dfn,
|
|
36
|
+
em,
|
|
37
|
+
img,
|
|
38
|
+
ins,
|
|
39
|
+
kbd,
|
|
40
|
+
q,
|
|
41
|
+
samp,
|
|
42
|
+
small,
|
|
43
|
+
strong,
|
|
44
|
+
sub,
|
|
45
|
+
sup,
|
|
46
|
+
var,
|
|
47
|
+
b,
|
|
48
|
+
i,
|
|
49
|
+
dl,
|
|
50
|
+
dt,
|
|
51
|
+
dd,
|
|
52
|
+
ol,
|
|
53
|
+
ul,
|
|
54
|
+
li,
|
|
55
|
+
fieldset,
|
|
56
|
+
form,
|
|
57
|
+
label,
|
|
58
|
+
legend,
|
|
59
|
+
caption,
|
|
60
|
+
article,
|
|
61
|
+
aside,
|
|
62
|
+
figure,
|
|
63
|
+
footer,
|
|
64
|
+
header,
|
|
65
|
+
menu,
|
|
66
|
+
nav,
|
|
67
|
+
section,
|
|
68
|
+
time,
|
|
69
|
+
mark,
|
|
70
|
+
audio,
|
|
71
|
+
video,
|
|
72
|
+
details,
|
|
73
|
+
summary {
|
|
74
|
+
margin: 0;
|
|
75
|
+
padding: 0;
|
|
76
|
+
border: 0;
|
|
77
|
+
font-size: 100%;
|
|
78
|
+
font-weight: normal;
|
|
79
|
+
vertical-align: baseline;
|
|
80
|
+
background: transparent;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main,
|
|
84
|
+
article,
|
|
85
|
+
aside,
|
|
86
|
+
figure,
|
|
87
|
+
footer,
|
|
88
|
+
header,
|
|
89
|
+
nav,
|
|
90
|
+
section,
|
|
91
|
+
details,
|
|
92
|
+
summary {
|
|
93
|
+
display: block;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Handle box-sizing while better addressing child elements:
|
|
97
|
+
http://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/ */
|
|
98
|
+
html {
|
|
99
|
+
box-sizing: border-box;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
*,
|
|
103
|
+
*:before,
|
|
104
|
+
*:after {
|
|
105
|
+
box-sizing: inherit;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* consider resetting the default cursor: https://gist.github.com/murtaugh/5247154 */
|
|
109
|
+
|
|
110
|
+
/* Responsive images and other embedded objects */
|
|
111
|
+
/* if you don't have full control over `img` tags (if you have to overcome attributes), consider adding height: auto */
|
|
112
|
+
img,
|
|
113
|
+
object,
|
|
114
|
+
embed {
|
|
115
|
+
max-width: 100%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/*
|
|
119
|
+
Note: keeping IMG here will cause problems if you're using foreground images as sprites.
|
|
120
|
+
In fact, it *will* cause problems with Google Maps' controls at small size.
|
|
121
|
+
If this is the case for you, try uncommenting the following:
|
|
122
|
+
|
|
123
|
+
#map img {
|
|
124
|
+
max-width: none;
|
|
125
|
+
}
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/* force a vertical scrollbar to prevent a jumpy page */
|
|
129
|
+
html {
|
|
130
|
+
overflow-y: scroll;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
blockquote,
|
|
134
|
+
q {
|
|
135
|
+
quotes: none;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
blockquote:before,
|
|
139
|
+
blockquote:after,
|
|
140
|
+
q:before,
|
|
141
|
+
q:after {
|
|
142
|
+
content: "";
|
|
143
|
+
content: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
a {
|
|
147
|
+
margin: 0;
|
|
148
|
+
padding: 0;
|
|
149
|
+
font-size: 100%;
|
|
150
|
+
vertical-align: baseline;
|
|
151
|
+
background: transparent;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
del {
|
|
155
|
+
text-decoration: line-through;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
abbr[title],
|
|
159
|
+
dfn[title] {
|
|
160
|
+
border-bottom: 1px dotted #000;
|
|
161
|
+
cursor: help;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
hr {
|
|
165
|
+
display: block;
|
|
166
|
+
height: 1px;
|
|
167
|
+
border: 0;
|
|
168
|
+
border-top: 1px solid #ccc;
|
|
169
|
+
margin: 1em 0;
|
|
170
|
+
padding: 0;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
input,
|
|
174
|
+
select {
|
|
175
|
+
vertical-align: middle;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
input[type="radio"] {
|
|
179
|
+
vertical-align: text-bottom;
|
|
180
|
+
}
|
|
181
|
+
input[type="checkbox"] {
|
|
182
|
+
vertical-align: bottom;
|
|
183
|
+
}
|
|
184
|
+
.ie7 input[type="checkbox"] {
|
|
185
|
+
vertical-align: baseline;
|
|
186
|
+
}
|
|
187
|
+
.ie6 input {
|
|
188
|
+
vertical-align: text-bottom;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
select,
|
|
192
|
+
input,
|
|
193
|
+
textarea {
|
|
194
|
+
font: 99% sans-serif;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
small {
|
|
198
|
+
font-size: 85%;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
strong {
|
|
202
|
+
font-weight: bold;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* Make sure sup and sub don't mess with your line-heights http://gist.github.com/413930 */
|
|
206
|
+
sub,
|
|
207
|
+
sup {
|
|
208
|
+
font-size: 75%;
|
|
209
|
+
line-height: 0;
|
|
210
|
+
position: relative;
|
|
211
|
+
}
|
|
212
|
+
sup {
|
|
213
|
+
top: -0.5em;
|
|
214
|
+
}
|
|
215
|
+
sub {
|
|
216
|
+
bottom: -0.25em;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* standardize any monospaced elements */
|
|
220
|
+
pre,
|
|
221
|
+
code,
|
|
222
|
+
kbd,
|
|
223
|
+
samp {
|
|
224
|
+
font-family: monospace, sans-serif;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* hand cursor on clickable elements */
|
|
228
|
+
.clickable,
|
|
229
|
+
label,
|
|
230
|
+
input[type="button"],
|
|
231
|
+
input[type="submit"],
|
|
232
|
+
input[type="file"],
|
|
233
|
+
button {
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* Webkit browsers add a 2px margin outside the chrome of form elements */
|
|
238
|
+
button,
|
|
239
|
+
input,
|
|
240
|
+
select,
|
|
241
|
+
textarea {
|
|
242
|
+
margin: 0;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* make buttons play nice in IE */
|
|
246
|
+
button,
|
|
247
|
+
input[type="button"] {
|
|
248
|
+
width: auto;
|
|
249
|
+
overflow: visible;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/* scale images in IE7 more attractively */
|
|
253
|
+
.ie7 img {
|
|
254
|
+
-ms-interpolation-mode: bicubic;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/* prevent BG image flicker upon hover
|
|
258
|
+
(commented out as usage is rare, and the filter syntax messes with some pre-processors)
|
|
259
|
+
.ie6 html {filter: expression(document.execCommand("BackgroundImageCache", false, true));}
|
|
260
|
+
*/
|
|
261
|
+
|
|
262
|
+
/* let's clear some floats */
|
|
263
|
+
.clearfix:after {
|
|
264
|
+
content: " ";
|
|
265
|
+
display: block;
|
|
266
|
+
clear: both;
|
|
267
|
+
}
|