fossbook 0.0.12 → 0.0.16

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/lib/mod/marked.js CHANGED
@@ -71,7 +71,7 @@ const renderer = {
71
71
  imageTag += ">";
72
72
 
73
73
  return `
74
- <div style="text-align: ${align};">
74
+ <div class="image-container" style="text-align: ${align};">
75
75
  <figure style="text-align: ${align};">
76
76
  ${imageTag}
77
77
  ${title ? `<figcaption>${title}</figcaption>` : ""}
@@ -113,6 +113,16 @@ const renderer = {
113
113
  },
114
114
  };
115
115
 
116
- marked.use({ renderer });
116
+ marked.use({
117
+ renderer,
118
+ hooks: {
119
+ postprocess(html) {
120
+ return html.replace(
121
+ /(<div class="image-container"[^>]*>[\s\S]*?<\/div>\s*)<div class="blockquote-container">/g,
122
+ '$1<div class="blockquote-container image-dialogue">',
123
+ );
124
+ },
125
+ },
126
+ });
117
127
 
118
128
  module.exports = marked;
package/lib/posts.js CHANGED
@@ -12,7 +12,7 @@ module.exports = class Posts {
12
12
  createPostObjects() {
13
13
  if (!fs.existsSync(this.config.dev.postsdir)) {
14
14
  console.warn(`No posts directory found at "${this.config.dev.postsdir}", skipping posts.`);
15
- return;
15
+ return [];
16
16
  }
17
17
  const postPaths = fs.readdirSync(this.config.dev.postsdir);
18
18
  postPaths.forEach((postPath) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fossbook",
3
- "version": "0.0.12",
3
+ "version": "0.0.16",
4
4
  "description": "A lightweight static blog site generator for GitHub Pages",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -18,13 +18,6 @@
18
18
 
19
19
  }
20
20
 
21
- /* for desktop */
22
- @media (min-width: 1025px) and (orientation: landscape) {
23
- blockquote {
24
- display: none;
25
- }
26
- }
27
-
28
21
  body{
29
22
  display: block;
30
23
  margin: 8px;
@@ -52,6 +45,8 @@
52
45
  .blockquote-container {
53
46
  display: flex;
54
47
  justify-content: center;
48
+ margin-inline: auto;
49
+ width: var(--dialogue-width, 100%);
55
50
  }
56
51
 
57
52
 
@@ -126,7 +121,7 @@
126
121
  margin: 0;
127
122
  max-width: 100%;
128
123
  }
129
-
124
+
130
125
  figure img {
131
126
  max-height: 500px;
132
127
  }
@@ -135,6 +130,7 @@
135
130
  figure {
136
131
  padding: 0 40px;
137
132
  }
133
+
138
134
  }
139
135
 
140
136
  figure h4 {
@@ -83,5 +83,16 @@
83
83
  import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
84
84
  mermaid.initialize({ startOnLoad: true });
85
85
  </script>` : ""}
86
+ ${page.body.includes('class="blockquote-container image-dialogue"') ? `<script>
87
+ document.querySelectorAll(".image-container + .image-dialogue").forEach((dialogue) => {
88
+ const image = dialogue.previousElementSibling.querySelector("img");
89
+ const syncDialogueWidth = () => {
90
+ dialogue.style.setProperty("--dialogue-width", image.getBoundingClientRect().width + "px");
91
+ };
92
+ if (!image.complete) image.addEventListener("load", syncDialogueWidth, { once: true });
93
+ new ResizeObserver(syncDialogueWidth).observe(image);
94
+ syncDialogueWidth();
95
+ });
96
+ </script>` : ""}
86
97
  </body>
87
98
  </html>