diff --git a/themes/hugo-coder/.editorconfig b/themes/hugo-coder/.editorconfig index d5add1a..51c74a1 100644 --- a/themes/hugo-coder/.editorconfig +++ b/themes/hugo-coder/.editorconfig @@ -1,4 +1,4 @@ -# http://editorconfig.org +# https://editorconfig.org # this file is the top-most editorconfig file root = true diff --git a/themes/hugo-coder/.github/FUNDING.yml b/themes/hugo-coder/.github/FUNDING.yml new file mode 100644 index 0000000..f100056 --- /dev/null +++ b/themes/hugo-coder/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: https://www.buymeacoffee.com/luizdepra diff --git a/themes/hugo-coder/.github/ISSUE_TEMPLATE/bug_report.md b/themes/hugo-coder/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0c8827e --- /dev/null +++ b/themes/hugo-coder/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,30 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "" +labels: "Triage Needed" +assignees: "" +--- + +## Describe the problem: + +_Explain the problem you have encountered_ + +### Steps to reproduce: + +1. *** +2. *** +3. *** + +### Observed Results: + +- What happened? +- What did you expect to happen? + +### Relevant code exceptions or logs + +Note: Please copy/paste text of the messages, no screenshots of logs please. + +``` +// paste your log here +``` diff --git a/themes/hugo-coder/.github/ISSUE_TEMPLATE/feature_request.md b/themes/hugo-coder/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..1e99de0 --- /dev/null +++ b/themes/hugo-coder/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,11 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "" +labels: "" +assignees: "" +--- + +## Describe the enhancement + +_Explain the enhancement you would like_ diff --git a/themes/hugo-coder/.github/ISSUE_TEMPLATE/question.md b/themes/hugo-coder/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..4aeca23 --- /dev/null +++ b/themes/hugo-coder/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,11 @@ +--- +name: Question +about: Ask a question you could not find an answer in the docs +title: "" +labels: "Question" +assignees: "" +--- + +## Your question + +_Ask the question you have not been able to find an answer in the Documentation_ diff --git a/themes/hugo-coder/.gitignore b/themes/hugo-coder/.gitignore index ddf775b..2be26dd 100644 --- a/themes/hugo-coder/.gitignore +++ b/themes/hugo-coder/.gitignore @@ -1,4 +1,6 @@ +.idea **/themes/ -demo/ -.hugo/* -!.hugo/version +exampleSite/public/ +exampleSite/resources/ +*.lock +public diff --git a/themes/hugo-coder/CONTRIBUTORS.md b/themes/hugo-coder/CONTRIBUTORS.md index d11c59a..b33a0e4 100644 --- a/themes/hugo-coder/CONTRIBUTORS.md +++ b/themes/hugo-coder/CONTRIBUTORS.md @@ -10,6 +10,7 @@ - [Jiri Hubacek](https://github.com/qeef) - [Khosrow Moossavi](https://github.com/khos2ow) - [Maikel](https://github.com/mbollemeijer) +- [MetBril](https://github.com/metbril) - [Myles Johnson](https://github.com/MylesJohnson) - [Niels Reijn](https://github.com/reijnn) - [Padraic Renaghan](https://github.com/prenagha) @@ -49,7 +50,7 @@ - [Bobby Lindsey](https://bobbywlindsey.com) - [José Mª Escartín](https://github.com/jme52) - [John Schroeder](https://blog.schroedernet.software) -- [Tobias Lindberg](https://tobiaslindberg.com) +- [Tobias Lindberg](https://github.com/tobiasehlert) - [KK](https://github.com/bebound) - [Eli W. Hunter](https://github.com/elihunter173) - [Víctor López](https://github.com/viticlick) @@ -62,7 +63,7 @@ - [Piotr Orzechowski](https://orzechowski.tech) - [Glenn Feunteun](https://github.com/gfeun) - [Santiago González](https://github.com/netrules) -- [Codruț Constantin Gușoi](https://www.sdwolfz.pro) +- [Codruț Constantin Gușoi](https://www.codrut.pro) - [Clément Pannetier](https://clementpannetier.dev) - [FantasticMao](https://github.com/FantasticMao) - [Utkarsh Gupta](https://utkarsh2102.com) @@ -70,3 +71,78 @@ - [Endormi](https://endormi.io) - [Rajiv Ranjan Singh](https://iamrajiv.github.io/) - [Pakhomov Alexander](https://github.com/PakhomovAlexander) +- [Rhys Perry](https://rhysperry.com) +- [Arunvel Sriram](https://github.com/arunvelsriram) +- [Lorenzo Cameroni](https://github.com/came88) +- [Jared Sturdy](https://github.com/jsturdy) +- [Daniel Monteiro](https://github.com/dfamonteiro) +- [Dave Rolsky](https://github.com/autarch) +- [Joseph Sanders](https://github.com/jls83) +- [Rabin Adhikari](https://github.com/rabinadk1/) +- [Hussaini Zulkifli](https://github.com/hussaini/) +- [Ellison Leão](https://github.com/ellisonleao) +- [Lucas de Oliveira](https://github.com/lucas-dOliveira) +- [Jian Loong Liew](https://github.com/JianLoong) +- [earnest ma](https://github.com/earnestma) +- [TMineCola](https://github.com/tminecola) +- [Arafat Hasan](https://github.com/arafat-hasan) +- [YUJI](https://yuji.ne.jp/) +- [JaeSang Yoo](https://github.com/JSYoo5B) +- [tianheg](https://github.com/tianheg) +- [Felix](https://github.com/lazyyz) +- [Peter Duchnovsky](https://pduchnovsky.com) +- [Alex Miranda](https://ammiranda.com) +- [Alphonse Mariya](https://github.com/alfunx) +- [Ziwei Pan](https://github.com/PanZiwei/) +- [Viktar Patotski](https://github.com/xp-vit) +- [cuso4-5h2o](https://www.cuso4.me) +- [freeformz](https://icanhazdowntime.org) +- [Roberto Gongora](https://yourfavourite.blog) +- [kuba86](https://kuba86.com) +- [Vladislav Matus](https://github.com/matusvla) +- [Kirill Feoktistov](https://feoktistoff.org) +- [leins275](https://github.com/LanskovNV) +- [Michael Weiss](https://mweiss.ch) +- [Simon Pai](https://github.com/simonpai) +- [Brenton Mallen](https://github.com/brentonmallen1) +- [Xiaoyang Luo](https://github.com/ccviolett/) +- [Michiel Appelman](https://appelman.se) +- [Mark Wood](https://digitalnotions.net) +- [Sam A.](https://samsapti.dev) +- [John Feminella](https://jxf.me) +- [zzsqwq](https://zzsqwq.cn) +- [George Tsiokos](https://george.tsiokos.com) +- [Eltjo](https://github.com/eltjo) +- [Saurmandal](https://saur.neocities.org) +- [Jneo8](https://github.com/jneo8) +- [Daniel Nduati](https://github.com/DanNduati) +- [Simon Hollingshead](https://github.com/simonhollingshead) +- [yangyangdaji](https://github.com/yangyangdaji) +- [xiaotianxt](https://github.com/xiaotianxt) +- [Nour Agha](https://github.com/nourkagha) +- [Brian Lachniet](https://github.com/blachniet) +- [ShortArrow](https://github.com/ShortArrow) +- [Martin Hellspong](https://github.com/marhel) +- [Robert Tucker](https://github.com/robertwtucker) +- [Michał Pawlik](https://michalp.net) +- [Kilian Kluge](https://github.com/ionicsolutions) +- [Jaroslaw Rozanski](https://jarekrozanski.eu) +- [Easton Man](https://github.com/eastonman) +- [Yiğit Altınay](https://altinay.xyz) +- [Fei Kong](https://github.com/alpha0422) +- [Ahmet Enes Bayraktar](https://github.com/aeb-dev) +- [Todor Bogosavljević](https://github.com/tbx1b) +- [Kemal Akkoyun](https://github.com/kakkoyun) +- [Igetin](https://github.com/Igetin) +- [Kirill Che.](https://github.com/g4s8) +- [iron3oxide](https://github.com/iron3oxide) +- [Jens Rantil](https://github.com/JensRantil) +- [Muqeet Malik](https://github.com/mmalik23) +- [Sammy44nts](https://github.com/sammy44nts) +- [Shaked8634](https://github.com/shaked8634) +- [Leo Heimann Ruiz](https://leo.heitmannruiz.org/) +- [Antoine "Toinux" Wam](https://github.com/itzwam) +- [Reberti Carvalho Soares](https://github.com/RebertiCS) +- [Andreas Deininger](https://github.com/deining) +- [Ardemium](https://github.com/ardemium) +- [Matt Ellery](https://github.com/matt-ellery) diff --git a/themes/hugo-coder/Makefile b/themes/hugo-coder/Makefile index 7ed802b..8e0c3e4 100644 --- a/themes/hugo-coder/Makefile +++ b/themes/hugo-coder/Makefile @@ -1,20 +1,12 @@ HUGO_BIN=hugo -.PHONY: prepare release build demo clean +.PHONY: build demo release -build: prepare - $(HUGO_BIN) --source demo +build: + $(HUGO_BIN) --themesDir=../.. --source=exampleSite -demo: prepare - $(HUGO_BIN) server --buildDrafts --source demo +demo: + $(HUGO_BIN) server -D --themesDir=../.. --source=exampleSite --bind 0.0.0.0 release: build - rm -rf ./resources && cp -r ./demo/resources ./resources - -prepare: clean - mkdir -p demo/themes/hugo-coder - rsync -av exampleSite/ demo - rsync -av --exclude='demo' --exclude='exampleSite' --exclude='.git' . demo/themes/hugo-coder - -clean: - rm -rf demo + rm -rf ./resources && cp -r ./exampleSite/resources ./resources diff --git a/themes/hugo-coder/README.md b/themes/hugo-coder/README.md index a77ac4f..0dfdeec 100644 --- a/themes/hugo-coder/README.md +++ b/themes/hugo-coder/README.md @@ -1,18 +1,37 @@ -![Hugo Coder Logotype](https://github.com/luizdepra/hugo-coder/blob/master/images/logos/logotype-a.png) +
+
+ ++ + + +
+ A simple and clean blog theme for [Hugo](https://gohugo.io/). -![](https://github.com/luizdepra/hugo-coder/blob/master/images/screenshot.png) +![](images/screenshot.png) + +## Live Demo + +See [here](https://hugo-coder.netlify.app/). ## Quick Start 1. Add the repository into your Hugo Project repository as a submodule, `git submodule add https://github.com/luizdepra/hugo-coder.git themes/hugo-coder`. -2. Configure your `config.toml`. You can either use the [this minimal configuration](https://github.com/luizdepra/hugo-coder/wiki/Configurations#complete-example) as a base, or look for a complete explanation about all configurations [here](https://github.com/luizdepra/hugo-coder/wiki/Configurations). The [`config.toml`](https://github.com/luizdepra/hugo-coder/blob/master/exampleSite/config.toml) inside the [`exampleSite`](https://github.com/luizdepra/hugo-coder/tree/master/exampleSite) is also a good reference. -3. Build your site with `hugo serve` and see the result at `http://localhost:1313/`. +2. Configure your `hugo.toml`. You can either use [this minimal configuration](https://github.com/luizdepra/hugo-coder/blob/main/docs/configurations.md#complete-example) as a base, or look for a complete explanation about all configurations [here](https://github.com/luizdepra/hugo-coder/blob/main/docs/configurations.md). The [`hugo.toml`](https://github.com/luizdepra/hugo-coder/blob/master/exampleSite/hugo.toml) inside the [`exampleSite`](https://github.com/luizdepra/hugo-coder/tree/master/exampleSite) is also a good reference. +3. Build your site with `hugo server` and see the result at `http://localhost:1313/`. -## Extra Guides +## Documentation -* [Multilingual Mode](https://github.com/luizdepra/hugo-coder/wiki/Multilingual-Mode) +See the [`docs`](docs/home.md) folder. ## License @@ -22,13 +41,13 @@ Coder is licensed under the [MIT license](https://github.com/luizdepra/hugo-code This theme is maintained by its author [Luiz de Prá](https://github.com/luizdepra) with the help from these awesome [contributors](CONTRIBUTORS.md). +## Sponsoring + +If you like my project or it was useful for you, consider supporting its development. Just: + + + ## Special Thanks -- Gleen McComb, for his great [article](https://glennmccomb.com/articles/how-to-build-custom-hugo-pagination/) about custom pagination. -- All contributors, for every PR and Issue reported. - -## Stackbit - -This theme is ready to import into Stackbit. This theme can be deployed to Netlify and you can connect any headless CMS including Forestry, NetlifyCMS, DatoCMS or Contentful. - -[![Create with Stackbit](https://assets.stackbit.com/badge/create-with-stackbit.svg)](https://app.stackbit.com/create?theme=https://github.com/luizdepra/hugo-coder) +- Gleen McComb, for his great [article](https://glennmccomb.com/articles/how-to-build-custom-hugo-pagination/) about custom pagination. +- All contributors, for every PR and Issue reported. diff --git a/themes/hugo-coder/archetypes/posts.md b/themes/hugo-coder/archetypes/posts.md index afdb40e..76242f8 100644 --- a/themes/hugo-coder/archetypes/posts.md +++ b/themes/hugo-coder/archetypes/posts.md @@ -3,7 +3,8 @@ draft = true date = {{ .Date }} title = "" description = "" -slug = "" +slug = "" +authors = [] tags = [] categories = [] externalLink = "" diff --git a/themes/hugo-coder/assets/js/coder.js b/themes/hugo-coder/assets/js/coder.js new file mode 100644 index 0000000..9b46cfc --- /dev/null +++ b/themes/hugo-coder/assets/js/coder.js @@ -0,0 +1,97 @@ +const body = document.body; +const darkModeToggle = document.getElementById('dark-mode-toggle'); +const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); + +// Check if user preference is set, if not check value of body class for light or dark else it means that colorscheme = auto +if (localStorage.getItem("colorscheme")) { + setTheme(localStorage.getItem("colorscheme")); +} else if (body.classList.contains('colorscheme-light') || body.classList.contains('colorscheme-dark')) { + setTheme(body.classList.contains("colorscheme-dark") ? "dark" : "light"); +} else { + setTheme(darkModeMediaQuery.matches ? "dark" : "light"); +} + +if (darkModeToggle) { + darkModeToggle.addEventListener('click', () => { + let theme = body.classList.contains("colorscheme-dark") ? "light" : "dark"; + setTheme(theme); + rememberTheme(theme); + }); +} + +darkModeMediaQuery.addListener((event) => { + setTheme(event.matches ? "dark" : "light"); +}); + +document.addEventListener("DOMContentLoaded", function () { + let node = document.querySelector('.preload-transitions'); + node.classList.remove('preload-transitions'); +}); + +function setTheme(theme) { + body.classList.remove('colorscheme-auto'); + let inverse = theme === 'dark' ? 'light' : 'dark'; + body.classList.remove('colorscheme-' + inverse); + body.classList.add('colorscheme-' + theme); + document.documentElement.style['color-scheme'] = theme; + + function waitForElm(selector) { + return new Promise(resolve => { + if (document.querySelector(selector)) { + return resolve(document.querySelector(selector)); + } + + const observer = new MutationObserver(mutations => { + if (document.querySelector(selector)) { + resolve(document.querySelector(selector)); + observer.disconnect(); + } + }); + + observer.observe(document.body, { + childList: true, + subtree: true + }); + }); + } + + if (theme === 'dark') { + const message = { + type: 'set-theme', + theme: 'github-dark' + }; + waitForElm('.utterances-frame').then((iframe) => { + iframe.contentWindow.postMessage(message, 'https://utteranc.es'); + }) + + } + else { + const message = { + type: 'set-theme', + theme: 'github-light' + }; + waitForElm('.utterances-frame').then((iframe) => { + iframe.contentWindow.postMessage(message, 'https://utteranc.es'); + }) + + } + + function sendMessage(message) { + const iframe = document.querySelector('iframe.giscus-frame'); + if (!iframe) return; + iframe.contentWindow.postMessage({ giscus: message }, 'https://giscus.app'); + } + sendMessage({ + setConfig: { + theme: theme, + }, + }); + + // Create and send event + const event = new Event('themeChanged'); + document.dispatchEvent(event); +} + +function rememberTheme(theme) { + localStorage.setItem('colorscheme', theme); +} diff --git a/themes/hugo-coder/assets/js/purify.min.js b/themes/hugo-coder/assets/js/purify.min.js new file mode 100644 index 0000000..644aca0 --- /dev/null +++ b/themes/hugo-coder/assets/js/purify.min.js @@ -0,0 +1,3 @@ +/*! @license DOMPurify 2.4.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.1/LICENSE */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,n){return t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t(e,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function r(e,o,a){return r=n()?Reflect.construct:function(e,n,r){var o=[null];o.push.apply(o,n);var a=new(Function.bind.apply(e,o));return r&&t(a,r.prototype),a},r.apply(null,arguments)}function o(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);nhugo says hello!
- - -:wq - -$ -``` - -Build the web site and then verify the results. - -``` -$ hugo --verbose -INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml -INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/themes/zafta/static/ to /Users/quoha/Sites/zafta/public/ -INFO: 2014/09/29 syncing from /Users/quoha/Sites/zafta/static/ to /Users/quoha/Sites/zafta/public/ -WARN: 2014/09/29 Unable to locate layout: [404.html theme/404.html] -0 draft content -0 future content -0 pages created -0 tags created -0 categories created -in 2 ms - -$ find public -type f -name '*.html' | xargs ls -l --rw-r--r-- 1 quoha staff 78 Sep 29 21:26 public/index.html - -$ cat public/index.html - - - -hugo says hello!
- -``` - -#### Live Reload - -Note: If you're running the server with the `--watch` option, you'll see different content in the file: - -``` -$ cat public/index.html - - - -hugo says hello!
- - -``` - -When you use `--watch`, the Live Reload script is added by Hugo. Look for live reload in the documentation to see what it does and how to disable it. - -### Build a "Dynamic" Home Page - -"Dynamic home page?" Hugo's a static web site generator, so this seems an odd thing to say. I mean let's have the home page automatically reflect the content in the site every time Hugo builds it. We'll use iteration in the template to do that. - -#### Create New Posts - -Now that we have the home page generating static content, let's add some content to the site. We'll display these posts as a list on the home page and on their own page, too. - -Hugo has a command to generate a skeleton post, just like it does for sites and themes. - -``` -$ hugo --verbose new post/first.md -INFO: 2014/09/29 Using config file: /Users/quoha/Sites/zafta/config.toml -INFO: 2014/09/29 attempting to create post/first.md of post -INFO: 2014/09/29 curpath: /Users/quoha/Sites/zafta/themes/zafta/archetypes/default.md -ERROR: 2014/09/29 Unable to Castmy first post
- - - - -$ cat public/post/second/index.html - - - -my second post
- - - -$ -``` - -Notice that the posts now have content. You can go to localhost:1313/post/first to verify. - -### Linking to Content - -The posts are on the home page. Let's add a link from there to the post. Since this is the home page, we'll update its template. - -``` -$ vi themes/zafta/layouts/index.html - - - - {{ range first 10 .Data.Pages }} -🙈 :see_no_evil:
🙉 :hear_no_evil:
🙊 :speak_no_evil:
🙈 :see_no_evil:
🙉 :hear_no_evil:
🙊 :speak_no_evil: