about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-06-16T03·18-0400
committerglittershark <grfn@gws.fyi>2020-06-16T03·19+0000
commit098bbb4d67a0df8d191ba9a8665b86e8dbad7759 (patch)
tree0a9c705c2fcc187132f4fc94ef2619dbb73c3a57 /users
parent5ae449dcccc97c67d9ef239e089b4552a579114a (diff)
feat(gws.fyi): Make title work properly in index r/989
This is remarkably silly, but it gets the job done

Change-Id: Ifbc57988a59c4f51a3bba0ed8ad397cb9855d8ab
Reviewed-on: https://cl.tvl.fyi/c/depot/+/423
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'users')
-rw-r--r--users/glittershark/gws.fyi/config.el3
-rw-r--r--users/glittershark/gws.fyi/index.org3
-rw-r--r--users/glittershark/gws.fyi/orgExportHTML.nix30
-rw-r--r--users/glittershark/gws.fyi/site.nix4
4 files changed, 32 insertions, 8 deletions
diff --git a/users/glittershark/gws.fyi/config.el b/users/glittershark/gws.fyi/config.el
index d11f0e309d..b05d897d3d 100644
--- a/users/glittershark/gws.fyi/config.el
+++ b/users/glittershark/gws.fyi/config.el
@@ -1,3 +1,6 @@
 (require 'org)
 
 (setq org-html-postamble nil)
+
+(defadvice org-export-grab-title-from-buffer
+    (around org-export-grab-title-from-buffer-disable activate))
diff --git a/users/glittershark/gws.fyi/index.org b/users/glittershark/gws.fyi/index.org
index 2af54253db..18ed066b1c 100644
--- a/users/glittershark/gws.fyi/index.org
+++ b/users/glittershark/gws.fyi/index.org
@@ -1,3 +1,6 @@
+#+OPTIONS: title:nil
+#+HTML_HEAD: <title>griffin smith</title>
+
 my name is griffin ward smith (aka grfn, glittershark, gws) and i'm a software
 engineer and musician
 
diff --git a/users/glittershark/gws.fyi/orgExportHTML.nix b/users/glittershark/gws.fyi/orgExportHTML.nix
index b37be10045..153036789f 100644
--- a/users/glittershark/gws.fyi/orgExportHTML.nix
+++ b/users/glittershark/gws.fyi/orgExportHTML.nix
@@ -1,4 +1,4 @@
-{ pkgs, ... }:
+{ pkgs ? import <nixpkgs> {}, ... }:
 
 with pkgs;
 with lib;
@@ -20,14 +20,29 @@ let
 
 in
 
-src:
+opts:
 
 let
+  src = if isAttrs opts then opts.src else opts;
+  headline = if isAttrs opts then opts.headline else null;
+
+  bn = builtins.baseNameOf src;
+  filename = elemAt (splitString "." bn) 0;
 
   outName =
-    let bn = builtins.baseNameOf src;
-        filename = elemAt (splitString "." bn) 0;
-    in filename + ".html";
+    if isNull headline
+    then
+      let bn = builtins.baseNameOf src;
+          filename = elemAt (splitString "." bn) 0;
+      in filename + ".html"
+    else "${filename}-${replaceStrings [" "] ["-"] filename}.html";
+
+  escapeDoubleQuotes = replaceStrings ["\""] ["\\\""];
+
+  navToHeadline = optionalString (! isNull headline) ''
+    (search-forward "${escapeDoubleQuotes headline}")
+    (org-narrow-to-subtree)
+  '';
 
 in
 
@@ -38,8 +53,9 @@ runCommand outName {} ''
     --load ${./config.el} \
     --visit file.org \
     --eval "(progn
-      (require 'org)
+      ${escapeDoubleQuotes navToHeadline}
       (org-html-export-to-html))" \
     --kill
-  cp file.html $out
+  substitute file.html $out \
+    --replace '<title>&lrm;</title>' ""
 ''
diff --git a/users/glittershark/gws.fyi/site.nix b/users/glittershark/gws.fyi/site.nix
index 5a06203a6b..a74bee0bef 100644
--- a/users/glittershark/gws.fyi/site.nix
+++ b/users/glittershark/gws.fyi/site.nix
@@ -1,7 +1,9 @@
-args@{ pkgs, depot, ... }:
+args@{ pkgs ? import <nixpkgs> {}, ... }:
 
 let
+
   orgExportHTML = import ./orgExportHTML.nix args;
+
 in
 
 {