Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix prettier, move pages, add husky #14

Merged
merged 8 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: lint

on:
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

permissions:
contents: write

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up node
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Prettify code
run: npx prettier . --check
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"plugins": ["@shopify/prettier-plugin-liquid"],
"singleQuote": true,
"overrides": [
{
"files": "*.html",
"options": {
"parser": "liquid-html",
"singleQuote": false
}
}
]
}
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem "webrick", "~> 1.7"
gem 'jekyll-sass-converter', '~> 2.1.0'
gem 'jekyll-sass-converter', '~> 2.1.0'
84 changes: 28 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,40 @@
# TWC The Netherlands

This repository is responsible for most content visible on the website [techwerkers.nl](https://techwerkers.nl). The site is made with a static site generator called [Jekyll](https://jekyllrb.com/) in a language called Ruby.
[![Netlify Status][netlify_bagde]][netlify_url]
[![Code style][code_style_badge]][code_style_url]
[![Twitter: nederlandtwc][twitter_badge]][twitter_url]

## Getting Started
[![website][website_badge]][website_url]
[![production][production_badge]][production_url]
[![i18n-en][i18n_en_badge]][i18n_en_url]
[![i18n-nl][i18n_nl_badge]][i18n_nl_url]

### With Docker (recommended)
> This repository is responsible for most content visible on the website [techwerkers.nl](https://techwerkers.nl). The site is made with a static site generator called [Jekyll](https://jekyllrb.com/) in a language called Ruby.

We use Docker to have a reproducible development environment.
Before proceeding, install [Docker Compose](https://docs.docker.com/compose/install/) on your system.
## 🛠️ Installation

1. Start the application with the command: `docker-compose up`
2. Access the application in a browser at `localhost:4000`
3. Execute other commands in the Docker container: `docker-compose run --rm --service-ports jekyll bash`
Read the [installation guide](./docs/contributing.md) to get set up.

### Without Docker
## 🤝 Contributing

1. Install dependencies: `bundle install`
2. Start a local server: `bundle exec jekyll serve`
3. Verify all internal links are valid: `bundle exec rake`
4. (Optional) to reproduce Netlify functions run `npx decap-server`; then you can access `/admin` or other Netlify services
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://github.com/techworkersco/twc-site-nl/issues). You can also take a look at the [contributing guide](./docs/contributing.md).

Open a browser to localhost:4000
<!-- Links -->

## Add an event
[code_style_badge]: https://img.shields.io/badge/code%20style-prettier-F7B93E?logo=Prettier
[code_style_url]: /.prettierrc
[netlify_bagde]: https://api.netlify.com/api/v1/badges/05f9fda5-6fd8-418d-9cee-67882c0f5dba/deploy-status
[netlify_url]: https://app.netlify.com/sites/twc-site-nl/deploys
[website_badge]: https://img.shields.io/badge/website-url-blue.svg
[website_url]: https://techwerkers.nl/
[production_badge]: https://img.shields.io/badge/production-url-blue.svg
[production_url]: https://app.netlify.com/sites/twc-site-nl/deploys
[twitter_badge]: https://img.shields.io/twitter/follow/nederlandtwc.svg?style=social
[twitter_url]: https://twitter.com/nederlandtwc

Add a file inside the [`_events`](_events) directory. Copy a previous file as a template, and make sure to include the right time zone for The Netherlands!
<!-- i18n Links -->

## Add a blog post (inside /blog)

Add a file inside the [`_blog`](_blog) directory. Copy a previous file as a template. If an author does not exist, add one inside [`_data/authors.yml`](_data/authors.yml). A name is the only thing necessary, but photo is optional too.

## Add a press mention

Inside [`_data/press.yml`](_data/press.yml) file, add a media entry, with date format in `YYYY-MM-DD`.

## Translation

I18n (internationalization) is made available with the [jekyll-multiple-languages-plugin](https://github.com/kurtsson/jekyll-multiple-languages-plugin/). When a page has a translated version available, a link will show up on the top right if you use the [default_translate](_layouts/default_translate.html) layout. English is the default language, while other languages have their two letter ISO code prefixed, for example [TechWorkersCoalition.org/ru](https://TechWorkersCoalition.org/ru) for Russian.

### Localise date
Normally displaying a date is done using native liquid templates `{{ page.date | date: '%-d %B %Y' }}`, but for localisation, we need to pass it a language which can be done using our custom [_plugins/i18n_filter.rb](_plugins/i18n_filter.rb), and translation keys. We would replace our liquid template with the following:

`{{ page.date | localize: site.lang, '%-d %B %Y' }}`

### Adding new language
1. Add new language key to [en.yml](_i18n/en.yml)
2. Add two letter iso code in [config](_config.yml). The order here determines the order shown on the page. English must be first.
3. Inside the [i18n](_i18n) directory create a
- `LANGUAGE.yml` with the language key and value in its own language, for example `es: Español`

Note, only the default [en.yml](_i18n/en.yml) must contain the names of each language. The other language yaml files contain just their own language key. To include only certain languages, specify the exact language keys you want. For example `languages: ["en", 'ja']`


### API feeds

Currently [techworkerscoalition.org](https://techworkerscoalition.org) uses Berlin press and events either from GitHub or directly from our exposed APIs e.g [/events.json](https://techwerkers.nl/events.json). You can find other uses cases [here](https://github.com/techworkersco/twc-site/blob/master/_config.yml#L32)


### Supported Pages
* Landing Page [index.yml](index.md)
* Join Page [join.md](join.md)
* Events [events.md](events.md)
* Press mentions [press_mentions.md](press_mentions.md)

### Supported Languages
* English
* Nederlands
[i18n_en_badge]: https://img.shields.io/badge/i18n-en-orange.svg
[i18n_en_url]: ./_i18n/en.yml
[i18n_nl_badge]: https://img.shields.io/badge/i18n-nl-orange.svg
[i18n_nl_url]: ./_i18n/nl.yml
33 changes: 18 additions & 15 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
title: Tech Werkers NL
email: [email protected]
description: Tech Workers Coalition Netherlands is where tech workers come together to build collective power in our workplaces.
url: "https://techwerkers.nl"
baseurl: ""
timezone: "Europe/Amsterdam"

sass:
style: compressed
url: 'https://techwerkers.nl'
baseurl: ''
timezone: 'Europe/Amsterdam'

# Build settings
feed:
Expand Down Expand Up @@ -52,10 +49,13 @@ social:

sass:
style: compressed

include:
- _pages
exclude:
- .jekyll-cache/
languages: ["en", "nl"]
exclude_from_localizations: ["assets", "admin", "vendor"]
languages: ['en', 'nl']
exclude_from_localizations: ['assets', 'admin', 'vendor']
header_themes:
- url: /about
text: about
Expand All @@ -70,19 +70,22 @@ collections:
events:
output: true
permalink: events/:title
pages:
output: true
permalink: /:path

defaults:
- scope:
path: ""
path: ''
values:
image: /assets/img/beat_the_boss.jpg
- scope:
type: "events"
path: ""
type: 'events'
path: ''
values:
layout: "event"
layout: 'event'
- scope:
type: "blog"
path: ""
type: 'blog'
path: ''
values:
layout: "blog"
layout: 'blog'
5 changes: 3 additions & 2 deletions _events/mozfest-house-amsterdam.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
title: "MozFest House: Amsterdam"
title: 'MozFest House: Amsterdam'
date: 2024-06-12 09:00
locations:
- Online
hide_form: false
image: ""
image: ''
---

Find our table stand for some Zines and to meet tech workers!
11 changes: 5 additions & 6 deletions _i18n/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ home:
more: Find more blog posts
other_chapters:
title: Other chapters
more: |
more: |
<p>Find other chapters of Tech Workers Coalition <a href="https://techworkerscoalition.org/chapters/">this overview</a>.</p>


connect:
info: Get involved!
Expand Down Expand Up @@ -55,10 +54,10 @@ press:
en:
time:
formats:
default: "%A, %d %b %Y %H:%M"
default: '%A, %d %b %Y %H:%M'
date:
formats:
default: "%-d %B %Y"
default: '%-d %B %Y'
order:
- :day
- :month
Expand All @@ -84,7 +83,7 @@ en:
- Sept
- Oct
- Nov
- Dec
- Dec
day_names:
- Sunday
- Monday
Expand All @@ -106,4 +105,4 @@ en:
- September
- October
- November
- December
- December
12 changes: 6 additions & 6 deletions _i18n/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ home:
more: Alle blogs
other_chapters:
title: Andere groepen
more: |
more: |
<p>Ontdek andere groepen binnen de Techwerkerscoalitie in <a href="https://techworkerscoalition.org/chapters/">dit overzicht</a>.</p>

connect:
Expand All @@ -33,7 +33,7 @@ connect:
public_link: Sociale media link
public_link_placeholder: LinkedIn, Xitter, Mastodon, etc.
company: Werkgever
how_did_hear: Wat zou jou helpen je doelen te bereiken?
how_did_hear: Wat zou jou helpen je doelen te bereiken?
subscribe: Doe mee

global:
Expand All @@ -53,12 +53,12 @@ press:
nl:
time:
formats:
default: "%A, %-d %B %Y %H:%M"
long: "%-d %B %Y %H:%M"
short: "%d %b %H:%M"
default: '%A, %-d %B %Y %H:%M'
long: '%-d %B %Y %H:%M'
short: '%d %b %H:%M'
date:
formats:
default: "%-d %B %Y"
default: '%-d %B %Y'
order:
- :day
- :month
Expand Down
68 changes: 35 additions & 33 deletions _includes/blog.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% unless page.permalink == "/blog" %}
{% unless page.permalink == '/blog' %}
<a href="/blog">{% t home.blog.more %}</a>
{% endunless %}
<ul
Expand All @@ -8,38 +8,40 @@
{% assign limit = include.limit %}
{% assign sorted_posts = site.blog | filter_tags: include.tags | sort: 'date' | reverse %}
{% for post in sorted_posts limit: limit %}
{% assign author = site.data.authors[post.author] | default:
site.data.authors['techworkersber'] %}
{% assign author = site.data.authors[post.author] | default: site.data.authors.techworkersber %}

<li>
<article
class="event-card__info-column l-stack -vertical"
style="--stack-spacing: 0.5rem"
aria-labelledby="news-{{ post.title | slugify }}">
<section class="l-stack -horizontal" style="--stack-spacing: 1rem">
<div class="l-stack -horizontal" style="--stack-spacing: 0.25rem">
{% if author.picture %}
<img
class="h-rounded"
style="--circle-size: 1.75rem"
src="{{author.picture}}"
alt="{{author.name}}"
/>
{% endif %}
<span>{{ author.name }}</span>
</div>
<time
class="aside"
datetime="{{ post.date | date: '%Y-%m-%d' }}"
>{{ post.date | localize: site.lang, '%-d %B %Y' }}</time>
</section>
{% if limit %}<h3{% else %}<h2{% endif %}
class="event-card__title"
id="news-{{ post.title | slugify }}"
>
<a href="{{ post.url }}" class="event-card__link">{{ post.title }}</a>
{% if limit %}</h3>{% else %}</h2>{% endif %}
</article>
</li>
<li>
<article
class="event-card__info-column l-stack -vertical"
style="--stack-spacing: 0.5rem"
aria-labelledby="news-{{ post.title | slugify }}"
>
<section class="l-stack -horizontal" style="--stack-spacing: 1rem">
<div class="l-stack -horizontal" style="--stack-spacing: 0.25rem">
{% if author.picture %}
<img
class="h-rounded"
style="--circle-size: 1.75rem"
src="{{author.picture}}"
alt="{{author.name}}"
>
{% endif %}
<span>{{ author.name }}</span>
</div>
<time class="aside" datetime="{{ post.date | date: '%Y-%m-%d' }}">
{{- post.date | localize: site.lang, '%-d %B %Y' -}}
</time>
</section>
{% if limit %}
<h3 class="event-card__title" id="news-{{ post.title | slugify }}">
<a href="{{ post.url }}" class="event-card__link">{{ post.title }}</a>
</h3>
{% else %}
<h2 class="event-card__title" id="news-{{ post.title | slugify }}">
<a href="{{ post.url }}" class="event-card__link">{{ post.title }}</a>
</h2>
{% endif %}
</article>
</li>
{% endfor %}
</ul>
Loading