Skip to content

Commit 316e717

Browse files
committed
Update for changes to lcf
1 parent 1298a52 commit 316e717

File tree

8 files changed

+15
-9
lines changed

8 files changed

+15
-9
lines changed

deploy/404.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<meta property="og:title" content="Logan Forman / Dev-Dwarf" />
99
<meta property="og:locale" content="en_US" />
10+
<meta property="og:image" content="/assets/dd.png" />
1011
<link rel="canonical" href="http://lcfd.dev/" />
1112
<meta property="og:url" content="http://lcfd.dev/"/>
1213
<meta property="og:site_name" content="Logan Forman / Dev-Dwarf" />

deploy/contact.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<meta property="og:title" content="Logan Forman / Dev-Dwarf" />
99
<meta property="og:locale" content="en_US" />
10+
<meta property="og:image" content="/assets/dd.png" />
1011
<link rel="canonical" href="http://lcfd.dev/" />
1112
<meta property="og:url" content="http://lcfd.dev/"/>
1213
<meta property="og:site_name" content="Logan Forman / Dev-Dwarf" />

deploy/git-ssg.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<meta property="og:title" content="Logan Forman / Dev-Dwarf" />
99
<meta property="og:locale" content="en_US" />
10+
<meta property="og:image" content="/assets/dd.png" />
1011
<link rel="canonical" href="http://lcfd.dev/" />
1112
<meta property="og:url" content="http://lcfd.dev/"/>
1213
<meta property="og:site_name" content="Logan Forman / Dev-Dwarf" />

deploy/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<meta property="og:title" content="Logan Forman / Dev-Dwarf" />
99
<meta property="og:locale" content="en_US" />
10+
<meta property="og:image" content="/assets/dd.png" />
1011
<link rel="canonical" href="http://lcfd.dev/" />
1112
<meta property="og:url" content="http://lcfd.dev/"/>
1213
<meta property="og:site_name" content="Logan Forman / Dev-Dwarf" />

deploy/projects.html

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<meta property="og:title" content="Logan Forman / Dev-Dwarf" />
99
<meta property="og:locale" content="en_US" />
10+
<meta property="og:image" content="/assets/dd.png" />
1011
<link rel="canonical" href="http://lcfd.dev/" />
1112
<meta property="og:url" content="http://lcfd.dev/"/>
1213
<meta property="og:site_name" content="Logan Forman / Dev-Dwarf" />

deploy/technical/making-a-ssg1.html

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<meta property="og:title" content="Logan Forman / Dev-Dwarf" />
99
<meta property="og:locale" content="en_US" />
10+
<meta property="og:image" content="/assets/dd.png" />
1011
<link rel="canonical" href="http://lcfd.dev/" />
1112
<meta property="og:url" content="http://lcfd.dev/"/>
1213
<meta property="og:site_name" content="Logan Forman / Dev-Dwarf" />
@@ -28,7 +29,7 @@ <h2 id='intro'>Introduction</h2><p>
2829
<ol>
2930
<li> Easily extendable. Do exactly what I want, quickly.</li>
3031
<li> Markdown-like language to write pages/articles in.</li>
31-
<li> Small Codebase. Should be <1000 LOC.</li>
32+
<li> Small. Should be <1000 LOC.</li>
3233

3334
</ol>
3435
<hr>
@@ -109,7 +110,7 @@ <h2 id='parse'>Parsing Markdown</h2><p>
109110
}
110111
</code></pre>
111112
<p>
112-
The Text parsing is similar to the Block parsing, except each character is checked, and most nodes come in start/end pairs. Because I want to support composing formatting like <code>***bold-and-italic* just-bold**</code> generating <b><em>bold-and-italic</em> just-bold</b>, its not enough to just have <code>BOLD</code> node encapsulate the bolded text in a pair of tags. For this reason each text node has an <code>end</code> flag marking it as the start or end node of a pair:</p>
113+
The Text parsing is similar to the Block parsing, except each character is checked, and most nodes come in start/end pairs. Because I want to support composing formatting like <code>***bold-and-italic* just-bold**</code> generating <b><em>bold-and-italic</em> just-bold</b>, it's not enough to just have <code>BOLD</code> node encapsulate the bolded text in a pair of tags. For this reason each text node has an <code>end</code> flag marking it as the start or end node of a pair:</p>
113114
<pre><code id=''>for (; curr->next != 0; pre = curr, curr = curr->next) {
114115
str8 s = curr->text;
115116
if ((curr->type == Text::LIST_ITEM) /* Already formatted, do not parse */
@@ -200,7 +201,7 @@ <h2 id='compile'>Render as HTML</h2><p>
200201
<p>It's nice to be <b>loud</b>!</p>
201202
</code></pre>
202203
<p>
203-
With the above as the goal, its not hard to imagine rendering the parsed nodes to HTML using a couple loops:</p>
204+
With the above as the goal, it's not hard to imagine rendering the parsed nodes to HTML using a couple loops:</p>
204205
<pre><code id=''>Str8List render(Arena* arena, Block* root) {
205206
Str8List out = {0};
206207
for (Block* b = root; b->type != Block::NIL; b = b->next) {
@@ -319,7 +320,7 @@ <h2 id='generate'>Generating the site.</h2><p>
319320
}
320321
</code></pre>
321322
<p>
322-
And that's pretty much it for a heavily-idealized version of my static site generator! The actual thing can be found <a href='https://github.com/dev-dwarf/dev-dwarf.github.io'>on GitHub</a>. You may have noticed an unused type field for pages; the real version of the generator has <code>ARTICLE</code> pages and an <code>INDEX</code> page. <code>ARTICLE</code>s have slightly different HTML generated, and the <code>INDEX</code> gets a list of links to articles appended to it. I don't think its worth writing about these yet as they are very hacked in and I want to change that system soon! However I am pleased with how easy it is to quickly hack in features like those given what I have described here as a base.</p>
323+
And that's pretty much it for a heavily-idealized version of my static site generator! The actual thing can be found <a href='https://github.com/dev-dwarf/dev-dwarf.github.io'>on GitHub</a>. You may have noticed an unused type field for pages; the real version of the generator has <code>ARTICLE</code> pages and an <code>INDEX</code> page. <code>ARTICLE</code>s have slightly different HTML generated, and the <code>INDEX</code> gets a list of links to articles appended to it. I don't think it's worth writing about these yet as they are very hacked in and I want to change that system soon! However I am pleased with how easy it is to quickly hack in features like those given what I have described here as a base.</p>
323324
<hr>
324325
<h2 id='conc'>Conclusion</h2><p>
325326
Overall I'm pretty happy with the results of this project so far. The up-front time investment was a bit more than using Jekyll (about 4-days of hacking and writing), but for it I have a small, fast, and extendable static site generator tailored to my needs. The current version is ~700 LOC, well under the 1000 LOC goal. I already hacked in some basic features to write this article, but I'd like to rework these soon. In addition, there's quite a few things I'd like to add:</p>
@@ -328,7 +329,7 @@ <h2 id='conc'>Conclusion</h2><p>
328329
<li> Generate an RSS feed from recent articles.</li>
329330
<li> After the first compile of each page, run in the background checking for changes and compile files automatically. Right now I manually run <code>site.exe</code> to see my changes each time, but it would help my flow if that was taken care of for me.</li>
330331
<li> Introduce some sort of templating/custom generation for individual pages. I <b>abhor</b> how most generators handle this sort of feature so I'm excited to look for a unique approach. I'd prefer something where I can easily hack in new templates in C++ instead of using some bogus templating language.</li>
331-
<li> Additional miscellanous features like captions for images, subsections, and asides/expandable text. </li>
332+
<li> Additional miscellaneous features like captions for images, subsections, and asides/expandable text. </li>
332333

333334
</ol>
334335
<p>

deploy/writing.html

57 Bytes
Binary file not shown.

static-site-gen/site.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ void compile_page(Arena *longa, Arena *tempa, Page *page) {
177177
str8 first_line = str8_pop_at_first_delimiter(&dummy, str8_NEWLINE);
178178
page->title = str8_copy(longa, str8_cut(str8_skip(first_line, 2), 1));
179179
} else {
180-
page->title = str8_cut(page->filename, 4);
180+
page->title = str8_cut(page->filename, 3);
181181
}
182182

183183
printf("%.*s \"%.*s\" ", str8_PRINTF_ARGS(filename.str), str8_PRINTF_ARGS(page->title));
184184

185185
Str8List_pop_node(&dir);
186186

187-
filename.str = str8_concat(tempa, str8_cut(page->filename, 3), str8_lit("html\0"));
187+
filename.str = str8_concat(tempa, str8_cut(page->filename, 2), str8_lit("html\0"));
188188
Str8List_add_node(&dir, &filename);
189189

190190
Str8List html = {0};
@@ -236,7 +236,7 @@ void compile_page(Arena *longa, Arena *tempa, Page *page) {
236236
if (link->type == Page::ARTICLE) {
237237
Str8List_add(tempa, &html, str8_lit("<li><a href='"));
238238
Str8List_add(tempa, &html, link->base_href);
239-
Str8List_add(tempa, &html, str8_cut(link->filename,3));
239+
Str8List_add(tempa, &html, str8_cut(link->filename,2));
240240
Str8List_add(tempa, &html, str8_lit("html' id='"));
241241
Str8List_add(tempa, &html, link->filename);
242242
Str8List_add(tempa, &html, str8_lit("'>"));
@@ -250,7 +250,7 @@ void compile_page(Arena *longa, Arena *tempa, Page *page) {
250250
Str8List_add(tempa, &html, FOOTER);
251251

252252
switch_to_dir(&deploy);
253-
win32_write_file(build_dir(tempa).str, html);
253+
win32_write_file(build_dir(tempa), html);
254254

255255
printf("> %.*s%.*s\n", str8_PRINTF_ARGS(page->base_href), str8_PRINTF_ARGS(page->filename));
256256

0 commit comments

Comments
 (0)