From 6cad47d247da0620be1f42b4e5fdc6fbfa590206 Mon Sep 17 00:00:00 2001 From: Matthew M-B Date: Sat, 15 May 2021 22:30:55 -0400 Subject: [PATCH] configured prettier and github actions (#19) * prettier setup * formatted by prettier * github actions test * github actions fix * fix --- .github/workflows/workflow.yml | 14 ++++++ .gitignore | 3 +- .prettierrc | 10 ++++ assets/js/index.js | 6 +-- assets/js/navbar.js | 6 +-- assets/scss/_global.scss | 6 +-- assets/scss/components/_navbar.scss | 9 ++-- assets/scss/components/_overlaypost.scss | 59 ++++++++++++------------ assets/scss/components/_posts.scss | 44 +++++++++--------- assets/scss/main.scss | 6 +-- layouts/404.html | 1 - layouts/_default/announcement.html | 25 +++++----- layouts/_default/baseof.html | 10 ++-- layouts/_default/list.html | 6 +-- layouts/_default/overlaypost.html | 34 ++++++++------ layouts/_default/single.html | 6 +-- layouts/index.html | 6 +-- layouts/partials/footer.html | 5 +- layouts/partials/head.html | 23 +++++---- layouts/partials/navbar.html | 58 ++++++++++++----------- package-lock.json | 20 ++++++++ package.json | 25 ++++++++++ readme.md | 11 ++++- 23 files changed, 244 insertions(+), 149 deletions(-) create mode 100644 .github/workflows/workflow.yml create mode 100644 .prettierrc create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 000000000..f5c7e8684 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,14 @@ +name: CI +'on': + - push +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install modules + run: | + npm install + - name: Run Prettier + run: | + npm run check diff --git a/.gitignore b/.gitignore index d6773623f..f8933ca22 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /public -_gen \ No newline at end of file +_gen +node_modules diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..477a08ca4 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "overrides": [ + { + "files": ["*.html"], + "options": { + "parser": "go-template" + } + } + ] + } diff --git a/assets/js/index.js b/assets/js/index.js index 21c627df4..53517eec1 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -1,5 +1,5 @@ -function fileClosure(){ - console.log("Hello World") +function fileClosure() { + console.log("Hello World"); } -window.addEventListener('load', fileClosure()); +window.addEventListener("load", fileClosure()); diff --git a/assets/js/navbar.js b/assets/js/navbar.js index 400b77868..d17cbed07 100644 --- a/assets/js/navbar.js +++ b/assets/js/navbar.js @@ -1,5 +1,5 @@ -function loadNavbar(){ - console.log("Loaded Navbar") +function loadNavbar() { + console.log("Loaded Navbar"); } -window.addEventListener('load', loadNavbar()); +window.addEventListener("load", loadNavbar()); diff --git a/assets/scss/_global.scss b/assets/scss/_global.scss index 162791f7a..60630d6f7 100644 --- a/assets/scss/_global.scss +++ b/assets/scss/_global.scss @@ -1,5 +1,5 @@ body { - margin: 0; - padding: 0; - background-color: var(--bg); + margin: 0; + padding: 0; + background-color: var(--bg); } diff --git a/assets/scss/components/_navbar.scss b/assets/scss/components/_navbar.scss index 049d9f1af..3d7d58d21 100644 --- a/assets/scss/components/_navbar.scss +++ b/assets/scss/components/_navbar.scss @@ -105,7 +105,7 @@ li { height: 195px; } -.actual_content{ +.actual_content { color: black; position: fixed; -webkit-transition: all 600ms ease-out; @@ -133,8 +133,8 @@ li { z-index: 2; } -@for $i from 1 through $navItemsLength{ - #item#{$i}:hover ~ { +@for $i from 1 through $navItemsLength { + #item#{$i}:hover ~ { #actual_content#{$i} { z-index: 3 !important; -webkit-transition: all 400ms ease-in; @@ -148,7 +148,6 @@ li { } } - .item_block { -webkit-transition: all 500ms ease-out; -moz-transition: all 500ms ease-out; @@ -176,7 +175,7 @@ li { border-right: 2px solid black; } -.right_image{ +.right_image { background-repeat: no-repeat; background-position: 50%; background-size: cover; diff --git a/assets/scss/components/_overlaypost.scss b/assets/scss/components/_overlaypost.scss index eb5f084cf..4c2e9aaec 100644 --- a/assets/scss/components/_overlaypost.scss +++ b/assets/scss/components/_overlaypost.scss @@ -1,42 +1,41 @@ - .overlaypost_header { - background-size: cover; - background-repeat: no-repeat; - background-position: center; - position: absolute; - width: 100%; - height: 75vh; - background-color:black; - margin-top: -10rem; - z-index: -1; + background-size: cover; + background-repeat: no-repeat; + background-position: center; + position: absolute; + width: 100%; + height: 75vh; + background-color: black; + margin-top: -10rem; + z-index: -1; } .overlaypost_blur { - filter: blur(0.2rem); - -webkit-filter: blur(0.2rem); + filter: blur(0.2rem); + -webkit-filter: blur(0.2rem); } .overlaypost_header::after { - content: ""; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 1; - background: rgba(10,15,30,0.72); + content: ""; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1; + background: rgba(10, 15, 30, 0.72); } .overlaypost { - padding: 1rem 3.5rem; - max-width: 45rem; - margin: 0 auto; - margin-top: 10rem; - background-color: var(--bg); - box-shadow: 0px 0.5rem 1rem -0.5rem rgba(19, 17, 16, 0.384); - border-radius: 0.25rem; + padding: 1rem 3.5rem; + max-width: 45rem; + margin: 0 auto; + margin-top: 10rem; + background-color: var(--bg); + box-shadow: 0px 0.5rem 1rem -0.5rem rgba(19, 17, 16, 0.384); + border-radius: 0.25rem; - h2 { - margin-top: 2rem; - } + h2 { + margin-top: 2rem; + } } diff --git a/assets/scss/components/_posts.scss b/assets/scss/components/_posts.scss index 42fe7f091..b1f1e22a4 100644 --- a/assets/scss/components/_posts.scss +++ b/assets/scss/components/_posts.scss @@ -1,31 +1,31 @@ .post_header { - background-size: cover; - background-repeat: no-repeat; - background-position: center; - position: relative; - height: 40vh; - background-color: var(--bg); - margin-top: 3rem; + background-size: cover; + background-repeat: no-repeat; + background-position: center; + position: relative; + height: 40vh; + background-color: var(--bg); + margin-top: 3rem; } .post_header::after { - content: ""; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 1; - background: rgba(10,15,30,0.72); + content: ""; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: 1; + background: rgba(10, 15, 30, 0.72); } .post { - padding: 1rem 1.5rem; - margin-top: 1.5rem; - max-width: 45rem; - margin: 0 auto; + padding: 1rem 1.5rem; + margin-top: 1.5rem; + max-width: 45rem; + margin: 0 auto; - h2 { - margin-top: 2rem; - } + h2 { + margin-top: 2rem; + } } diff --git a/assets/scss/main.scss b/assets/scss/main.scss index d49526a8d..262e9497f 100644 --- a/assets/scss/main.scss +++ b/assets/scss/main.scss @@ -1,3 +1,3 @@ -@import 'variables'; -@import 'components'; -@import 'global'; \ No newline at end of file +@import "variables"; +@import "components"; +@import "global"; diff --git a/layouts/404.html b/layouts/404.html index 8b1378917..e69de29bb 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1 +0,0 @@ - diff --git a/layouts/_default/announcement.html b/layouts/_default/announcement.html index a6b030087..0dca483b3 100644 --- a/layouts/_default/announcement.html +++ b/layouts/_default/announcement.html @@ -1,15 +1,18 @@ {{ define "main" }} - {{- partial "navbar.html" . -}} + {{- partial "navbar.html" . -}} - - {{- if ne .Params.hideBanner true }} -
- {{- end }} + + {{- if ne .Params.hideBanner true }} +
+ {{- end }} - -
-
- {{- .Content }} -
-
+ +
+
+ {{- .Content }} +
+
{{ end }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 67c81e183..17761474d 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,8 +1,8 @@ - {{- partial "head.html" . -}} - - {{- block "main" . }}{{- end }} - - {{- partial "footer.html" . -}} + {{- partial "head.html" . -}} + + {{- block "main" . }}{{- end }} + + {{- partial "footer.html" . -}} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index dc645b1e2..b32415106 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,5 +1,5 @@ {{ define "main" }} -

List

-

{{ .Title }}

- {{ .Content }} +

List

+

{{ .Title }}

+ {{ .Content }} {{ end }} diff --git a/layouts/_default/overlaypost.html b/layouts/_default/overlaypost.html index efe4e46c7..0422f1cec 100644 --- a/layouts/_default/overlaypost.html +++ b/layouts/_default/overlaypost.html @@ -1,18 +1,24 @@ {{ define "main" }} - {{- partial "navbar.html" . -}} + {{- partial "navbar.html" . -}} - - {{- if ne .Params.hideBanner true }} -
-
- {{- end }} + + {{- if ne .Params.hideBanner true }} +
+
+ {{- end }} - -
-
- -

{{- .Params.title }}

- {{- .Content }} -
-
+ +
+
+ +

{{- .Params.title }}

+ {{- .Content }} +
+
{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index d9ddc1f7f..358740fb0 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,5 +1,5 @@ {{ define "main" }} -

Single

-

{{ .Title }}

- {{ .Content }} +

Single

+

{{ .Title }}

+ {{ .Content }} {{ end }} diff --git a/layouts/index.html b/layouts/index.html index 4d9168fa2..5b3ec4c54 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,5 +1,5 @@ {{ define "main" }} - {{- partial "navbar.html" . -}} -

Site

- {{ .Content }} + {{- partial "navbar.html" . -}} +

Site

+ {{ .Content }} {{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index a84b2c9fd..d87ce8d41 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,6 +1,5 @@ - {{- $mainScriptPath := "js/index.js" }} @@ -9,9 +8,9 @@ {{- $navbarScriptPath := "js/navbar.js" }} {{- $navbar := resources.Get $navbarScriptPath | resources.ExecuteAsTemplate $navbarScriptPath . }} -{{- $bundle := slice $main $navbar}} +{{- $bundle := slice $main $navbar }} {{- if site.Params.Staticman }} - {{- $bundle = slice $main $navbar}} + {{- $bundle = slice $main $navbar }} {{- end }} {{- $bundle = $bundle | resources.Concat "js/bundle.js" | resources.Fingerprint "sha512" -}} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 0b151b32d..dfdabf4e6 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,11 +1,16 @@ - - - {{- $options := (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") -}} - {{- $styles := resources.Get "scss/main.scss" | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS $options | resources.Fingerprint "sha512" }} - - - {{ $title := print .Site.Title " | " .Title }} - {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }} - {{ $title }} + + + {{- $options := (dict "targetPath" "css/styles.css" "outputStyle" "compressed" "enableSourceMap" "true") -}} + {{- $styles := resources.Get "scss/main.scss" | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS $options | resources.Fingerprint "sha512" }} + + + {{ $title := print .Site.Title " | " .Title }} + {{ if .IsHome }}{{ $title = .Site.Title }}{{ end }} + {{ $title }} diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index 2290fed92..5c0c84a42 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -1,28 +1,34 @@ - diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..0c0df7b4c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,20 @@ +{ + "name": "ccss-website", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "prettier": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", + "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", + "dev": true + }, + "prettier-plugin-go-template": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/prettier-plugin-go-template/-/prettier-plugin-go-template-0.0.10.tgz", + "integrity": "sha512-TaHPqiMK/zfk+YhvKRf/1WZDgQ6ffnlxJZX5rwphqfxBOVEezZQtYistTB348MKrKnnwKpyXZWpMRo0/KCVB+A==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..ae845ca43 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "ccss-website", + "version": "1.0.0", + "description": "```bash", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "check": "prettier --check '{layouts,assets}/**/*.{css,scss,html,js}'", + "format": "prettier --write '{layouts,assets}/**/*.{css,scss,html,js}'" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/CarletonComputerScienceSociety/ccss-website.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/CarletonComputerScienceSociety/ccss-website/issues" + }, + "homepage": "https://github.com/CarletonComputerScienceSociety/ccss-website#readme", + "devDependencies": { + "prettier": "2.1.1", + "prettier-plugin-go-template": "0.0.10" + } +} diff --git a/readme.md b/readme.md index 47ac66b09..38bbba606 100644 --- a/readme.md +++ b/readme.md @@ -10,4 +10,13 @@ hugo new events/.md hugo new news/.md -```` +``` + +## Prettier + +npm is only used for adding developer dependencies and does not interface with hugo in anyway. The main dependency is prettier. + +```bash +npm install +npm run format +```