Skip to content

Commit

Permalink
Fix: add site title, author, and description to layouts (#41)
Browse files Browse the repository at this point in the history
- Add site title, author, and description to layouts public-api for SEO and accessibility.
- Update default layout
- Update head partial
- Make meta charset casing consistent with other attributes

- Update metadata table
  - Add site-author, site-desc, and site-title
  - Add site-url
  - Add firn-tags data type
  - Alphabetize and format
  • Loading branch information
Yosevu Kilonzo authored Oct 1, 2020
1 parent 77d896e commit a2a6b40
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
5 changes: 3 additions & 2 deletions clojure/resources/firn/_firn_starter/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
:firn-toc nil ; global: settings for any rendered table of contents
:ignored-dirs ["priv"] ; Directories to ignore org files in.
:run-build-clean? "never" ; Whether to clean out unused attachments on build. Values: "never" | "always" | "prompt"
:site-desc "" ; Used for RSS.
:site-title "" ; Used for RSS.
:site-author "" ; Used for SEO.
:site-desc "" ; Used for RSS and SEO.
:site-title "" ; Used for RSS and SEO.
:org-tags-path "tags" ; Path on which to structure links for org headline tags.
:site-url ""} ; Used for building links / accessing site url in layouts/partials. If Left blank, internal links will start with `/`
4 changes: 2 additions & 2 deletions clojure/resources/firn/_firn_starter/layouts/default.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defn default
[{:keys [render partials build-url]}]
[{:keys [render partials build-url site-title site-author site-desc] :as config}]
(let [{:keys [head]} partials]
[:html
(head build-url)
(head config)
[:body
[:main
[:article.content
Expand Down
7 changes: 5 additions & 2 deletions clojure/resources/firn/_firn_starter/partials/head.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
(defn head
[build-url]
[{:keys [build-url site-title site-author site-desc]}]
[:html
[:head
[:meta {:charset "UTF-8"}]
[:meta {:charset "utf-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1.0"}]
[:meta {:name "author" :content site-author}]
[:meta {:name "description" :content site-desc}]
[:title site-title]
[:link {:rel "stylesheet" :href (build-url "/static/css/firn_base.css")}]]])
3 changes: 3 additions & 0 deletions clojure/src/firn/layout.clj
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@
:site-map (config :site-map)
:site-links (config :site-links)
:site-logs (config :site-logs)
:site-title (-> config :user-config :site-title)
:site-author (-> config :user-config :site-author)
:site-desc (-> config :user-config :site-desc)
:site-url site-url
:org-tags (config :org-tags)
:firn-tags (config :firn-tags)
Expand Down
25 changes: 14 additions & 11 deletions docs/data-and-metadata.org
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#+TITLE: Data and Metadata
#+DATE_CREATED: <2020-03-25 Wed>
#+DATE_UPDATED: <2020-09-23 18:43>
#+DATE_UPDATED: <2020-09-29 22:26>
#+FIRN_UNDER: Content
#+FIRN_LAYOUT: docs
#+FIRN_ORDER: 20
Expand All @@ -25,29 +25,32 @@ you need more fine grained control of your data.

* Metadata

The following table describes all the data and functions "passed" to a layout each time a layout is applied to the data representing an org file. If the [[file:the-render-function.org][render function]] already does everything you need in your layouts, then this section may not be valuable for you.

The following table describes all the data and functions "passed" to a layout each time a layout is applied to the data representing an org file. If the [[file:the-render-function.org][render function]] already does everything you need in your layouts, then this section may not be valuable for you.

| Function/Data | Intent | Data-type |
|---------------+-------------------------------------------------------+-----------|
| config | The site wide config, containing everything! | map |
| build-url | Function to more easily construct internal urls | function |
| date-created | The ~#+DATE_CREATED~ value of the processed file | string |
| date-updated | The ~#+DATE_UPDATED~ value of the processed file | string |
| config | The site wide config, containing everything! | map |
| date-created | The ~#+DATE_CREATED~ value of the processed file | string |
| date-updated | The ~#+DATE_UPDATED~ value of the processed file | string |
| file | The file as a data structure | map |
| file-links | A list of links per file | list |
| firn-under | The ~#+FIRN_UNDER~ value of the file | string |
| firn-tags | A map of tag names mapped to files. | |
| firn-tags | A map of tag names mapped to files. | map |
| firn-under | The ~#+FIRN_UNDER~ value of the file | string |
| logbook | A list of logbook entries of the processed-file. | list |
| logbook-total | The sum of all the logbook entries per file | string |
| meta | A map of metadata per file (logbook, links, keywords) | map |
| org-tags | A map of or org tags and associated headlines. | map |
| partials | a list of invokable partials from the =/partials= dir | list |
| partials | a list of invokable partials from the =/partials= dir | list |
| render | See the [[file:the-render-function.org][Render Function document]] | function |
| site-author | The site author used for SEO. | string |
| site-desc | The site description used for RSS and SEO. | string |
| site-links | A list of all links across all documents | vector |
| site-logs | A list of all logbook entries | vector |
| site-map | A map of all files as sorted by ~#+FIRN_UNDER~ | map |
| title | The ~#+TITLE~ value of the file. | string |
| site-map | A map of all files as sorted by ~#+FIRN_UNDER~ | map |
| site-title | The site title used for RSS and SEO. | string |
| site-url | The site url used to build link in templates. | string |
| title | The ~#+TITLE~ value of the file. | string |

This may seem like a lot of information to make available to a layout template.
And that's because it is! But thanks to destructuring in Clojure, you can make
Expand Down

0 comments on commit a2a6b40

Please sign in to comment.