blog.grace.moe

Source for the blog blog.grace.moe
git clone https://git.grace.moe/blog.grace.moe
Log | Files | Refs

commit 3a943ef4ee0e90b2315d57e1153166f976aa72c6
parent b2a2b9b40504c538d2a6c0393f29d0aeb2d40c73
Author: gracefu <81774659+gracefuu@users.noreply.github.com>
Date:   Fri,  2 May 2025 18:14:22 +0800

Improve page preloading further by only loading the content div instead of the whole html

Diffstat:
Mcontent/bio.smd | 5+++++
Mcontent/cs3211.smd | 5+++++
Mcontent/index.smd | 5+++++
Mcontent/posts/2025-01-14-popl-src.smd | 5+++++
Mcontent/posts/a.smd | 5+++++
Mcontent/posts/b.smd | 5+++++
Mcontent/posts/c.smd | 5+++++
Mcontent/posts/index.smd | 4++++
Mcontent/teaching.smd | 5+++++
Alayouts/index.raw.shtml | 11+++++++++++
Alayouts/page.raw.shtml | 26++++++++++++++++++++++++++
Alayouts/post.raw.shtml | 44++++++++++++++++++++++++++++++++++++++++++++
Alayouts/posts.raw.shtml | 25+++++++++++++++++++++++++
Mlayouts/templates/base.shtml | 4++--
14 files changed, 152 insertions(+), 2 deletions(-)

diff --git a/content/bio.smd b/content/bio.smd @@ -4,6 +4,11 @@ .author = "Grace Tan", .description = "Grace Tan's Bio", .layout = "page.shtml", +.alternatives = [{ + .name = "raw", + .layout = "page.raw.shtml", + .output = "index.raw.html", +}], .draft = false, --- diff --git a/content/cs3211.smd b/content/cs3211.smd @@ -4,6 +4,11 @@ .author = "Grace Tan", .description = "CS3211 Tutorial 10", .layout = "page.shtml", +.alternatives = [{ + .name = "raw", + .layout = "page.raw.shtml", + .output = "index.raw.html", +}], .draft = false, --- diff --git a/content/index.smd b/content/index.smd @@ -4,6 +4,11 @@ .author = "Grace Tan", .layout = "index.shtml", .description = "Hello! I am a PhD student studying weak memory models.", +.alternatives = [{ + .name = "raw", + .layout = "index.raw.shtml", + .output = "index.raw.html", +}], .draft = false, --- diff --git a/content/posts/2025-01-14-popl-src.smd b/content/posts/2025-01-14-popl-src.smd @@ -5,6 +5,11 @@ .description = "What happened at POPL SRC", .aliases = ["/posts/popl-2025-src/index.html"], .layout = "post.shtml", +.alternatives = [{ + .name = "raw", + .layout = "post.raw.shtml", + .output = "index.raw.html", +}], .draft = false, --- diff --git a/content/posts/a.smd b/content/posts/a.smd @@ -4,6 +4,11 @@ .author = "Grace Tan", .description = "What happened at POPL SRC", .layout = "post.shtml", +.alternatives = [{ + .name = "raw", + .layout = "post.raw.shtml", + .output = "index.raw.html", +}], .draft = true, --- diff --git a/content/posts/b.smd b/content/posts/b.smd @@ -4,6 +4,11 @@ .author = "Grace Tan", .description = "What happened at POPL SRC", .layout = "post.shtml", +.alternatives = [{ + .name = "raw", + .layout = "post.raw.shtml", + .output = "index.raw.html", +}], .draft = true, --- diff --git a/content/posts/c.smd b/content/posts/c.smd @@ -4,6 +4,11 @@ .author = "Grace Tan", .description = "What happened at POPL SRC", .layout = "post.shtml", +.alternatives = [{ + .name = "raw", + .layout = "post.raw.shtml", + .output = "index.raw.html", +}], .draft = true, --- diff --git a/content/posts/index.smd b/content/posts/index.smd @@ -8,6 +8,10 @@ .name = "rss", .layout = "posts.xml", .output = "index.xml", +},{ + .name = "raw", + .layout = "posts.raw.shtml", + .output = "index.raw.html", }], .draft = false, --- diff --git a/content/teaching.smd b/content/teaching.smd @@ -4,6 +4,11 @@ .author = "Grace Tan", .description = "My teaching experience", .layout = "page.shtml", +.alternatives = [{ + .name = "raw", + .layout = "page.raw.shtml", + .output = "index.raw.html", +}], .draft = false, --- diff --git a/layouts/index.raw.shtml b/layouts/index.raw.shtml @@ -0,0 +1,10 @@ +<div id="content"> + <style> + #post-header { + margin-block-end: 1.2em; + } + </style> + <main> + <article class="hierarchical limit-children" :html="$page.content()"></article> + </main> +</div> +\ No newline at end of file diff --git a/layouts/page.raw.shtml b/layouts/page.raw.shtml @@ -0,0 +1,25 @@ +<div id="content"> + <style> + #prev-next { + display: flex; + flex-direction: row; + justify-content: space-between; + margin-top: 40px; + } + + #post-header>p>time, + #post-header>p>span { + font-size: 0.8em; + } + </style> + <main> + <header id="post-header" class="non-hierarchical limit-children"> + <p> + <time class="date" datetime="$page.date.format('2006-01-02 15:04:05MST')" :text="$page.date.format('2006-01-02')"></time> + · + <span rel="author" :text="$page.author"></span> + </p> + </header> + <article id="post" class="hierarchical limit-children" :html="$page.content()"></article> + </main> +</div> +\ No newline at end of file diff --git a/layouts/post.raw.shtml b/layouts/post.raw.shtml @@ -0,0 +1,43 @@ +<div id="content"> + <style> + #prev-next { + padding-block: 15px; + padding-inline: 15px; + } + #prev-next>div:last-child { + text-align: end; + } + + #post-header { + margin-block-end: 1.2em; + } + #post-header>p>time, + #post-header>p>span { + font-size: 0.8em; + } + </style> + <main> + <header id="post-header" class="non-hierarchical limit-children"> + <p> + <time class="date" datetime="$page.date.format('2006-01-02 15:04:05MST')" :text="$page.date.format('2006-01-02')"></time> + · + <span rel="author" :text="$page.author"></span> + </p> + </header> + <article id="post" class="hierarchical limit-children" :html="$page.content()"></article> + </main> + <footer id="prev-next"> + <div :if="$page.prevPage?()"> + <a href="$if.link()"> + ← + <span :text="$if.title"></span> + </a> + </div> + <div :if="$page.nextPage?()"> + <a href="$if.link()"> + <span :text="$if.title"></span> + → + </a> + </div> + </footer> +</div> +\ No newline at end of file diff --git a/layouts/posts.raw.shtml b/layouts/posts.raw.shtml @@ -0,0 +1,24 @@ +<div id="content"> + <style> + .date, .author { + font-size: 0.8em; + } + + .post { + margin-block: 1.6em; + } + </style> + <main> + <div class="hierarchical limit-children" :html="$page.content()"></div> + <div class="limit-children" :loop="$page.subpages()"> + <section class="post"> + <a class="post-title" href="$loop.it.link()"> + <h3 :text="$loop.it.title"></h3> + </a> + <time class="date" datetime="$loop.it.date.format('2006-01-02 15:04:05MST')" :text="$loop.it.date.format('2006-01-02')"></time> + · + <span class="author" rel="author" :text="$loop.it.author"></span> + </section> + </div> + </main> +</div> +\ No newline at end of file diff --git a/layouts/templates/base.shtml b/layouts/templates/base.shtml @@ -371,7 +371,7 @@ console.log('ho', results[href]); resolve(results[href]); }); - req.open("GET", href); + req.open("GET", href + '/index.raw.html'); req.send(); }); } @@ -420,7 +420,7 @@ console.log('ho', results[href]); resolve(results[href]); }); - req.open("GET", href); + req.open("GET", href + '/index.raw.html'); req.send(); }); }