diff options
author | Martin Ashby <martin@ashbysoft.com> | 2024-03-04 16:24:45 +0000 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2024-03-10 22:03:45 +0000 |
commit | e12c0d23ad72ffa9389d90311453db535f57e450 (patch) | |
tree | 00e8caf78140dee2c9af4568d7d2fb083b80b906 | |
parent | 5ed483825a50cadb1d3d2dd55f9e4ebc52716660 (diff) | |
download | mfashby.net-e12c0d23ad72ffa9389d90311453db535f57e450.tar.gz mfashby.net-e12c0d23ad72ffa9389d90311453db535f57e450.tar.bz2 mfashby.net-e12c0d23ad72ffa9389d90311453db535f57e450.tar.xz mfashby.net-e12c0d23ad72ffa9389d90311453db535f57e450.zip |
Prepare to move to zine static site generator instead of hugo
https://zine-ssg.io/documentation/
40 files changed, 251 insertions, 544 deletions
diff --git a/archetypes/default.md b/archetypes/default.md deleted file mode 100644 index 0a0aae0..0000000 --- a/archetypes/default.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: "{{ replace .Name "-" " " | title }}" -date: {{ .Date }} -draft: true -params: - comments: true ---- - diff --git a/build.zig b/build.zig new file mode 100644 index 0000000..aa86e00 --- /dev/null +++ b/build.zig @@ -0,0 +1,14 @@ +const std = @import("std"); +const zine = @import("zine"); + +pub fn build(b: *std.Build) !void { + try zine.addWebsite(b, .{ + .layouts_dir_path = "layouts", + .content_dir_path = "content", + .static_dir_path = "static", + .site = .{ + .base_url = "https://sample.com", + .title = "Sample Website", + }, + }); +}
\ No newline at end of file diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..b803ff9 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,12 @@ +.{ + .name = "mfashby.net", + .version = "0.0.0", + .dependencies = .{ + .zine = .{ + //.url = "git+https://github.com/kristoff-it/zine.git#beb5434a04fad660ecf8db8379532dfe5b5e13b0", + //.hash = "12203c37cb5fb3931d3b7d1f1dace46cf5329ffe2fb5a8d2ac87dc78630ce7f601a7", + .path = "../zine", + }, + }, + .paths = .{"."}, +}
\ No newline at end of file diff --git a/converter/build.zig b/converter/build.zig new file mode 100644 index 0000000..10f855a --- /dev/null +++ b/converter/build.zig @@ -0,0 +1,36 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.standardTargetOptions(.{}); + const optimize = b.standardOptimizeOption(.{}); + + const exe = b.addExecutable(.{ + .name = "converter", + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); + // const zig_yaml = b.dependency("zig-yaml", .{}); + // exe.root_module.addImport("yaml", zig_yaml.module("yaml")); + + b.installArtifact(exe); + + const run_cmd = b.addRunArtifact(exe); + run_cmd.step.dependOn(b.getInstallStep()); + + if (b.args) |args| { + run_cmd.addArgs(args); + } + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); + + const exe_unit_tests = b.addTest(.{ + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); + + const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&run_exe_unit_tests.step); +} diff --git a/converter/build.zig.zon b/converter/build.zig.zon new file mode 100644 index 0000000..6e262b1 --- /dev/null +++ b/converter/build.zig.zon @@ -0,0 +1,14 @@ +.{ + .name = "converter", + .version = "0.0.0", + .dependencies = .{ + // It doesn't work! + //.@"zig-yaml" = .{ + // .url = "https://github.com/kubkon/zig-yaml/archive/refs/heads/main.tar.gz", + // .hash = "122084941d6e06491a85e1356c7cca24a078103d34155e34a10a16a53f420d6bc37b", + //}, + }, + .paths = .{ + "", + }, +} diff --git a/themes/XMin/layouts/partials/head_custom.html b/converter/convert_posts.zig index e69de29..e69de29 100644 --- a/themes/XMin/layouts/partials/head_custom.html +++ b/converter/convert_posts.zig diff --git a/converter/src/main.zig b/converter/src/main.zig new file mode 100644 index 0000000..bc60e35 --- /dev/null +++ b/converter/src/main.zig @@ -0,0 +1,41 @@ +const std = @import("std"); + +pub fn main() !void { + const a = std.heap.page_allocator; + const contentdir = try std.fs.cwd().openDir("../content", .{.iterate = true}); + var walker = try contentdir.walk(a); + while (try walker.next()) |we| { + if (std.mem.endsWith(u8, we.basename, ".md")) { + std.log.info("converting file {s}", .{we.basename}); + const file = try we.dir.readFileAlloc(a, we.basename, 1_000_000); + const start = (std.mem.indexOf(u8, file, "---\n") orelse return error.NoFrontmatter) + 4; + const end = (std.mem.lastIndexOf(u8, file, "---\n") orelse return error.NoFrontMatter); + + var childproc = std.process.Child.init(&.{"yq", "-o", "json"}, a); + childproc.stdin_behavior = .Pipe; + childproc.stdout_behavior = .Pipe; + childproc.stderr_behavior = .Pipe; + std.log.info("spawn", .{}); + try childproc.spawn(); + std.log.info("writeAll", .{}); + try childproc.stdin.?.writeAll(file[start..end]); + childproc.stdin.?.close(); + childproc.stdin = null; + + var stdout = std.ArrayList(u8).init(a); + var stderr = std.ArrayList(u8).init(a); + std.log.info("collectOutput", .{}); + try childproc.collectOutput(&stdout, &stderr, 1_000_000); + std.log.info("got output {s}", .{stdout.items}); + std.log.info("wait", .{}); + const term = try childproc.wait(); + if (term.Exited != 0) { + return error.ProcessError; + } + const fm_json = try stdout.toOwnedSlice(); + const newfile = try std.mem.concat(a, u8, &.{"---\n", fm_json, file[end..]}); + try we.dir.writeFile(we.basename, newfile); + } + } + std.log.info("done!", .{}); +}
\ No newline at end of file diff --git a/converter/src/root.zig b/converter/src/root.zig new file mode 100644 index 0000000..ecfeade --- /dev/null +++ b/converter/src/root.zig @@ -0,0 +1,10 @@ +const std = @import("std"); +const testing = std.testing; + +export fn add(a: i32, b: i32) i32 { + return a + b; +} + +test "basic add functionality" { + try testing.expect(add(3, 7) == 10); +} diff --git a/themes/XMin/layouts/404.html b/layouts/404.html index c2e4e40..c2e4e40 100644 --- a/themes/XMin/layouts/404.html +++ b/layouts/404.html diff --git a/layouts/list.html b/layouts/list.html new file mode 100644 index 0000000..f0329d5 --- /dev/null +++ b/layouts/list.html @@ -0,0 +1,13 @@ +<extend template="main.html"/> +<div id="main"> + <h1 var="$page.title"></h1> + + <p var="$page.content"></p> + + <ul> + <li loop="$site.pages()"> + <span class="date" var="$loop.it.date.format('02-Jan-2006')"></span> + <a href="$loop.it.permalink()" var="$loop.it.title"></a> + </li> + </ul> +</div>
\ No newline at end of file diff --git a/layouts/shortcodes/rawhtml.html b/layouts/shortcodes/rawhtml.html deleted file mode 100644 index 14e0ee9..0000000 --- a/layouts/shortcodes/rawhtml.html +++ /dev/null @@ -1,3 +0,0 @@ -<!-- https://anaulin.org/blog/hugo-raw-html-shortcode/ --> -<!-- raw html --> -{{.Inner}}
\ No newline at end of file diff --git a/layouts/single.html b/layouts/single.html new file mode 100644 index 0000000..4a8a12f --- /dev/null +++ b/layouts/single.html @@ -0,0 +1,8 @@ +<extend template="main.html"> +<div id="main"> + <div class="article-meta"> + <h1><span class="title" var=$page.title></span></h1> + </div> + <main var="$page.content"></main> +</div> +<extend>
\ No newline at end of file diff --git a/layouts/templates/main.html b/layouts/templates/main.html new file mode 100644 index 0000000..917bdce --- /dev/null +++ b/layouts/templates/main.html @@ -0,0 +1,59 @@ +<!DOCTYPE html> +<html lang="{{ .Site.LanguageCode }}"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title var="$page.title.suffix('|', $site.title)"></title> + <link rel="stylesheet" href="/css/style.css"/> + <link rel="stylesheet" href="/css/fonts.css"/> + </head> + + <body> + <nav> + <ul class="menu"> + <li><a href="/">home</a></li> + <li><a href="/">about</a></li> + <li><a href="/">rss</a></li> + </ul> + <hr/> + </nav> + + <div id="main"> + <super/> + </div> + + <footer> + {{ if or (.Params.author) (gt .Params.lastmod 0) }} + <div class="article-meta"> + {{ with .Params.author }}Author <span class="author">{{ . }}</span><br/>{{ end }} + {{ if (gt .Params.lastmod 0) }}Updated <span class="date">{{ .Lastmod.Format "January 02, 2006" }}</span><br/>{{ end }} + </div> + {{ end }} + + {{ if .Param "comments" }} + <h2>comments</h2> + <div style="visibility: hidden" id="comments">comments go here</div> + <div style="visibility: hidden" id="comment_form">comment form goes here</div> + <script> + let comments = document.getElementById("comments"); + let urlParam = new URLSearchParams(); + urlParam.append("url", document.location.href); + fetch(document.location.origin + "/api/comment?" + urlParam.toString()) + .then((response) => response.text()) + .then((data) => { + comments.innerHTML = data; + comments.style.visibility = "visible"; + }); + let form = document.getElementById("comment_form"); + fetch(document.location.origin + "/api/form?" + urlParam.toString()) + .then((response) => response.text()) + .then((data) => { + form.innerHTML = data; + form.style.visibility = "visible"; + }); + </script> + <noscript>Comments disabled without javascript!</noscript> + {{ end }} + </footer> + </body> +</html> diff --git a/layouts/shortcodes/video.html b/layouts/video.html index eba4d66..eba4d66 100644 --- a/layouts/shortcodes/video.html +++ b/layouts/video.html diff --git a/server/src/tmp.zig b/server/src/tmp.zig new file mode 100644 index 0000000..71a9865 --- /dev/null +++ b/server/src/tmp.zig @@ -0,0 +1,44 @@ +const std = @import("std"); + +test "slices" { + // option 1 slices + const a = std.testing.allocator; + var words_al = std.ArrayList([]const u8).init(a); + defer words_al.deinit(); + var toks = std.mem.tokenizeAny(u8, wordlist, "\n "); + while (toks.next()) |tok| { + try words_al.append(tok); + } + const words: []const[]const u8 = try words_al.toOwnedSlice(); // a slice is a pointer + length (so 2 x usize x length) + defer a.free(words); + + try std.testing.expectEqualStrings("bar", words[1]); // words accessed by index +} + +test "offsets" { + // option 2 offsets + const a = std.testing.allocator; + var offsets_al = std.ArrayList(u16).init(a); + defer offsets_al.deinit(); + try offsets_al.append(0); + for (wordlist, 0..) |ch,ix| { + if (ch == '\n' and ix < wordlist.len) { + try offsets_al.append(@intCast(ix+1)); // we know we have less than 2^16 words + } + } + const offsets = try offsets_al.toOwnedSlice(); // offsets are just u16 x length, so ~4x less memory on 64 bit systems. + defer a.free(offsets); + // words accessed by slicing wordlist using offsets + // be careful of edge cases i.e. accessing the last word in the list, not handled here. + const word = wordlist[offsets[1]..(offsets[2]-1)]; + try std.testing.expectEqualStrings("bar", word); +} + +const wordlist: []const u8 = +\\foo +\\bar +\\baz +\\I +\\like +\\cheese +; diff --git a/themes/XMin/static/css/fonts.css b/static/css/fonts.css index 8ffcecd..8ffcecd 100644 --- a/themes/XMin/static/css/fonts.css +++ b/static/css/fonts.css diff --git a/themes/XMin/static/css/style.css b/static/css/style.css index 6288f17..6288f17 100644 --- a/themes/XMin/static/css/style.css +++ b/static/css/style.css diff --git a/themes/XMin/.gitignore b/themes/XMin/.gitignore deleted file mode 100644 index ce130a0..0000000 --- a/themes/XMin/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.Rproj.user -.Rhistory -.RData -.Ruserdata -exampleSite/public diff --git a/themes/XMin/LICENSE.md b/themes/XMin/LICENSE.md deleted file mode 100644 index fa77e18..0000000 --- a/themes/XMin/LICENSE.md +++ /dev/null @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Yihui Xie - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/themes/XMin/README.md b/themes/XMin/README.md deleted file mode 100644 index 2cd5279..0000000 --- a/themes/XMin/README.md +++ /dev/null @@ -1,28 +0,0 @@ -# HUGO XMIN - -## _Keep it simple, but not simpler_ - -**XMin** is a Hugo theme written by [Yihui Xie](https://yihui.org) in about four hours: half an hour was spent on the Hugo templates, and 3.5 hours were spent on styling. The main motivation for writing this theme was to provide a really minimal example to beginners of Hugo templates. This XMin theme contains about 130 lines of code in total, including the code in HTML templates and CSS (also counting empty lines). - - -```bash -find . -not -path '*/exampleSite/*' \( -name '*.html' -o -name '*.css' \) | xargs wc -l -``` - -``` - 5 ./layouts/404.html - 12 ./layouts/_default/single.html - 20 ./layouts/_default/list.html - 13 ./layouts/_default/terms.html - 0 ./layouts/partials/foot_custom.html - 0 ./layouts/partials/head_custom.html - 9 ./layouts/partials/footer.html - 20 ./layouts/partials/header.html - 51 ./static/css/style.css - 7 ./static/css/fonts.css - 137 total -``` - -I can certainly further reduce the code, for example, by eliminating the CSS, but I believe a tiny bit of CSS can greatly improve readability. You cannot really find many CSS frameworks that only contain 50 lines of code. - -[![Screenshot](https://github.com/yihui/hugo-xmin/raw/master/images/screenshot.png)](https://xmin.yihui.org) diff --git a/themes/XMin/archetypes/default.md b/themes/XMin/archetypes/default.md deleted file mode 100644 index fb98e92..0000000 --- a/themes/XMin/archetypes/default.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: '' -date: '' ---- diff --git a/themes/XMin/exampleSite/config.yaml b/themes/XMin/exampleSite/config.yaml deleted file mode 100644 index 6b5e2eb..0000000 --- a/themes/XMin/exampleSite/config.yaml +++ /dev/null @@ -1,38 +0,0 @@ -baseurl: "/" -languageCode: "en-us" -title: "A minimal Hugo website" -theme: "hugo-xmin" -googleAnalytics: "" -disqusShortname: "" -ignoreFiles: ["\\.Rmd$", "\\.Rmarkdown$", "_cache$", "\\.knit\\.md$", "\\.utf8\\.md$"] -footnotereturnlinkcontents: "↩" - -permalinks: - note: "/note/:year/:month/:day/:slug/" - post: "/post/:year/:month/:day/:slug/" - -menu: - main: - - name: Home - url: "" - weight: 1 - - name: About - url: "about/" - weight: 2 - - name: Categories - url: "categories/" - weight: 3 - - name: Tags - url: "tags/" - weight: 4 - - name: Subscribe - url: "index.xml" - -params: - description: "A website built through Hugo and blogdown." - footer: "© [Yihui Xie](https://yihui.org) 2017 -- 2020 | [Github](https://github.com/yihui) | [Twitter](https://twitter.com/xieyihui)" - -markup: - goldmark: - renderer: - unsafe: true diff --git a/themes/XMin/exampleSite/content/_index.Rmarkdown b/themes/XMin/exampleSite/content/_index.Rmarkdown deleted file mode 100644 index bae7bb6..0000000 --- a/themes/XMin/exampleSite/content/_index.Rmarkdown +++ /dev/null @@ -1,25 +0,0 @@ ---- -title: Home ---- - -[<img src="https://simpleicons.org/icons/github.svg" style="max-width:15%;min-width:40px;float:right;" alt="Github repo" />](https://github.com/yihui/hugo-xmin) - -# HUGO XMIN - -## _Keep it simple, but not simpler_ - -**XMin** is a Hugo theme written by [Yihui Xie](https://yihui.org) in about four hours: half an hour was spent on the Hugo templates, and 3.5 hours were spent on styling. The main motivation for writing this theme was to provide a really minimal example to beginners of Hugo templates. This XMin theme contains about 130 lines of code in total, including the code in HTML templates and CSS (also counting empty lines). - -```{bash, comment='', echo=3, eval=Sys.which('bash') != '', message=FALSE} -cd ../..; -if [ ! -f 'theme.toml' ]; then exit 0; fi # only run find below within the theme example site -find . -not -path '*/exampleSite/*' \( -name '*.html' -o -name '*.css' \) | xargs wc -l -``` - -I can certainly further reduce the code, for example, by eliminating the CSS, but I believe a tiny bit of CSS can greatly improve readability. You cannot really find many CSS frameworks that only contain 50 lines of code. - -Although it is a minimal theme, it is actually fully functional. It supports pages (including the home page), blog posts, a navigation menu, categories, tags, and RSS. With [a little bit customization](https://github.com/yihui/hugo-xmin/blob/master/exampleSite/layouts/partials/foot_custom.html), it can easily support LaTeX math expressions, e.g., - -`$${\sqrt {n}}\left(\left({\frac {1}{n}}\sum _{i=1}^{n}X_{i}\right)-\mu \right)\ {\xrightarrow {d}}\ N\left(0,\sigma ^{2}\right)$$` - -All pages not under the root directory of the website are listed below. You can also visit the list page of a single section, e.g., [posts](/post/), or [notes](/note/). See the [About](/about/) page for the usage of this theme. diff --git a/themes/XMin/exampleSite/content/_index.markdown b/themes/XMin/exampleSite/content/_index.markdown deleted file mode 100644 index 5a92003..0000000 --- a/themes/XMin/exampleSite/content/_index.markdown +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: Home ---- - -[<img src="https://simpleicons.org/icons/github.svg" style="max-width:15%;min-width:40px;float:right;" alt="Github repo" />](https://github.com/yihui/hugo-xmin) - -# HUGO XMIN - -## _Keep it simple, but not simpler_ - -**XMin** is a Hugo theme written by [Yihui Xie](https://yihui.org) in about four hours: half an hour was spent on the Hugo templates, and 3.5 hours were spent on styling. The main motivation for writing this theme was to provide a really minimal example to beginners of Hugo templates. This XMin theme contains about 130 lines of code in total, including the code in HTML templates and CSS (also counting empty lines). - - -```bash -find . -not -path '*/exampleSite/*' \( -name '*.html' -o -name '*.css' \) | xargs wc -l -``` - -``` - 5 ./layouts/404.html - 12 ./layouts/_default/single.html - 20 ./layouts/_default/list.html - 13 ./layouts/_default/terms.html - 0 ./layouts/partials/foot_custom.html - 0 ./layouts/partials/head_custom.html - 9 ./layouts/partials/footer.html - 20 ./layouts/partials/header.html - 51 ./static/css/style.css - 7 ./static/css/fonts.css - 137 total -``` - -I can certainly further reduce the code, for example, by eliminating the CSS, but I believe a tiny bit of CSS can greatly improve readability. You cannot really find many CSS frameworks that only contain 50 lines of code. - -Although it is a minimal theme, it is actually fully functional. It supports pages (including the home page), blog posts, a navigation menu, categories, tags, and RSS. With [a little bit customization](https://github.com/yihui/hugo-xmin/blob/master/exampleSite/layouts/partials/foot_custom.html), it can easily support LaTeX math expressions, e.g., - -`$${\sqrt {n}}\left(\left({\frac {1}{n}}\sum _{i=1}^{n}X_{i}\right)-\mu \right)\ {\xrightarrow {d}}\ N\left(0,\sigma ^{2}\right)$$` - -All pages not under the root directory of the website are listed below. You can also visit the list page of a single section, e.g., [posts](/post/), or [notes](/note/). See the [About](/about/) page for the usage of this theme. diff --git a/themes/XMin/exampleSite/content/about.md b/themes/XMin/exampleSite/content/about.md deleted file mode 100644 index 210bb35..0000000 --- a/themes/XMin/exampleSite/content/about.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: About Hugo XMin -author: Yihui Xie ---- - -**XMin** is the first Hugo theme I have designed. The original reason that I wrote it was I needed a minimal example of Hugo themes when I was writing the [**blogdown**](https://github.com/rstudio/blogdown) book. Basically I wanted a simple theme that supports a navigation menu, a home page, other single pages, lists of pages, blog posts, categories, tags, and RSS. That is all. Nothing fancy. In terms of CSS and JavaScript, I really want to keep them minimal. In fact, this theme does not contain any JavaScript code at all, although on this example website I did introduce some JavaScript code (still relatively simple anyway). The theme does not contain any images, either, and is pretty much a plain-text theme. - -The theme name "XMin" can be interpreted as "**X**ie's **Min**imal theme" (Xie is my last name) or "e**X**tremely **Min**imal theme". - -# config.toml - -For this example site, I defined permalinks for two sections, `post` and `note`, so that the links to pages under these directories will contain the date info, e.g., `https://xmin.yihui.org/post/2016/02/14/a-plain-markdown-post/`. This is optional, and it is up to your personal taste of URLs. - -``` -[permalinks] - post = "/post/:year/:month/:day/:slug/" - note = "/note/:year/:month/:day/:slug/" -``` - -You can define the menu through `menu.main`, e.g., - -``` -[[menu.main]] - name = "Home" - url = "/" - weight = 1 -[[menu.main]] - name = "About" - url = "/about/" - weight = 2 -[[menu.main]] - name = "Categories" - url = "/categories/" - weight = 3 -[[menu.main]] - name = "Tags" - url = "/tags/" - weight = 4 -[[menu.main]] - name = "Subscribe" - url = "/index.xml" -``` - -Alternatively, you can add `menu: main` to the YAML metadata of any of your pages, so that these pages will appear in the menu. - -The page footer can be defined in `.Params.footer`, and the text is treated as Markdown, e.g., - -``` -[params] - footer = "© [Yihui Xie](https://yihui.org) 2017" -``` - -# Custom layouts - -There are two layout files under `layouts/partials/` that you may want to override: `head_custom.html` and `foot_custom.html`. This is how you inject arbitrary HTML code to the head and foot areas. For example, this site has a file `layouts/partials/foot_custom.html` to support LaTeX math via MathJax and center images automatically: - -```html -<script src="//yihui.org/js/math-code.js"></script> -<script async src="//cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"> -</script> - -<script async src="//yihui.org/js/center-img.js"></script> -``` - -You can certainly enable highlight.js for syntax highlighting by yourself through `head_custom.html` and `foot_custom.html` if you want. - -If you do not like the default fonts (e.g., `Palatino`), you may provide your own `static/css/fonts.css` under the root directory of your website to override the `fonts.css` in the theme. - -# Other features - -I could have added more features to this theme, but I decided not to, since I have no intention to make this theme feature-rich. However, I will teach you how. I have prepared several examples via pull requests at https://github.com/yihui/hugo-xmin/pulls, so that you can see the implementations of these features when you check out the diffs in the pull requests. For example, you can: - -- [Enable Google Analytics](https://github.com/yihui/hugo-xmin/pull/3) - -- [Enable Disqus comments](https://github.com/yihui/hugo-xmin/pull/4) - -- [Enable highlight.js for syntax highlighting of code blocks](https://github.com/yihui/hugo-xmin/pull/5) - -- [Display categories and tags on a page](https://github.com/yihui/hugo-xmin/pull/2) - -- [Add a table of contents](https://github.com/yihui/hugo-xmin/pull/7) - -- [Add a link in the footer of each page to "Edit this page" on Github](https://github.com/yihui/hugo-xmin/pull/6) - -To fully understand these examples, you have to read [the section on Hugo templates](https://bookdown.org/yihui/blogdown/templates.html) in the **blogdown** book. - -# Design philosophy - -Lastly, a few words about my design philosophy for this theme: I have been relying on existing frameworks like Bootstrap for years since I'm not really a designer, and I was always scared by the complexity of CSS. - -When I started writing this theme, I asked myself, "_What if I just write from scratch?_" No Bootstrap. No Normalize.css. I don't care about IE (life could be so much easier without IE) or inconsistencies among browsers (for personal websites). As long as the theme looks okay in Chrome, Firefox, and Safari, I'm done. Thanks to the simplicity of Markdown, you cannot really produce very complicated HTML, and I think styling the HTML output from Markdown is much simpler than general HTML documents. For example, I do not need to care much about form elements like textareas or buttons. - -After I finished this theme, I started to wonder why I'd need `normalize.css` at all (it sounds like a religious belief). The default appearance of modern browsers actually looks pretty good in my eyes, after I tweak the typeface a little bit. - -Compared to inconsistencies across browsers, I care much more about these properties of HTML elements: - -- Tables should always be centered, and striped tables are easier to read especially when they are wide. Tables should not have vertical borders. -- An image should be centered if it is the only child element of a paragraph. -- The `max-width` of images, videos, and iframes should be `100%`. - -I hope you can enjoy this theme. The source code is [on Github](https://github.com/yihui/hugo-xmin). Happy hacking! diff --git a/themes/XMin/exampleSite/content/note/2017-06-13-a-quick-note.md b/themes/XMin/exampleSite/content/note/2017-06-13-a-quick-note.md deleted file mode 100644 index 9d855a4..0000000 --- a/themes/XMin/exampleSite/content/note/2017-06-13-a-quick-note.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: A Quick Note on Two Beautiful Websites -author: Yihui Xie -date: '2017-06-13' -categories: - - Example -slug: a-quick-note ---- - -To me, the two most impressive websites based on **blogdown** are: - -1. [Rob J Hyndman](https://robjhyndman.com)'s personal website. -1. [Live Free or Dichotomize](http://livefreeordichotomize.com) by Lucy and Nick _et al_. - -I'm sure there will be more. diff --git a/themes/XMin/exampleSite/content/note/2017-06-14-another-note.md b/themes/XMin/exampleSite/content/note/2017-06-14-another-note.md deleted file mode 100644 index 76442de..0000000 --- a/themes/XMin/exampleSite/content/note/2017-06-14-another-note.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: Another Note on A blogdown Tutorial -author: Yihui Xie -date: '2017-06-14' -categories: - - Example -tags: - - Tutorial -slug: another-note ---- - -I just discovered [an awesome tutorial](https://apreshill.rbind.io/post/up-and-running-with-blogdown/) on **blogdown** written by Alison. I have to admit this is _the_ best **blogdown** tutorial I have seen so far. - -![Alison's blogdown tutorial](https://alison.rbind.io/post/2017-06-12-up-and-running-with-blogdown/blogdown-signpost-1.png) diff --git a/themes/XMin/exampleSite/content/post/2015-07-23-lorem-ipsum.md b/themes/XMin/exampleSite/content/post/2015-07-23-lorem-ipsum.md deleted file mode 100644 index ef58622..0000000 --- a/themes/XMin/exampleSite/content/post/2015-07-23-lorem-ipsum.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Lorem Ipsum -date: '2015-07-23' -categories: - - Example -tags: - - Markdown ---- - -**Lorem ipsum** dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore _magna aliqua_. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. - -Quisque mattis volutpat lorem vitae feugiat. Praesent porta est quis porta imperdiet. Aenean porta, mi non cursus volutpat, mi est mollis libero, id suscipit orci urna a augue. In fringilla euismod lacus, vitae tristique massa ultricies vitae. Mauris accumsan ligula tristique, viverra nulla sed, porta sapien. Vestibulum facilisis nec nisl blandit convallis. Maecenas venenatis porta malesuada. Ut ac erat tortor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla sodales quam sit amet tincidunt egestas. In et turpis at orci vestibulum ullamcorper. Aliquam sed ante libero. Sed hendrerit arcu lacus. - -> Sed luctus volutpat sem in dapibus. Ut pellentesque vitae magna ac mattis. Sed vestibulum, nulla at condimentum semper, magna quam posuere dui, quis sagittis enim nisi eget ex. Vivamus tempor erat a sem dapibus porta. Fusce varius dapibus tempus. Nam bibendum dignissim fringilla. Phasellus eu justo facilisis, ullamcorper urna in, feugiat mauris. Quisque dignissim purus vitae ullamcorper scelerisque. Sed at magna at nisi consequat euismod. Curabitur justo ex, efficitur in fermentum luctus, tincidunt nec lectus. Aliquam a neque metus. Etiam nulla nunc, tristique vitae accumsan ullamcorper, placerat eget nunc. Cras porta eleifend dolor maximus molestie. Etiam vitae pellentesque turpis, quis accumsan ligula. Mauris auctor, nisi nec ullamcorper pulvinar, libero magna sagittis enim, sollicitudin dignissim urna justo et tortor. - -Morbi non sem euismod, suscipit purus id, gravida velit. Quisque mollis luctus ligula non suscipit. Curabitur massa arcu, aliquam ac dolor a, pellentesque dignissim dui. Donec at vestibulum magna. Quisque fermentum, tortor id sodales egestas, ligula ligula interdum ipsum, et volutpat elit massa vitae nibh. Morbi eleifend libero quis pretium viverra. Etiam congue, velit ac vestibulum finibus, velit nibh fringilla purus, eu semper dui est eu nunc. Etiam feugiat scelerisque diam vitae sodales. Etiam luctus in urna eu lobortis. Nam vestibulum eros et nibh elementum ullamcorper. Nam tristique porttitor orci, nec pretium est vestibulum at. Quisque posuere semper orci, vel semper justo commodo sed. Nullam accumsan risus rhoncus fringilla porta. Morbi interdum condimentum pharetra. Donec eu elit quam. Vivamus eleifend posuere mi, vel accumsan urna sollicitudin ut. - -Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla nec nunc felis. Sed bibendum vel leo id semper. Maecenas vitae iaculis ante. Nam ut tempor est, eu molestie augue. Quisque tincidunt sagittis odio sed tristique. Aenean et felis quis mi viverra consequat. diff --git a/themes/XMin/exampleSite/content/post/2016-02-14-hello-markdown.md b/themes/XMin/exampleSite/content/post/2016-02-14-hello-markdown.md deleted file mode 100644 index 21ee28d..0000000 --- a/themes/XMin/exampleSite/content/post/2016-02-14-hello-markdown.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -title: A Plain Markdown Post -author: Yihui Xie -date: '2016-02-14' -categories: - - Example - - Hugo -tags: - - blogdown - - Markdown - - MathJax - - Pandoc - - RStudio ---- - -This sample post is mainly for [**blogdown**](https://github.com/rstudio/blogdown) users. If you do not use **blogdown**, you can skip the first section. - -# 1. Markdown or R Markdown - -This is a post written in plain Markdown (`*.md`) instead of R Markdown (`*.Rmd`). The major differences are: - -1. You cannot run any R code in a plain Markdown document, whereas in an R Markdown document, you can embed R code chunks (```` ```{r} ````); -2. A plain Markdown post is rendered through [Blackfriday](https://gohugo.io/overview/configuration/), and an R Markdown document is compiled by [**rmarkdown**](http://rmarkdown.rstudio.com) and [Pandoc](http://pandoc.org). - -There are many differences in syntax between Blackfriday's Markdown and Pandoc's Markdown. For example, you can write a task list with Blackfriday but not with Pandoc: - -- [x] Write an R package. -- [ ] Write a book. -- [ ] ... -- [ ] Profit! - -Similarly, Blackfriday does not support LaTeX math and Pandoc does. I have added the MathJax support to this theme ([hugo-xmin](https://github.com/yihui/hugo-xmin)) but there is a caveat for plain Markdown posts: you have to include math expressions in a pair of backticks (inline: `` `$ $` ``; display style: `` `$$ $$` ``), e.g., `$S_n = \sum_{i=1}^n X_i$`.^[This is because we have to protect the math expressions from being interpreted as Markdown.] For R Markdown posts, you do not need the backticks, because Pandoc can identify and process math expressions. - -When creating a new post, you have to decide whether the post format is Markdown or R Markdown, and this can be done via the `rmd` argument of the function `blogdown::new_post()`, e.g. - -```r -blogdown::new_post("Post Title", rmd = FALSE) -``` - -Actually I recommend you to use the RStudio addin "New Post" instead: - -![RStudio addin New Post](https://bookdown.org/yihui/blogdown/images/new-post.png) - -# 2. Sample Text - -## Second-level header - -### Third-level header - -#### Fourth-level header - -A paragraph (with a footnote): - -**Lorem ipsum** dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore _magna aliqua_. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.^[I'm sure you are bored by the text here.] - -A blockquote (a gray bar at the left and lightgray background): - -> Quisque mattis volutpat lorem vitae feugiat. Praesent porta est quis porta imperdiet. Aenean porta, mi non cursus volutpat, mi est mollis libero, id suscipit orci urna a augue. In fringilla euismod lacus, vitae tristique massa ultricies vitae. Mauris accumsan ligula tristique, viverra nulla sed, porta sapien. Vestibulum facilisis nec nisl blandit convallis. Maecenas venenatis porta malesuada. Ut ac erat tortor. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla sodales quam sit amet tincidunt egestas. In et turpis at orci vestibulum ullamcorper. Aliquam sed ante libero. Sed hendrerit arcu lacus. - -Some code (with a drop-shadow effect): - -```js -(function() { - var quotes = document.getElementsByTagName('blockquote'), i, quote; - for (i = 0; i < quotes.length; i++) { - quote = quotes[i]; - var n = quote.children.length; - if (n === 0) continue; - var el = quote.children[n - 1]; - if (!el || el.nodeName !== 'P') continue; - // right-align a quote footer if it starts with --- - if (/^—/.test(el.textContent)) el.style.textAlign = 'right'; - } -})(); -``` - -A table (centered by default): - -| Sepal.Length| Sepal.Width| Petal.Length| Petal.Width|Species | -|------------:|-----------:|------------:|-----------:|:-------| -| 5.1| 3.5| 1.4| 0.2|setosa | -| 4.9| 3.0| 1.4| 0.2|setosa | -| 4.7| 3.2| 1.3| 0.2|setosa | -| 4.6| 3.1| 1.5| 0.2|setosa | -| 5.0| 3.6| 1.4| 0.2|setosa | -| 5.4| 3.9| 1.7| 0.4|setosa | - -An image (automatically centered when it is appropriate): - -![Happy Elmo](https://slides.yihui.org/gif/happy-elmo.gif) - -Looks good? diff --git a/themes/XMin/exampleSite/layouts/partials/foot_custom.html b/themes/XMin/exampleSite/layouts/partials/foot_custom.html deleted file mode 100644 index 3389d46..0000000 --- a/themes/XMin/exampleSite/layouts/partials/foot_custom.html +++ /dev/null @@ -1,4 +0,0 @@ -<script src="//yihui.org/js/math-code.js"></script> -<script async src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script> - -<script async src="//yihui.org/js/center-img.js"></script> diff --git a/themes/XMin/hugo-xmin.Rproj b/themes/XMin/hugo-xmin.Rproj deleted file mode 100644 index d64e28b..0000000 --- a/themes/XMin/hugo-xmin.Rproj +++ /dev/null @@ -1,16 +0,0 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: knitr -LaTeX: pdfLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes diff --git a/themes/XMin/images/screenshot.png b/themes/XMin/images/screenshot.png Binary files differdeleted file mode 100644 index 3df0a14..0000000 --- a/themes/XMin/images/screenshot.png +++ /dev/null diff --git a/themes/XMin/images/tn.png b/themes/XMin/images/tn.png Binary files differdeleted file mode 100644 index 389a20c..0000000 --- a/themes/XMin/images/tn.png +++ /dev/null diff --git a/themes/XMin/layouts/_default/list.html b/themes/XMin/layouts/_default/list.html deleted file mode 100644 index 2ab6958..0000000 --- a/themes/XMin/layouts/_default/list.html +++ /dev/null @@ -1,20 +0,0 @@ -{{ partial "header.html" . }} - -{{if not .IsHome }} -<h1>{{ .Title | markdownify }}</h1> -{{ end }} - -{{ .Content }} - -<ul> - {{ $pages := .Pages }} - {{ if .IsHome }}{{ $pages = .Site.RegularPages }}{{ end }} - {{ range (where $pages "Section" "!=" "") }} - <li> - <span class="date">{{ .Date.Format "2006/01/02" }}</span> - <a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a> - </li> - {{ end }} -</ul> - -{{ partial "footer.html" . }}
\ No newline at end of file diff --git a/themes/XMin/layouts/_default/single.html b/themes/XMin/layouts/_default/single.html deleted file mode 100644 index ed638ae..0000000 --- a/themes/XMin/layouts/_default/single.html +++ /dev/null @@ -1,10 +0,0 @@ -{{ partial "header.html" . }} -<div class="article-meta"> -<h1><span class="title">{{ .Title | markdownify }}</span></h1> -</div> - -<main> -{{ .Content }} -</main> - -{{ partial "footer.html" . }} diff --git a/themes/XMin/layouts/_default/terms.html b/themes/XMin/layouts/_default/terms.html deleted file mode 100644 index 71f47e7..0000000 --- a/themes/XMin/layouts/_default/terms.html +++ /dev/null @@ -1,13 +0,0 @@ -{{ partial "header.html" . }} - -<h1>{{ .Title }}</h1> - -<ul class="terms"> - {{ range .Data.Terms }} - <li> - <a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a> ({{ .Count }}) - </li> - {{ end }} -</ul> - -{{ partial "footer.html" . }} diff --git a/themes/XMin/layouts/partials/foot_custom.html b/themes/XMin/layouts/partials/foot_custom.html deleted file mode 100644 index 970c41c..0000000 --- a/themes/XMin/layouts/partials/foot_custom.html +++ /dev/null @@ -1,24 +0,0 @@ -{{ if .Param "comments" }} -<h2>comments</h2> -<div style="visibility: hidden" id="comments">comments go here</div> -<div style="visibility: hidden" id="comment_form">comment form goes here</div> -<script> - let comments = document.getElementById("comments"); - let urlParam = new URLSearchParams(); - urlParam.append("url", document.location.href); - fetch(document.location.origin + "/api/comment?" + urlParam.toString()) - .then((response) => response.text()) - .then((data) => { - comments.innerHTML = data; - comments.style.visibility = "visible"; - }); - let form = document.getElementById("comment_form"); - fetch(document.location.origin + "/api/form?" + urlParam.toString()) - .then((response) => response.text()) - .then((data) => { - form.innerHTML = data; - form.style.visibility = "visible"; - }); -</script> -<noscript>Comments disabled without javascript!</noscript> -{{ end }}
\ No newline at end of file diff --git a/themes/XMin/layouts/partials/footer.html b/themes/XMin/layouts/partials/footer.html deleted file mode 100644 index 082588d..0000000 --- a/themes/XMin/layouts/partials/footer.html +++ /dev/null @@ -1,16 +0,0 @@ - <footer> - {{ if or (.Params.author) (gt .Params.lastmod 0) }} - <div class="article-meta"> - {{ with .Params.author }}Author <span class="author">{{ . }}</span><br/>{{ end }} - {{ if (gt .Params.lastmod 0) }}Updated <span class="date">{{ .Lastmod.Format "2006/01/02" }}</span><br/>{{ end }} - </div> - {{ end }} - - {{ partial "foot_custom.html" . }} - {{ with .Site.Params.footer }} - <hr/> - {{ . | markdownify }} - {{ end }} - </footer> - </body> -</html> diff --git a/themes/XMin/layouts/partials/header.html b/themes/XMin/layouts/partials/header.html deleted file mode 100644 index 4f431eb..0000000 --- a/themes/XMin/layouts/partials/header.html +++ /dev/null @@ -1,20 +0,0 @@ -<!DOCTYPE html> -<html lang="{{ .Site.LanguageCode }}"> - <head> - <meta charset="utf-8"> - <meta name="viewport" content="width=device-width, initial-scale=1"> - <title>{{ .Title }} | {{ .Site.Title }}</title> - <link rel="stylesheet" href="{{ "/css/style.css" | relURL }}" /> - <link rel="stylesheet" href="{{ "/css/fonts.css" | relURL }}" /> - {{ partial "head_custom.html" . }} - </head> - - <body> - <nav> - <ul class="menu"> - {{ range .Site.Menus.main }} - <li><a href="{{ .URL | relURL }}">{{ .Name }}</a></li> - {{ end }} - </ul> - <hr/> - </nav> diff --git a/themes/XMin/theme.toml b/themes/XMin/theme.toml deleted file mode 100644 index 4233eb6..0000000 --- a/themes/XMin/theme.toml +++ /dev/null @@ -1,12 +0,0 @@ -name = "XMin" -license = "MIT" -licenselink = "https://github.com/yihui/hugo-xmin/blob/master/LICENSE.md" -description = "eXtremely Minimal Hugo theme: about 150 lines of code in total, including HTML and CSS" -homepage = "https://xmin.yihui.org" -tags = ["minimal", "blog", "personal", "clean", "simple", "starter", "minimalist"] -features = ["blog"] -min_version = "0.18" - -[author] - name = "Yihui Xie" - homepage = "https://yihui.org" |