@ca-plant-list/ca-plant-list 0.2.18 → 0.3.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.
@@ -1,49 +1,54 @@
1
1
  import { Files, HTML } from "@ca-plant-list/ca-plant-list";
2
2
  import { Glossary } from "../plants/glossary.js";
3
- import { Jekyll } from "../jekyll.js";
3
+ import { Markdown } from "../markdown.js";
4
+
5
+ const ENTRY_DIR = "g";
4
6
 
5
7
  class GlossaryPages {
6
8
 
7
- #outputDir;
8
- #entryDir;
9
+ #siteGenerator;
9
10
  #glossary;
10
11
 
11
- constructor( outputDir ) {
12
- this.#outputDir = outputDir;
13
- this.#entryDir = outputDir + "/g";
12
+ constructor( siteGenerator ) {
13
+ this.#siteGenerator = siteGenerator;
14
14
  this.#glossary = new Glossary();
15
15
  }
16
16
 
17
17
  #generateEntryPage( entry ) {
18
- const front = Jekyll.getFrontMatter( { title: entry.getTermName() } );
19
- const markdown = entry.getMarkdown();
20
- Files.write( this.#entryDir + "/" + entry.getTermName() + ".md", front + markdown );
18
+ const title = entry.getTermName();
19
+ let html = HTML.textElement( "h1", title );
20
+ html += HTML.wrap( "div", Markdown.strToHTML( entry.getMarkdown() ), { class: "glossary" } );
21
+ this.#siteGenerator.writeTemplate( html, { title: title }, Files.join( ENTRY_DIR, title + ".html" ) );
21
22
  }
22
23
 
23
24
  #generateEntryPages() {
25
+
26
+ // Make sure output directory exists.
27
+ this.#siteGenerator.mkdir( ENTRY_DIR );
28
+
24
29
  const entries = this.#glossary.getEntries();
25
30
  for ( const entry of entries ) {
26
31
  this.#generateEntryPage( entry );
27
32
  }
28
33
  }
29
34
 
30
- #generateIncludeFile() {
31
-
35
+ #generateIndexPage() {
32
36
  const links = [];
33
37
  const entries = this.#glossary.getEntries();
34
38
  for ( const entry of entries ) {
35
- links.push( HTML.getLink( "g/" + entry.getHTMLFileName(), entry.getTermName() ) );
39
+ links.push( HTML.getLink( Files.join( ENTRY_DIR, entry.getHTMLFileName() ), entry.getTermName() ) );
36
40
  }
41
+ let html = HTML.wrap( "h1", "Glossary" );
42
+ html += HTML.wrap( "ol", HTML.arrayToLI( links ) );
43
+ this.#siteGenerator.writeTemplate( html, { title: "Glossary" }, "glossary.html" );
44
+ }
37
45
 
38
- Files.write( this.#outputDir + "/_includes/glossary.html", HTML.arrayToLI( links ), true );
39
-
46
+ getGlossary() {
47
+ return this.#glossary;
40
48
  }
41
49
 
42
50
  renderPages() {
43
- // Make sure output directory exists.
44
- Files.mkdir( this.#entryDir );
45
-
46
- this.#generateIncludeFile();
51
+ this.#generateIndexPage();
47
52
  this.#generateEntryPages();
48
53
  }
49
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.2.18",
3
+ "version": "0.3.0",
4
4
  "description": "Tools to create Jekyll files for a website listing plants in an area of California.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,6 +30,7 @@
30
30
  "image-size": "^1.0.2",
31
31
  "markdown-it": "^13.0.1",
32
32
  "sharp": "^0.32.1",
33
+ "svgo": "^3.0.3",
33
34
  "unzipper": "^0.10.11"
34
35
  },
35
36
  "devDependencies": {
@@ -37,4 +38,4 @@
37
38
  "eslint": "^8.26.0",
38
39
  "typescript": "^4.9.3"
39
40
  }
40
- }
41
+ }
@@ -1,28 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
- <svg width="82.437mm" height="84.504mm" version="1.1" viewBox="0 0 82.437 84.504" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
4
- <defs>
5
- <marker id="Triangle" overflow="visible" markerHeight="1" markerWidth="1" orient="auto-start-reverse" preserveAspectRatio="xMidYMid" viewBox="0 0 1 1">
6
- <path transform="scale(.5)" d="m5.77 0-8.65 5v-10z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
7
- </marker>
8
- </defs>
9
- <g transform="translate(-48.054 -6.5123)">
10
- <g fill="#959595">
11
- <path d="m79.276 37.945a8.4667 31.089 0 0 1 1.8353 33.88 8.4667 31.089 0 0 1-7.8222 19.191 8.4667 31.089 0 0 1-7.8222-19.191 8.4667 31.089 0 0 1 1.8353-33.88z"/>
12
- <path d="m48.253 13.074 19.05 24.871" stroke="#888" stroke-width=".5"/>
13
- <path id="path3" d="m98.326 13.074-19.05 24.871" fill="#959595" stroke="#888" stroke-width=".5"/>
14
- </g>
15
- <use transform="rotate(-17.226 77.257 49.068)" xlink:href="#path3"/>
16
- <path d="m55.686 9.6812 13.798 28.126" fill="#959595" stroke="#888" stroke-width=".5"/>
17
- <path d="m62.705 7.5473 8.2896 30.212" fill="#959595" stroke="#888" stroke-width=".5"/>
18
- <use transform="rotate(-5.8666 77.05 56.397)" xlink:href="#path3"/>
19
- <use transform="rotate(-27.32 76.391 49.027)" xlink:href="#path3"/>
20
- <g>
21
- <path d="m69.881 6.5376 3.171 31.167" fill="#959595" stroke="#888" stroke-width=".5"/>
22
- <text x="114.47877" y="66.073151" fill="#050000" font-family="Arial" font-size="4.9389px" stroke="#020000" stroke-width="0" xml:space="preserve"><tspan x="114.47877" y="66.073151" fill="#050000" font-family="Arial" font-size="4.9389px" stroke="#020000" stroke-width="0">achene</tspan></text>
23
- <text x="114.47877" y="28.502281" fill="#050000" font-family="Arial" font-size="4.9389px" stroke="#020000" stroke-width="0" xml:space="preserve"><tspan x="114.47877" y="28.502281" fill="#050000" font-family="Arial" font-size="4.9389px" stroke="#020000" stroke-width="0">pappus</tspan></text>
24
- <path d="m88.996 65.009 20.886-0.12554" marker-start="url(#Triangle)" stroke="#000" stroke-width=".42043"/>
25
- <path d="m90.584 27.967 20.886-0.12554" marker-start="url(#Triangle)" stroke="#000" stroke-width=".42043"/>
26
- </g>
27
- </g>
28
- </svg>
@@ -1,11 +0,0 @@
1
- <svg version="1.1" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"
2
- xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <ellipse id="a" cx="15" cy="15" rx="2.5" ry="15" fill="blue" stroke-width="0" />
4
- <use xlink:href="#a" />
5
- <use transform="rotate(30,15,15)" xlink:href="#a" />
6
- <use transform="rotate(60,15,15)" xlink:href="#a" />
7
- <use transform="rotate(90,15,15)" xlink:href="#a" />
8
- <use transform="rotate(120,15,15)" xlink:href="#a" />
9
- <use transform="rotate(150,15,15)" xlink:href="#a" />
10
- </svg>
11
-
@@ -1,11 +0,0 @@
1
- <svg version="1.1" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"
2
- xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <ellipse id="a" cx="15" cy="15" rx="2.5" ry="15" fill="orange" stroke-width="0" />
4
- <use xlink:href="#a" />
5
- <use transform="rotate(30,15,15)" xlink:href="#a" />
6
- <use transform="rotate(60,15,15)" xlink:href="#a" />
7
- <use transform="rotate(90,15,15)" xlink:href="#a" />
8
- <use transform="rotate(120,15,15)" xlink:href="#a" />
9
- <use transform="rotate(150,15,15)" xlink:href="#a" />
10
- </svg>
11
-
@@ -1,11 +0,0 @@
1
- <svg version="1.1" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"
2
- xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <ellipse id="a" cx="15" cy="15" rx="2.5" ry="15" fill="pink" stroke-width="0" />
4
- <use xlink:href="#a" />
5
- <use transform="rotate(30,15,15)" xlink:href="#a" />
6
- <use transform="rotate(60,15,15)" xlink:href="#a" />
7
- <use transform="rotate(90,15,15)" xlink:href="#a" />
8
- <use transform="rotate(120,15,15)" xlink:href="#a" />
9
- <use transform="rotate(150,15,15)" xlink:href="#a" />
10
- </svg>
11
-
@@ -1,11 +0,0 @@
1
- <svg version="1.1" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"
2
- xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <ellipse id="a" cx="15" cy="15" rx="2.5" ry="15" fill="red" stroke-width="0" />
4
- <use xlink:href="#a" />
5
- <use transform="rotate(30,15,15)" xlink:href="#a" />
6
- <use transform="rotate(60,15,15)" xlink:href="#a" />
7
- <use transform="rotate(90,15,15)" xlink:href="#a" />
8
- <use transform="rotate(120,15,15)" xlink:href="#a" />
9
- <use transform="rotate(150,15,15)" xlink:href="#a" />
10
- </svg>
11
-
@@ -1,11 +0,0 @@
1
- <svg version="1.1" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"
2
- xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <ellipse id="a" cx="15" cy="15" rx="2.5" ry="15" fill="white" stroke-width="0" />
4
- <use xlink:href="#a" />
5
- <use transform="rotate(30,15,15)" xlink:href="#a" />
6
- <use transform="rotate(60,15,15)" xlink:href="#a" />
7
- <use transform="rotate(90,15,15)" xlink:href="#a" />
8
- <use transform="rotate(120,15,15)" xlink:href="#a" />
9
- <use transform="rotate(150,15,15)" xlink:href="#a" />
10
- </svg>
11
-
@@ -1,11 +0,0 @@
1
- <svg version="1.1" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"
2
- xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <ellipse id="a" cx="15" cy="15" rx="2.5" ry="15" fill="yellow" stroke-width="0" />
4
- <use xlink:href="#a" />
5
- <use transform="rotate(30,15,15)" xlink:href="#a" />
6
- <use transform="rotate(60,15,15)" xlink:href="#a" />
7
- <use transform="rotate(90,15,15)" xlink:href="#a" />
8
- <use transform="rotate(120,15,15)" xlink:href="#a" />
9
- <use transform="rotate(150,15,15)" xlink:href="#a" />
10
- </svg>
11
-
@@ -1,21 +0,0 @@
1
- <svg version="1.1" viewBox="0 0 102.55 60" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2
- <defs>
3
- <marker id="b" overflow="visible" markerHeight="1" markerWidth="1" orient="auto-start-reverse" preserveAspectRatio="xMidYMid" viewBox="0 0 1 1">
4
- <path transform="scale(.5)" d="m5.77 0-8.65 5v-10z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
5
- </marker>
6
- </defs>
7
- <path d="m15 60v-45" fill="#14140c" stroke="#160707"/>
8
- <use xlink:href="#a"/>
9
- <use transform="rotate(30,15,15)" xlink:href="#a"/>
10
- <use transform="rotate(60,15,15)" xlink:href="#a"/>
11
- <use transform="rotate(90,15,15)" xlink:href="#a"/>
12
- <use transform="rotate(120,15,15)" xlink:href="#a"/>
13
- <use transform="rotate(150,15,15)" xlink:href="#a"/>
14
- <ellipse id="a" cx="15" cy="15" rx="2.5" ry="15" fill="#ff0" stroke-width="0"/>
15
- <g fill="#14140c" stroke="#160707">
16
- <path d="m20 45h25" marker-start="url(#b)" stroke-width=".5"/>
17
- <text x="50" y="47.068359" font-family="Arial" font-size="8px" letter-spacing=".5px" opacity=".55843" stroke-width=".1" xml:space="preserve"><tspan x="50" y="47.068359" font-family="Arial" font-size="8px" letter-spacing=".5px" stroke-width=".1" style="font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal">peduncle</tspan></text>
18
- <path d="m35 15h10" marker-start="url(#b)" stroke-width=".5"/>
19
- <text x="49.696735" y="17.068359" font-family="Arial" font-size="8px" letter-spacing=".5px" opacity=".55843" stroke-width=".1" xml:space="preserve"><tspan x="49.696735" y="17.068359" font-family="Arial" font-size="8px" letter-spacing=".5px" stroke-width=".1" style="font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal">inflorescence</tspan></text>
20
- </g>
21
- </svg>
@@ -1,5 +0,0 @@
1
- ---
2
- title: Glossary
3
- ---
4
-
5
- {%include glossary.html %}