Skip to content

Commit 6c705c1

Browse files
author
Alban Bailly
committed
create child theme
1 parent 9d95b58 commit 6c705c1

File tree

28 files changed

+6013
-3
lines changed

28 files changed

+6013
-3
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
yarn-error.log
3+
.DS_Store
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "stylelint-config-standard",
3+
"rules": {
4+
"no-missing-end-of-source-newline": null,
5+
}
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Adam Wathan <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Linode Hugo Bade Theme
2+
3+
Base theme for Hugo. Using PostCSS, TailwindCSS and gulp as a task manager.
4+
Lightweight, versatile and aimed to facilitate developmenmt by using utlility classes while remaining lean.
5+
6+
## Setup
7+
8+
Install Dependencies
9+
`yarn`
10+
11+
Compile
12+
`gulp`
13+
14+
Watch during development
15+
`gulp watch`
16+
17+
## Tools
18+
19+
This theme uses <a href="https://tailwindcss.com/docs/what-is-tailwind/" target="_blank">TailwindCSS</a> as a utlility library.
20+
Just add the classes provided by the library to tailor your application.
21+
22+
add
23+
24+
```
25+
[params.dev]
26+
enable = true
27+
```
28+
29+
to your `config.toml` (root dir) to enable the css helper. This will enable a small icon in the bottom right corner of your site. This helper shows you what's available in your css to use for your markup.
30+
It is a combination of the tailwind styles and custom styles from your theme's CSS.
31+
32+
To avoid ending up with a very large bundle of unused css utility classes, the gulp setup uses CSSPurge to strip whatever is not used in the HUGO layouts.
33+
This ensures a small css bundle for production use.
34+
35+
The gulp setup also includes a linter and the nanocss minifier.
36+
37+
## Architecture
38+
39+
In order to customize this theme, the proper way is to move/copy the enclosed CHILD-THEME under the `/themes` dir, rename it to your liking and add your modifications from within.
40+
This will ensure the maintainability of the linode-base-theme for future updates.
41+
42+
*Note*: You will need to make sure the theme inheritance is set up in your config.toml. (See <a href="https://gohugo.io/themes/theme-components/" target="_blank">Theme Components</a>).
43+
44+
for instance:
45+
46+
```
47+
theme = ["my-new-theme(child-theme)", "linode-base-theme"]
48+
```
49+
50+
The theme follows the concept of <a href="http://bradfrost.com/blog/post/atomic-web-design/" target="_blank">Atomic Design</a> to structure its templates and CSS.
51+
It is a rather arbitrary set of rules to keep a consistent design system when dealing with a large amount of templates and help with template inheritance.
52+
53+
You will probably want to keep a similar structure for template overriding: see the <a href="https://gohugo.io/templates/lookup-order/" target="_blank">lookup order</a> for more info.
54+
55+
## Default Content
56+
57+
The theme uses `config.toml` to populate some of its templates, so it will probably be empty upon installation.
58+
59+
ex: `layouts/partials/2_molecules/nav.html`
60+
relies on such definition in `config.toml`
61+
62+
```
63+
[menu]
64+
65+
[[menu.main]]
66+
weight = 1
67+
name = "Page 1"
68+
url = "/"
69+
70+
[[menu.main]]
71+
weight = 2
72+
name = "Page 2"
73+
url = "page2"
74+
75+
[[menu.main]]
76+
weight = 3
77+
name = "Page 3"
78+
url = "page3"
79+
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "{{ replace .Name "-" " " | title }}"
3+
date: {{ .Date }}
4+
draft: true
5+
---
6+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
const gulp = require('gulp');
2+
const postcss = require('gulp-postcss');
3+
const plumber = require('gulp-plumber');
4+
const tailwindcss = require('tailwindcss');
5+
const atImport = require('postcss-easy-import');
6+
const purgecss = require('gulp-purgecss')
7+
const autoprefixer = require('autoprefixer');
8+
const cssInfo = require('gulp-css-info');
9+
const cssnano = require('cssnano');
10+
const stylelint = require('stylelint');
11+
const reporter = require('postcss-reporter');
12+
13+
const tailwind = 'tailwind.js';
14+
const mainCss = './srcCSS/main.css';
15+
const css = './srcCSS/**/*.css';
16+
const html = './layouts/**/*.html'
17+
const output = 'static/assets/css/';
18+
const cssInfoDir = 'static/assets/cssinfo/';
19+
20+
const plugins = [
21+
atImport,
22+
tailwindcss('./tailwind.js'),
23+
autoprefixer({
24+
browsers: ['last 2 versions', '> 2%']
25+
}),
26+
cssnano
27+
];
28+
29+
gulp.task('lint', () => {
30+
return gulp.src('./srcCSS/**/*.css')
31+
.pipe(postcss([
32+
stylelint(),
33+
reporter(),
34+
]));
35+
});
36+
37+
gulp.task('cssInfo', () => {
38+
return gulp.src(mainCss)
39+
.pipe(postcss(plugins))
40+
.pipe(cssInfo())
41+
.pipe(gulp.dest(cssInfoDir))
42+
});
43+
44+
gulp.task('compile', () => {
45+
return gulp.src(mainCss)
46+
.pipe(plumber())
47+
.pipe(postcss(plugins))
48+
.pipe(
49+
purgecss({
50+
content: [html],
51+
whitelist: ['mobile-nav', ['active']]
52+
})
53+
)
54+
.pipe(gulp.dest(output));
55+
});
56+
57+
gulp.task('watch:css', () => {
58+
gulp.watch(css, ['compile']);
59+
});
60+
61+
gulp.task('watch:html', () => {
62+
gulp.watch(html, ['compile']);
63+
});
64+
65+
gulp.task('watch:tailwind', () => {
66+
gulp.watch(tailwind, ['compile']);
67+
});
68+
69+
gulp.task('default', ['lint', 'compile', 'cssInfo']);
70+
gulp.task('watch', ['compile', 'watch:css', 'watch:html', 'watch:tailwind']);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>Tailwind Starter Template</title>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
<link rel="stylesheet" href="./dist/styles.css">
8+
</head>
9+
<body>
10+
<div class="min-h-screen flex items-center justify-center">
11+
<h1 class="text-5xl text-purple font-sans">Greetings.</h1>
12+
</div>
13+
</body>
14+
</html>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"private": true,
3+
"scripts": {},
4+
"devDependencies": {},
5+
"dependencies": {
6+
"autoprefixer": "^8.6.5",
7+
"cssnano": "^4.0.0",
8+
"glob": "^7.1.2",
9+
"gulp": "^3.9.1",
10+
"gulp-css-info": "^1.0.1",
11+
"gulp-plumber": "^1.2.0",
12+
"gulp-postcss": "^7.0.1",
13+
"gulp-purgecss": "^1.0.0",
14+
"gulp-watch": "^5.0.0",
15+
"postcss": "^6.0.14",
16+
"postcss-easy-import": "^3.0.0",
17+
"postcss-reporter": "^5.0.0",
18+
"stylelint": "^9.3.0",
19+
"stylelint-config-standard": "^18.2.0",
20+
"tailwindcss": "^0.5.3"
21+
}
22+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:root {
2+
}

themes/linode-hugo-base-theme/CHILD-THEME/srcCSS/components/0_utilities/layout.css

Whitespace-only changes.

themes/linode-hugo-base-theme/CHILD-THEME/srcCSS/components/0_utilities/typography.css

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.visually-hidden {
2+
position: absolute;
3+
width: 1px;
4+
height: 1px;
5+
padding: 0;
6+
margin: -1px;
7+
overflow: hidden;
8+
clip: rect(0,0,0,0);
9+
border: 0;
10+
}

themes/linode-hugo-base-theme/CHILD-THEME/srcCSS/components/1_atoms/logo.css

Whitespace-only changes.

themes/linode-hugo-base-theme/CHILD-THEME/srcCSS/components/2_molecules/mobile-nav.css

Whitespace-only changes.

themes/linode-hugo-base-theme/CHILD-THEME/srcCSS/components/2_molecules/nav.css

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import 'tailwind.css';
2+
@import './**/*.css';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@import "tailwindcss/preflight";
2+
@import "tailwindcss/components";
3+
@import "tailwindcss/utilities";

themes/linode-hugo-base-theme/CHILD-THEME/static/assets/css/main.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

themes/linode-hugo-base-theme/CHILD-THEME/static/assets/js/main.js

Whitespace-only changes.
Lines changed: 49 additions & 0 deletions
Loading
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)