Init version 2

- Switch to the Hugo Pipes (bye bye Webpack)
- Use Inter from Google Fonts
- Update README
This commit is contained in:
panr 2020-07-27 00:40:08 +02:00
parent 005e78d86c
commit 0be313316f
74 changed files with 173 additions and 7564 deletions

View file

@ -44,12 +44,6 @@ rules:
no-unused-vars:
- 2
- argsIgnorePattern: "^_"
# jsx a11y
jsx-a11y/no-static-element-interactions: 0
jsx-a11y/anchor-is-valid:
- 2
- specialLink:
- to
globals:
document: true

3
.gitignore vendored
View file

@ -1 +1,2 @@
node_modules
node_modules
public

View file

@ -1,5 +1,11 @@
{
"parser": "babel",
"printWidth": 100,
"trailingComma": "all"
"trailingComma": "all",
"overrides": [{
"files": ".html",
"options": {
"parser": "html"
}
}]
}

21
COMMUNITY-FEATURES.md Normal file
View file

@ -0,0 +1,21 @@
# Community features
<!--
Did a cool thing with the theme and want to share it with rest of the Hello Friend theme users? Jump in!
Please follow the template:
- **NAME_OF_THE_FEATURE** (LINK TO YOUR FORK)
- SHORT DESCRIPTION
- SOMETHING ABOUT YOU (name and who you are / what you do / etc.)
eg:
- **Social media icons** (https://github.com/...)
- This was a big missing feature of the theme. It will help your audience reach you over the internet.
- John, a javascript developer.
-->
- **Social media icons** (https://github.com/...)
- This is the biggest missing feature of the theme. But now it will help your audience reach you over the internet.
- John, a javascript developer.

View file

@ -2,27 +2,28 @@
![Hello Friend](https://github.com/panr/hugo-theme-hello-friend/blob/master/images/screenshot.png?raw=true)
### DEMO - https://hugo-hello-friend.now.sh/
### DEMO - https://hugo-hello-friend.now.sh/ <a id="demo" />
<a href="https://www.buymeacoffee.com/panr" target="_blank"><img src="https://res.cloudinary.com/panr/image/upload/v1579374705/buymeacoffee_y6yvov.svg" alt="Buy Me A Coffee" ></a>
---
- [Hello Friend](#hello-friend)
- [DEMO - https://hugo-hello-friend.now.sh/](#demo---httpshugo-hello-friendnowsh)
- [DEMO - https://hugo-hello-friend.now.sh/](#demo)
- [Features](#features)
- [Built-in shortcodes](#built-in-shortcodes)
- [Code highlighting](#code-highlighting)
- [Improved RSS Feed](#improved-rss-feed)
- [How to start](#how-to-start)
- [How to run your site](#how-to-run-your-site)
- [How to configure](#how-to-configure)
- [How to add a cover image to your posts](#how-to-add-a-cover-image-to-your-posts)
- [How to display the Last Modified Date in your posts](#how-to-display-the-last-modified-date-in-your-posts)
- [How to hide "Read more" button](#how-to-hide-read-more-button)
- [Add-ons](#add-ons)
- [How to run your site](#how-to-run-your-site)
- [How to edit the theme](#how-to-edit-the-theme)
- [How to contribute](#how-to-contribute)
- [How to (safely) edit the theme](#how-to-edit)
- [Found a bug?](#bug)
- [New cool idea or feature](#feature)
- [`Hello Friend` theme user?](#hello-friend-theme-user)
- [Sponsoring](#sponsoring)
- [License](#license)
@ -107,6 +108,24 @@ If you don't want to make any radical changes, it's the best option, because you
$ git submodule add https://github.com/panr/hugo-theme-hello-friend.git themes/hello-friend
```
## How to run your site
The theme is using [Hugo Pipes](https://gohugo.io/hugo-pipes/) to handle Javascript and PostCSS files. This setup **requires** following npm packages:
```
@babel/cli @babel/core @babel/preset-env browserslist clipboard cssnano postcss-cli postcss-import postcss-mixins postcss-nested postcss-preset-env postcss-url
```
Before you start, you have to install them (globally or locally).
Then:
```
$ hugo server -t hello-friend
```
and go to `localhost:1313` in your browser. From now on all the changes you make will go live, so you don't need to refresh your browser every single time.
## How to configure
The theme doesn't require any advanced configuration. Just copy:
@ -210,37 +229,30 @@ In a post's front matter you have to add `hideReadMore` param set to `true`. Thi
- **Extended `<head>`** — if you need to add something inside `<head>` element, after all of all of the theme's `<script>` and `<link>` tags are declared, please take a look at `layouts/partial/extended_head.html` https://github.com/panr/hugo-theme-hello-friend/blob/master/layouts/partials/extended_head.html
- **Extended `<footer>`** — if you need to add something before end of `<body>` element, please take a look at `layouts/partial/extended_footer.html` https://github.com/panr/hugo-theme-hello-friend/blob/master/layouts/partials/extended_footer.html
## How to run your site
## How to (safely) edit the theme <a id="how-to-edit" />
From your Hugo root directory run:
To change something in the theme, you have to go to `themes/hello-friend` and modify the files. You can also copy them (like `assets` folder) from the theme to your root directory and modify the files there (thanks to Hugo's lookup https://gohugo.io/templates/lookup-order). This will protect your changes from overriding when you update the theme.
```bash
$ hugo server -t hello-friend
```
## Found a bug? <a id="bug" />
and go to `localhost:1313` in your browser. From now on all the changes you make will go live, so you don't need to refresh your browser every single time.
If you spot any bugs, please use [Issue Tracker](https://github.com/panr/hugo-theme-hello-friend/issues) or create a new [Pull Request](https://github.com/panr/hugo-theme-hello-friend/pulls) to fix the issue.
## How to edit the theme
## New cool idea or feature? <a id="feature" />
If you have to override some of the styles, you can do this easily by adding `static/style.css` in your root directory and point things you want to change.
The theme is in constant development since 2019 and has got many cool features that helped many of you and made the theme better. But there were also many features that I wasn't sure about because I want to keep the theme as simple as possible.
Otherwise, if you really want to edit the theme, you need to install Node dependencies. To do so, go to the theme directory (from your Hugo root directory):
So, let's say you have an idea of how to extend the theme. That's cool and you're welcome to do that, just follow these steps:
```bash
$ cd themes/hello-friend
```
- fork the theme
- implement the feature
- write an instruction how to use the feature
- give a working example of the implementation for other users
- add info about your work to `COMMUNITY-FEATURES.md`
- make a PR with edited `COMMUNITY-FEATURES.md`
and then run:
This will help keeping the theme close to its roots, and also allow anyone who wishes to improve it and match their needs, to do whatever they want.
```bash
$ npm install
$ npm i yarn
$ yarn
```
## How to contribute
If you spot any bugs, please use [Issue Tracker](https://github.com/panr/hugo-theme-hello-friend/issues) or if you want to add a new feature directly please create a new [Pull Request](https://github.com/panr/hugo-theme-hello-friend/pulls).
Sounds OK? Cool, let's rock! 🤘
## `Hello Friend` theme user?
@ -254,6 +266,6 @@ If you like my work and want to support the development of the project, now you
## License
Copyright © 2019 Radosław Kozieł ([@panr](https://twitter.com/panr))
Copyright © 2019-2020 Radosław Kozieł ([@panr](https://twitter.com/panr))
The theme is released under the MIT License. Check the [original theme license](https://github.com/panr/hugo-theme-hello-friend/blob/master/LICENSE.md) for additional licensing information.

View file

@ -13,7 +13,8 @@ body {
padding: 0;
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", Helvetica, Arial, sans-serif;
font-size: 1rem;
font-weight: 600;
font-weight: 500;
font-feature-settings: "liga", "tnum", "case", "calt", "zero", "ss01", "locl";
line-height: 1.54;
background-color: var(--background);
color: var(--color);
@ -124,7 +125,7 @@ figure {
}
}
code {
code, kbd {
font-family: Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;
background: var(--background-secondary);
padding: 1px 6px;
@ -132,6 +133,12 @@ code {
border-radius: 5px;
font-size: .9rem;
font-weight: normal;
code, kbd {
background: transparent;
padding: 0;
margin: 0;
}
}
pre {
@ -151,7 +158,7 @@ pre {
color: #ccc;
margin: 0;
padding: 0;
font-size: .9rem;
font-size: inherit;
}
}
@ -243,3 +250,10 @@ hr {
.hidden {
display: none;
}
.framed {
padding: 20px;
border-radius: 10px;
border: 1px solid var(--border-color);
max-width: 800px;
}

View file

@ -16,7 +16,7 @@
border-right: 1px solid;
margin-right: 18px;
padding-right: 24px;
font-weight: 600;
font-weight: 500;
@media (--phone) {
@mixin menu;

View file

@ -49,7 +49,7 @@
justify-content: center;
background: var(--background-secondary);
font-size: 1rem;
font-weight: 600;
font-weight: 500;
border-radius: 8px;
max-width: 40%;
padding: 0;

17
assets/css/style.css Normal file
View file

@ -0,0 +1,17 @@
@import 'fonts.css';
@import 'variables.css';
@import 'buttons.css';
@import 'header.css';
@import 'logo.css';
@import 'menu.css';
@import 'main.css';
@import 'post.css';
@import 'pagination.css';
@import 'footer.css';
@import 'terms.css';
@import 'archive.css';
@import 'prism.css';
@import 'code.css';

18
babel.config.js Normal file
View file

@ -0,0 +1,18 @@
module.exports = function(api) {
api.cache(true);
const presets = [
[
"@babel/preset-env",
{
targets: "last 2 versions, >1%, not dead",
},
],
];
const plugins = [];
return {
presets,
plugins,
};
};

View file

@ -8,6 +8,12 @@
{{ end }}
{{ $paginator := .Paginate (where $PageContext.RegularPages "Type" $contentTypeName) }}
{{ if .Content }}
<div class="index-content {{ if .Params.framed -}}framed{{- end -}}">
{{ .Content }}
</div>
{{ end }}
<div class="posts">
{{ range $paginator.Pages }}
<div class="post on-list">
@ -39,9 +45,9 @@
{{ if .Params.Cover }}
<figure class="post-cover">
{{ if .Params.UseRelativeCover }}
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" />
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Title | plainify | default " " }}"/>
{{ else }}
<img src="{{ .Params.Cover | absURL }}" />
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Title | plainify | default " " }}"/>
{{ end }}
{{ if .Params.CoverCaption }}

View file

@ -30,9 +30,9 @@
{{ if .Params.Cover }}
<figure class="post-cover">
{{ if .Params.UseRelativeCover }}
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" />
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Title | plainify | default " " }}" />
{{ else }}
<img src="{{ .Params.Cover | absURL }}" />
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Title | plainify | default " " }}" />
{{ end }}
{{ if .Params.CoverCaption }}

View file

@ -34,9 +34,9 @@
{{ if .Params.Cover }}
<figure class="post-cover">
{{ if .Params.UseRelativeCover }}
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" />
<img src="{{ (printf "%s%s" .Permalink .Params.Cover ) }}" alt="{{ .Title | plainify | default " " }}" />
{{ else }}
<img src="{{ .Params.Cover | absURL }}" />
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Title | plainify | default " " }}" />
{{ end }}
{{ if .Params.CoverCaption }}

View file

@ -12,6 +12,12 @@
</div>
</footer>
<script src="{{ "assets/main.js" | absURL }}"></script>
<script src="{{ "assets/prism.js" | absURL }}"></script>
{{ $opts := dict "noComments" true "minified" true "compact" true }}
{{ $menu := resources.Get "js/menu.js" | js.Build | babel $opts }}
{{ $theme := resources.Get "js/theme.js" | js.Build | babel $opts }}
{{ $prism := resources.Get "js/prism.js" | js.Build | babel $opts }}
<script src="{{ $menu.Permalink }}"></script>
<script src="{{ $theme.Permalink }}"></script>
<script src="{{ $prism.Permalink }}"></script>
{{- partial "extended_footer.html" . }}

View file

@ -9,7 +9,10 @@
{{- partial "prepended_head.html" . }}
<!-- Theme CSS -->
<link rel="stylesheet" href="{{ "assets/style.css" | absURL }}">
{{ $css := resources.Get "css/style.css" }}
{{ $opts := dict "inlineImports" true }}
{{ $style := $css | resources.PostCSS $opts | minify }}
<link rel="stylesheet" href="{{ $style.Permalink }}">
<!-- Custom CSS to override theme properties (/static/style.css) -->
<link rel="stylesheet" href="{{ "style.css" | absURL }}">

View file

@ -1,59 +1,7 @@
{
"name": "hello-friend",
"version": "1.0.0",
"version": "2.0.0",
"main": "index.js",
"author": "Radosław Kozieł <@panr> <radoslaw.koziel@gmail.com>",
"license": "MIT",
"scripts": {
"dev": "webpack --mode=development --watch",
"build": "webpack --mode=production"
},
"browserslist": [
"last 2 versions",
">1%",
"not dead"
],
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-stage-2": "^7.0.0",
"babel-eslint": "^8.2.1",
"babel-loader": "^8.0.5",
"browserslist": "^4.0.1",
"clean-webpack-plugin": "^0.1.19",
"clipboard": "^2.0.4",
"css-loader": "^1.0.1",
"cssnano": "^4.1.8",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^2.10.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"husky": "^4.2.5",
"postcss": "^7.0.0",
"postcss-browser-reporter": "^0.5.0",
"postcss-cli": "^6.1.1",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.6",
"postcss-mixins": "^6.2.1",
"postcss-nested": "^3.0.0",
"postcss-preset-env": "^5.3.0",
"postcss-reporter": "^5.0.0",
"postcss-url": "^7.3.2",
"prettier-eslint-cli": "^4.7.1",
"ramda": "^0.25.0",
"style-loader": "^0.21.0",
"uglifyjs-webpack-plugin": "^1.3.0",
"url-loader": "^1.1.2",
"webpack": "^4.29.3",
"webpack-cli": "^3.2.3"
},
"husky": {
"hooks": {
"pre-push": "yarn build && git add . && git commit --amend --no-edit"
}
}
"license": "MIT"
}

View file

@ -1,17 +0,0 @@
@import 'variables';
@import 'fonts';
@import 'buttons';
@import 'header';
@import 'logo';
@import 'menu';
@import 'main';
@import 'post';
@import 'pagination';
@import 'footer';
@import 'terms';
@import 'archive';
@import 'prism';
@import 'code';

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1 +0,0 @@
// Add your script here

View file

@ -1 +0,0 @@
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){n(1),n(2),e.exports=n(3)},function(e,t){},function(e,t){var n=document.querySelector(".container"),o=document.querySelector(".menu"),r=document.querySelector(".menu-trigger"),i=(document.querySelector(".menu__inner--desktop"),document.querySelector(".menu__sub-inner-more-trigger")),c=document.querySelector(".menu__sub-inner-more"),d=getComputedStyle(document.body).getPropertyValue("--phoneWidth"),u=function(){return window.matchMedia(d).matches},l=function(){r&&r.classList.toggle("hidden",!u()),o&&o.classList.toggle("hidden",u()),c&&c.classList.toggle("hidden",!u())};o&&o.addEventListener("click",function(e){return e.stopPropagation()}),c&&c.addEventListener("click",function(e){return e.stopPropagation()}),l(),document.body.addEventListener("click",function(){u()||!c||c.classList.contains("hidden")?u()&&!o.classList.contains("hidden")&&o.classList.add("hidden"):c.classList.add("hidden")}),window.addEventListener("resize",l),r&&r.addEventListener("click",function(e){e.stopPropagation(),o&&o.classList.toggle("hidden")}),i&&i.addEventListener("click",function(e){e.stopPropagation(),c&&c.classList.toggle("hidden"),c&&c.getBoundingClientRect().right>n.getBoundingClientRect().right&&(c.style.left="auto",c.style.right=0)})},function(e,t){var n=window.localStorage&&window.localStorage.getItem("theme"),o=document.querySelector(".theme-toggle"),r="dark"===n;null!==n&&document.body.classList.toggle("dark-theme",r),o.addEventListener("click",function(){document.body.classList.toggle("dark-theme"),window.localStorage&&window.localStorage.setItem("theme",document.body.classList.contains("dark-theme")?"dark":"light")})}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,13 +1,27 @@
name = "hello-friend"
description = "A simple theme for Hugo. That's it."
features = ["blog", "shortcode", "syntax Highlighting"]
homepage = "https://github.com/panr/hugo-theme-hello-friend/"
license = "MIT"
licenselink = "https://github.com/panr/hugo-theme-hello-friend/blob/master/LICENSE.md"
description = "A simple theme for Hugo. That's it."
homepage = "https://github.com/panr/hugo-theme-hello-friend/"
tags = ["blog", "clean", "customizable", "dark", "highlighting", "light", "minimal", "monochromatic", "multilingual", "personal", "responsive", "simple", "technical"]
features = ["blog", "shortcode", "syntax Highlighting"]
min_version = 0.57
min_version = 0.74
name = "hello-friend"
tags = [
"blog",
"clean",
"customizable",
"dark",
"highlighting",
"light",
"minimal",
"monochromatic",
"multilingual",
"personal",
"responsive",
"simple",
"technical",
]
[author]
name = "panr"
homepage = "https://radoslawkoziel.pl"
twitter = "https://twitter.com/panr"
homepage = "https://radoslawkoziel.pl"
name = "panr"
twitter = "https://twitter.com/panr"

View file

@ -1,95 +0,0 @@
const Webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CleanPlugin = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const path = require("path");
const join = (...paths) => path.join(__dirname, ...paths);
module.exports = {
resolve: {
extensions: [".js", ".css"],
modules: ["source", "node_modules"],
},
entry: {
"main.js": [
join("source", "js", "index.js"),
join("source", "js", "menu.js"),
join("source", "js", "theme.js"),
],
"prism.js": join("source", "js", "prism.js"),
"style.css": join("source", "css", "style.css"),
},
output: {
filename: "[name]",
path: join("static/assets"),
publicPath: "",
},
performance: {
hints: false,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
},
},
},
{
test: /\.(png|jpg|woff|woff2|ttf|eot|svg)$/,
use: [
{
loader: "url-loader",
options: {
limit: 8192,
},
},
],
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: {
minimize: true,
modules: true,
importLoaders: 1,
localIdentName: "[local]",
},
},
{
loader: "postcss-loader",
options: {
config: {
path: "postcss.config.js",
},
},
},
],
}),
},
],
},
optimization: {
splitChunks: {
name: "vendor",
minChunks: 2,
},
minimizer: [
new UglifyJsPlugin({
sourceMap: true,
}),
],
},
plugins: [new CleanPlugin(join("static/assets")), new ExtractTextPlugin("[name]")],
};

7328
yarn.lock

File diff suppressed because it is too large Load diff