Skip to content

Commit 3175c88

Browse files
committed
Update static build to include README documentation
1 parent 9a7fbce commit 3175c88

File tree

10 files changed

+308
-93
lines changed

10 files changed

+308
-93
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dist
33
node_modules
44
public/script.js
55
public/script.js.map
6+
public/index.html
67
static
78

89
# OS

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
![image](https://user-images.githubusercontent.com/7376450/154114970-a68a6b14-91b8-48ea-a76a-5d2cd2f342c7.png)
1+
<!-- ![image](https://user-images.githubusercontent.com/7376450/154114970-a68a6b14-91b8-48ea-a76a-5d2cd2f342c7.png) -->
2+
<img src="https://user-images.githubusercontent.com/7376450/154114970-a68a6b14-91b8-48ea-a76a-5d2cd2f342c7.png" class="clover-screenshot" alt="Clover screenshot" />
23

34
# Clover IIIF
45

@@ -30,7 +31,7 @@ Clover IIIF is a UI component that renders a multicanvas IIIF viewer intended fo
3031

3132
---
3233

33-
## Installation
34+
<h2 id="installation">Installation</h2>
3435

3536
Install the component from your command line using `npm install`,
3637

@@ -46,7 +47,7 @@ yarn add @samvera/clover-iiif
4647

4748
---
4849

49-
## Basic Usage
50+
<h2 id="basic-usage">Basic Usage</h2>
5051

5152
Add the CloverIIIF component to your `jsx` or `tsx` code.
5253

@@ -67,7 +68,7 @@ return <CloverIIIF manifestId={manifestId} />;
6768

6869
---
6970

70-
## Active Canvas
71+
<h2 id="active-canvas">Active Canvas</h2>
7172

7273
Example on using `canvasIdCallback` to return to your consuming application the active canvas ID. This will return as a string.
7374

@@ -91,7 +92,7 @@ return (
9192

9293
---
9394

94-
## Configuring Captions
95+
<h2 id="configuring-captions">Configuring Captions</h2>
9596

9697
WebVTT content resources are the source for both content mapped closed captioning `<track/>` elements in the HTML 5 video player and to the navigator panel adjacent to it. You may ignore these resources as tracks if they are not intended for closed captioning or subtitling by string values matching the label of the content resource. This is a manual option within the viewer as there is no defined way for a manifest to prescribe motivation for these resources beyond `supplementing`.
9798

@@ -134,7 +135,7 @@ export default function App() {
134135

135136
---
136137

137-
## Custom Theme
138+
<h2 id="custom-theme">Custom Theme</h2>
138139

139140
You may choose to override the base theme by setting optional colors and fonts. Naming conventions for colors are limited to those shown in the config example below.
140141

@@ -181,7 +182,7 @@ return <CloverIIIF manifestId={manifestId} customTheme={customTheme} />;
181182

182183
---
183184

184-
## Reference
185+
<h2 id="reference">Reference</h2>
185186

186187
| Prop | Type | Required | Default |
187188
| ----------------------------- | ---------- | -------- | ------- |
@@ -218,7 +219,7 @@ const options = {
218219

219220
---
220221

221-
## Manifest Requirements
222+
<h2 id="manifest-requirements">Manifest Requirements</h2>
222223

223224
The manifest provided to `manifestId`:
224225

@@ -229,7 +230,7 @@ The manifest provided to `manifestId`:
229230

230231
---
231232

232-
## Development
233+
<h2 id="development">Development</h2>
233234

234235
Clover IIIF is built with:
235236

@@ -271,6 +272,6 @@ npm run build:static
271272
tsc
272273
```
273274

274-
## License
275+
<h2 id="license">License</h2>
275276

276277
This project is available under the [MIT License](https://github.com/samvera-labs/clover-iiif/blob/main/LICENSE).

build-static.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
const { build } = require("esbuild");
22
const envFilePlugin = require("esbuild-envfile-plugin");
33
const fs = require("fs-extra");
4+
const { buildHTML } = require("./utils/html.js");
45

56
const { OUT_DIR } = process.env;
67

78
const filterFunc = (src, dest) => {
8-
console.log("copying: ", src);
9-
return !src.includes("script.js");
9+
const dontCopyFiles = ["script.js", "index.html"];
10+
const shouldCopy = !dontCopyFiles.some((file) => src.includes(file));
11+
12+
if (shouldCopy) {
13+
console.log("copying: ", src);
14+
}
15+
16+
return shouldCopy;
1017
};
1118

1219
async function emptyDir() {
1320
try {
1421
await fs.emptyDir(OUT_DIR);
15-
console.log("/static directory emptied");
22+
console.log("/static directory emptied\n");
1623
} catch (err) {
1724
console.error(err);
1825
}
@@ -21,16 +28,32 @@ async function emptyDir() {
2128
async function copyFiles() {
2229
try {
2330
await fs.copy("public", OUT_DIR, { filter: filterFunc });
24-
console.log("Success copying files");
31+
32+
// Copy highlight.js package styles for markdown code highlighting
33+
await fs.copy(
34+
"./node_modules/highlight.js/styles/default.css",
35+
`./${OUT_DIR}/default.css`,
36+
{ overwrite: true },
37+
);
38+
console.log("\nSuccess copying files");
2539
} catch (err) {
26-
console.error("Error copying files: ", err);
40+
console.error("\nError copying files: ", err);
2741
}
2842
}
2943

3044
(async () => {
3145
await emptyDir();
3246
await copyFiles();
3347

48+
/**
49+
* Build the /static HTML file
50+
*/
51+
fs.writeFile("./static/index.html", await buildHTML(true), (error) => {
52+
if (error) {
53+
console.error("Error writing index.html file: ", error);
54+
}
55+
});
56+
3457
await build({
3558
bundle: true,
3659
entryPoints: ["src/dev.tsx"],

package-lock.json

Lines changed: 117 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
"eslint-plugin-prettier": "^4.0.0",
4343
"eslint-plugin-react": "^7.26.0",
4444
"fs-extra": "^10.0.1",
45+
"highlight.js": "^11.5.0",
4546
"jest": "^27.2.1",
4647
"live-server": "^1.2.1",
48+
"markdown-it": "^12.3.2",
4749
"prettier": "^2.4.1",
4850
"rimraf": "^3.0.2",
4951
"ts-jest": "^27.0.5",

0 commit comments

Comments
 (0)