Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
Port of the Hyde theme to styx
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsagnes committed Oct 14, 2016
1 parent 4f9b5e0 commit 5772139
Show file tree
Hide file tree
Showing 24 changed files with 1,164 additions and 0 deletions.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Released under MIT License

Copyright (c) 2013 Mark Otto.

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.
12 changes: 12 additions & 0 deletions example/conf.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
# URL of the site, must be set to the url of the domain the site will be deployed
siteUrl = "http://yourdomain.com";

# Theme specific settings
# it is possible to override any of the theme configuration settings in the 'theme' set
theme = {
# Example, changing the default theme site.title setting
site.title = "Styx Site";
};

}
3 changes: 3 additions & 0 deletions example/pages/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# About

Styx is a static site generator based on the [Nix package manager](http://nixos.org/nix/).
9 changes: 9 additions & 0 deletions example/posts/2016-09-12-welcome-to-styx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{---
tags = [ "styx" ];
---}

# Welcome to Styx

You'll find this post in your `posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `styx serve`, which launches a web server.

To add new posts, simply add a file in the `posts` directory that follows the convention `YYYY-MM-DD-name-of-post.md`. Take a look at the source for this post to get an idea about how it works.
11 changes: 11 additions & 0 deletions example/posts/2016-09-13-using-themes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{---
tags = [ "themes" "styx" ];
level = [ "beginner" ];
---}

# Using themes

You'll find this post in your `posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `styx serve`, which launches a web server.

To add new posts, simply add a file in the `posts` directory that follows the convention `YYYY-MM-DD-name-of-post.md`. Take a look at the source for this post to get an idea about how it works.

172 changes: 172 additions & 0 deletions example/site.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/*-----------------------------------------------------------------------------
Init
Initialization of Styx, should not be edited
-----------------------------------------------------------------------------*/

{ pkgs ? import <nixpkgs> {}
, styxLib
, renderDrafts ? false
, siteUrl ? null
, lastChange ? null
}@args:

let lib = import styxLib pkgs;
in with lib;

let

/* Configuration loading
*/
conf = let
conf = import ./conf.nix;
themesConf = lib.themes.loadConf { inherit themes themesDir; };
mergedConf = recursiveUpdate themesConf conf;
in
overrideConf mergedConf args;

/* Site state
*/
state = { inherit lastChange; };

/* Load themes templates
*/
templates = lib.themes.loadTemplates {
inherit themes defaultEnvironment customEnvironments themesDir;
};

/* Load themes static files
*/
files = lib.themes.loadFiles {
inherit themes themesDir;
};


/*-----------------------------------------------------------------------------
Themes setup
-----------------------------------------------------------------------------*/

/* Themes location
*/
themesDir = ../..;

/* Themes used
*/
themes = [ "hyde" ];


/*-----------------------------------------------------------------------------
Template enviroments
-----------------------------------------------------------------------------*/


/* Default template environment
*/
defaultEnvironment = { inherit conf state lib templates data; };

/* Custom environments for specific templates
*/
customEnvironments = {
partials.head = defaultEnvironment // { feed = pages.feed; };
};


/*-----------------------------------------------------------------------------
Data
This section declares the data used by the site
the data set is included in the default template environment
-----------------------------------------------------------------------------*/

substitutions = { inherit conf; };

data = {
# loading a single page
about = loadFile { dir = ./pages; file = "about.md"; };
# loading a list of contents
posts = let
postsList = loadFolder { inherit substitutions; from = ./posts; };
# include drafts only when renderDrafts is true
draftsList = optionals renderDrafts (loadFolder { inherit substitutions; from = ./drafts; extraAttrs = { isDraft = true; }; });
in sortBy "date" "dsc" (postsList ++ draftsList);
menus = [ pages.about ];
};


/*-----------------------------------------------------------------------------
Pages
This section declares the pages that will be generated
-----------------------------------------------------------------------------*/

pages = rec {

/* Index page
Splitting a list of items through multiple pages
For more complex needs, mkSplitCustom is available
*/
index = mkSplit {
title = "Home";
baseHref = "index";
itemsPerPage = conf.theme.index.itemsPerPage;
template = templates.index;
items = posts;
};

/* About page
Example of generating a page from imported data
*/
about = {
href = "about.html";
template = templates.generic.full;
} // data.about;

/* RSS feed page
*/
feed = {
href = "feed.xml";
template = templates.feed;
# Show the 10 most recent posts
posts = take 10 posts;
# Bypassing the layout
layout = id;
};

/* 404 error page
*/
e404 = { href = "404.html"; template = templates.e404; title = "404"; };

/* Posts pages (as a list of pages)
*/
posts = mkPageList {
dataList = data.posts;
hrefPrefix = "posts/";
template = templates.post.full;
# Template for multi page contents
multipageTemplate = templates.post.full-multipage;
breadcrumbs = [ (head pages.index) ];
};

};


/*-----------------------------------------------------------------------------
generateSite arguments preparation
-----------------------------------------------------------------------------*/

pagesList = let
# converting pages attribute set to a list
list = pagesToList pages;
# setting a layout to pages without one
in map (setDefaultLayout templates.layout) list;


/*-----------------------------------------------------------------------------
Site rendering
-----------------------------------------------------------------------------*/

in generateSite { inherit files pagesList; }
Binary file added files/apple-touch-icon-144-precomposed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5772139

Please sign in to comment.