diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-07-10 22:20:06 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-07-25 19:50:27 +0300 |
commit | ef5d903ccecc5cb97bd9123731a13bc001029bc3 (patch) | |
tree | 4d91c6e496cda4d57e9af7225b7d1fe015eb110a | |
parent | 673861f6c264ce5639fa2cb8b1ff2306670db549 (diff) |
Basic port to Hugo Modules
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | assets/images/logo.psd | bin | 235114 -> 0 bytes | |||
-rw-r--r-- | assets/javascripts/app/_lang.js | 168 | ||||
-rw-r--r-- | assets/stylesheets/_docuapi.scss | 43 | ||||
-rw-r--r-- | assets/stylesheets/monokai.css | 65 | ||||
-rw-r--r-- | config.toml | 17 | ||||
-rw-r--r-- | exampleSite/config.toml | 5 | ||||
-rw-r--r-- | go.mod | 8 | ||||
-rw-r--r-- | go.sum | 5 | ||||
-rw-r--r-- | layouts/partials/styles.html | 15 |
10 files changed, 48 insertions, 282 deletions
@@ -1 +1,3 @@ -docuapi
\ No newline at end of file +docuapi +public/ +resources/
\ No newline at end of file diff --git a/assets/images/logo.psd b/assets/images/logo.psd Binary files differdeleted file mode 100644 index 4243d51..0000000 --- a/assets/images/logo.psd +++ /dev/null diff --git a/assets/javascripts/app/_lang.js b/assets/javascripts/app/_lang.js deleted file mode 100644 index 9572b01..0000000 --- a/assets/javascripts/app/_lang.js +++ /dev/null @@ -1,168 +0,0 @@ -//= require ../lib/_jquery - -/* -Copyright 2008-2013 Concur Technologies, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); you may -not use this file except in compliance with the License. You may obtain -a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations -under the License. -*/ -(function (global) { - 'use strict'; - - var languages = []; - - - global.setupLanguages = setupLanguages; - global.activateLanguage = activateLanguage; - - function activateLanguage(language) { - if (!language) return; - if (language === "") return; - $(".lang-selector a").removeClass('active'); - $(".lang-selector a[data-language-name='" + language + "']").addClass('active'); - // Mod to match Pygments from Hugo: div.highlight > pre code.language-ruby - var codeSelectorPrefix = ".highlight code.language-"; - for (var i=0; i < languages.length; i++) { - $(codeSelectorPrefix + languages[i]).parentsUntil(".highlight").hide(); - $(".lang-specific." + languages[i]).hide(); - } - $(codeSelectorPrefix + language).parentsUntil(".highlight").show(); - $(".lang-specific." + language).parentsUntil(".highlight").show(); - - global.toc.calculateHeights(); - - // scroll to the new location of the position - if ($(window.location.hash).get(0)) { - $(window.location.hash).get(0).scrollIntoView(true); - } - } - - // parseURL and stringifyURL are from https://github.com/sindresorhus/query-string - // MIT licensed - // https://github.com/sindresorhus/query-string/blob/7bee64c16f2da1a326579e96977b9227bf6da9e6/license - function parseURL(str) { - if (typeof str !== 'string') { - return {}; - } - - str = str.trim().replace(/^(\?|#|&)/, ''); - - if (!str) { - return {}; - } - - return str.split('&').reduce(function (ret, param) { - var parts = param.replace(/\+/g, ' ').split('='); - var key = parts[0]; - var val = parts[1]; - - key = decodeURIComponent(key); - // missing `=` should be `null`: - // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters - val = val === undefined ? null : decodeURIComponent(val); - - if (!ret.hasOwnProperty(key)) { - ret[key] = val; - } else if (Array.isArray(ret[key])) { - ret[key].push(val); - } else { - ret[key] = [ret[key], val]; - } - - return ret; - }, {}); - }; - - function stringifyURL(obj) { - return obj ? Object.keys(obj).sort().map(function (key) { - var val = obj[key]; - - if (Array.isArray(val)) { - return val.sort().map(function (val2) { - return encodeURIComponent(key) + '=' + encodeURIComponent(val2); - }).join('&'); - } - - return encodeURIComponent(key) + '=' + encodeURIComponent(val); - }).join('&') : ''; - }; - - // gets the language set in the query string - function getLanguageFromQueryString() { - if (location.search.length >= 1) { - var language = parseURL(location.search).language - if (language) { - return language; - } else if (jQuery.inArray(location.search.substr(1), languages) != -1) { - return location.search.substr(1); - } - } - - return false; - } - - // returns a new query string with the new language in it - function generateNewQueryString(language) { - var url = parseURL(location.search); - if (url.language) { - url.language = language; - return stringifyURL(url); - } - return language; - } - - // if a button is clicked, add the state to the history - function pushURL(language) { - if (!history) { return; } - var hash = window.location.hash; - if (hash) { - hash = hash.replace(/^#+/, ''); - } - history.pushState({}, '', '?' + generateNewQueryString(language) + '#' + hash); - - // save language as next default - localStorage.setItem("language", language); - } - - function setupLanguages(l) { - var defaultLanguage = localStorage.getItem("language"); - - languages = l; - - var presetLanguage = getLanguageFromQueryString(); - if (presetLanguage) { - // the language is in the URL, so use that language! - activateLanguage(presetLanguage); - - localStorage.setItem("language", presetLanguage); - } else if ((defaultLanguage !== null) && (jQuery.inArray(defaultLanguage, languages) != -1)) { - // the language was the last selected one saved in localstorage, so use that language! - activateLanguage(defaultLanguage); - } else { - // no language selected, so use the default - activateLanguage(languages[0]); - } - } - - // if we click on a language tab, activate that language - $(function() { - $(".lang-selector a").on("click", function() { - var language = $(this).data("language-name"); - pushURL(language); - activateLanguage(language); - return false; - }); - window.onpopstate = function() { - activateLanguage(getLanguageFromQueryString()); - }; - }); -})(window); diff --git a/assets/stylesheets/_docuapi.scss b/assets/stylesheets/_docuapi.scss deleted file mode 100644 index 9976828..0000000 --- a/assets/stylesheets/_docuapi.scss +++ /dev/null @@ -1,43 +0,0 @@ - - -// The section(s) below are just pulled over from _variables.scss in Slate and adjusted. - -// Make the selected code language a nice blue. -$lang-select-active-bg: $nav-active-bg; - -// Make the main background color slightly lighter than the original. -$main-bg: lighten(#eaf2f6, 2%); - - -// This will be added as the last import to the original Slate screen.css.scs. TOOD(bep) Print? - -.content { - // prevent clearing of higlight divs - &>div.highlight { - clear:none; - } -} - -.toc-footer { - .translations-title { - background-color: $nav-subitem-bg; - padding: 10px $nav-padding; - color: $nav-text; - font-size: 12px; - } -} - - - -// Getting the paths just right for Android and iOS and friends is hard ... -@font-face { - font-family:'slate'; - src:url(/fonts/slate.eot?-syv14m); - src:url(../fonts/slate.eot?#iefix-syv14m) format("embedded-opentype"), - url(../fonts/slate.woff2?-syv14m) format("woff2"), - url(../fonts/slate.woff?-syv14m) format("woff"), - url(../fonts/slate.ttf?-syv14m) format("truetype"), - url(../fonts/slate.svg?-syv14m#slate) format("svg"); - font-weight: normal; - font-style: normal; -}
\ No newline at end of file diff --git a/assets/stylesheets/monokai.css b/assets/stylesheets/monokai.css deleted file mode 100644 index e020d51..0000000 --- a/assets/stylesheets/monokai.css +++ /dev/null @@ -1,65 +0,0 @@ -.highlight pre { background-color: #272822; } -.highlight .hll { background-color: #272822; } -.highlight .c { color: #75715e } /* Comment */ -.highlight .err { color: #960050; background-color: #1e0010 } /* Error */ -.highlight .k { color: #66d9ef } /* Keyword */ -.highlight .l { color: #ae81ff } /* Literal */ -.highlight .n { color: #f8f8f2 } /* Name */ -.highlight .o { color: #f92672 } /* Operator */ -.highlight .p { color: #f8f8f2 } /* Punctuation */ -.highlight .cm { color: #75715e } /* Comment.Multiline */ -.highlight .cp { color: #75715e } /* Comment.Preproc */ -.highlight .c1 { color: #75715e } /* Comment.Single */ -.highlight .cs { color: #75715e } /* Comment.Special */ -.highlight .ge { font-style: italic } /* Generic.Emph */ -.highlight .gs { font-weight: bold } /* Generic.Strong */ -.highlight .kc { color: #66d9ef } /* Keyword.Constant */ -.highlight .kd { color: #66d9ef } /* Keyword.Declaration */ -.highlight .kn { color: #f92672 } /* Keyword.Namespace */ -.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ -.highlight .kr { color: #66d9ef } /* Keyword.Reserved */ -.highlight .kt { color: #66d9ef } /* Keyword.Type */ -.highlight .ld { color: #e6db74 } /* Literal.Date */ -.highlight .m { color: #ae81ff } /* Literal.Number */ -.highlight .s { color: #e6db74 } /* Literal.String */ -.highlight .na { color: #a6e22e } /* Name.Attribute */ -.highlight .nb { color: #f8f8f2 } /* Name.Builtin */ -.highlight .nc { color: #a6e22e } /* Name.Class */ -.highlight .no { color: #66d9ef } /* Name.Constant */ -.highlight .nd { color: #a6e22e } /* Name.Decorator */ -.highlight .ni { color: #f8f8f2 } /* Name.Entity */ -.highlight .ne { color: #a6e22e } /* Name.Exception */ -.highlight .nf { color: #a6e22e } /* Name.Function */ -.highlight .nl { color: #f8f8f2 } /* Name.Label */ -.highlight .nn { color: #f8f8f2 } /* Name.Namespace */ -.highlight .nx { color: #a6e22e } /* Name.Other */ -.highlight .py { color: #f8f8f2 } /* Name.Property */ -.highlight .nt { color: #f92672 } /* Name.Tag */ -.highlight .nv { color: #f8f8f2 } /* Name.Variable */ -.highlight .ow { color: #f92672 } /* Operator.Word */ -.highlight .w { color: #f8f8f2 } /* Text.Whitespace */ -.highlight .mf { color: #ae81ff } /* Literal.Number.Float */ -.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ -.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ -.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ -.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ -.highlight .sc { color: #e6db74 } /* Literal.String.Char */ -.highlight .sd { color: #e6db74 } /* Literal.String.Doc */ -.highlight .s2 { color: #e6db74 } /* Literal.String.Double */ -.highlight .se { color: #ae81ff } /* Literal.String.Escape */ -.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ -.highlight .si { color: #e6db74 } /* Literal.String.Interpol */ -.highlight .sx { color: #e6db74 } /* Literal.String.Other */ -.highlight .sr { color: #e6db74 } /* Literal.String.Regex */ -.highlight .s1 { color: #e6db74 } /* Literal.String.Single */ -.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ -.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ -.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ -.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ -.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ -.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ - -.highlight .gh { } /* Generic Heading & Diff Header */ -.highlight .gu { color: #75715e; } /* Generic.Subheading & Diff Unified/Comment? */ -.highlight .gd { color: #f92672; } /* Generic.Deleted & Diff Deleted */ -.highlight .gi { color: #a6e22e; } /* Generic.Inserted & Diff Inserted */ diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..dd0fcf8 --- /dev/null +++ b/config.toml @@ -0,0 +1,17 @@ + +baseURL = "https://example.com/" + +disableKinds = ["taxonomyTerm"] + +[module] +[[module.imports]] +path="github.com/lord/slate" +[[module.imports.mounts]] +source="source/images" +target="static/images" +[[module.imports.mounts]] +source="source/fonts" +target="static/fonts" +[[module.imports.mounts]] +source="source/stylesheets" +target="assets/scss/slate"
\ No newline at end of file diff --git a/exampleSite/config.toml b/exampleSite/config.toml index a93170b..0035473 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -4,13 +4,14 @@ languageCode = "en-us" baseurl = "https://docuapi.netlify.com/" title = "DocuAPI Example Site" +disableKinds = ["page", "taxonomyTerm"] + # Code higlighting settings pygmentsCodefences = true pygmentsCodeFencesGuesSsyntax = false pygmentsOptions = "" pygmentsStyle = "monokai" -# The monokai stylesheet is included in the base template. -pygmentsUseClasses = true +pygmentsUseClasses = false defaultContentLanguage = "en" @@ -0,0 +1,8 @@ +module github.com/bep/docuapi + +go 1.12 + +require ( + github.com/bep/hugotestmods/mymounts v1.2.0 // indirect + github.com/lord/slate v2.3.1+incompatible // indirect +) @@ -0,0 +1,5 @@ +github.com/bep/hugotestmods v0.0.0-20190604083900-a4c456c8a91c h1:92Ol/PBxFNz6nypoXm73BPRdM1ZnggGw0nrG8jf6i+k= +github.com/bep/hugotestmods/mymounts v1.2.0 h1:1Li0CppU5rsmxTDpFLxMOeOypOsCt0TO7/ELxJ5sfIQ= +github.com/bep/hugotestmods/mymounts v1.2.0/go.mod h1:eEF3JU4Kta3g3O2mxuHs4fVq0qMuJoOrr0OCADn1Lm4= +github.com/lord/slate v2.3.1+incompatible h1:uRy5iSKUWJdeozlS9RVWbeC1ZRyySLOCn20ve6iYw6A= +github.com/lord/slate v2.3.1+incompatible/go.mod h1:ujwDH+XJN1hPpN4JfN8Cp65e5jk3DGf+Jz0/nbJxoUM= diff --git a/layouts/partials/styles.html b/layouts/partials/styles.html index 4e6721d..be675ac 100644 --- a/layouts/partials/styles.html +++ b/layouts/partials/styles.html @@ -1,3 +1,12 @@ -<link href='{{ relURL "slate/stylesheets/monokai.css" }}' rel="stylesheet" media="screen" /> -<link href='{{ relURL "slate/stylesheets/screen.css" }}' rel="stylesheet" media="screen" /> -<link href='{{ relURL "slate/stylesheets/print.css" }}' rel="stylesheet" media="print" /> +{{ $isDev := ne hugo.Environment "production" }} +{{ $cssOpts := (dict "targetPath" "styles/screen.css" "enableSourceMap" $isDev ) }} +{{ $screenCSS := resources.Get "scss/slate/screen.css.scss" | toCSS $cssOpts }} +{{ $cssOpts := (dict "targetPath" "styles/print.css" "enableSourceMap" $isDev ) }} +{{ $printCSS := resources.Get "scss/slate/print.css.scss" | toCSS $cssOpts }} +{{ if not $isDev }} +{{ $printCSS = $printCSS | postCSS | minify | fingerprint }} +{{ $screenCSS = $printCSS | postCSS | minify | fingerprint }} +{{ end }} +<link href='{{ $screenCSS.RelPermalink }}' rel="stylesheet" media="screen" {{ if not $isDev }}integrity="{{ $screenCSS.Data.Integrity }}"{{ end }} /> +<link href='{{ $printCSS.RelPermalink }}' rel="stylesheet" media="print" {{ if not $isDev }}integrity="{{ $printCSS.Data.Integrity }}"{{ end }} /> + |