From f083407889c7871877e7f1a8aa6e00f0e1fc24fc Mon Sep 17 00:00:00 2001 From: Spedon <70063177+Sped0n@users.noreply.github.com> Date: Mon, 6 Nov 2023 16:07:56 +0800 Subject: [PATCH] add i18n 404 and README support (#132) * feat(params.toml): enable analytics and configure Umami Analytics Enable analytics by setting `enable` to `true` in the `[analytics]` section of the `params.toml` file. Also, configure Umami Analytics by providing the `data_website_id`, `src`, and `data_domains` values. * feat(404.html): replace hardcoded "404 page not found" text with translated version to improve localization * feat(README.md): add README.md file with information about the Bridget theme and its features feat(getStarted.md): add getStarted.md file with instructions on how to get started with the Bridget theme, including installation and content management instructions --- README.md | 42 ++++++ doc/getStarted.md | 171 ++++++++++++++++++++++++ exampleSite/config/_default/params.toml | 8 +- i18n/de.toml | 2 + i18n/en.toml | 2 + i18n/es.toml | 2 + i18n/fr.toml | 2 + i18n/it.toml | 2 + i18n/ja.toml | 2 + i18n/ko.toml | 2 + i18n/zh-cn.toml | 2 + i18n/zh-hk.toml | 2 + i18n/zh-mo.toml | 2 + i18n/zh-sg.toml | 2 + i18n/zh-tw.toml | 2 + layouts/404.html | 6 +- 16 files changed, 244 insertions(+), 7 deletions(-) create mode 100644 README.md create mode 100644 doc/getStarted.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..2326303 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# Bridget + +![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/Sped0n/bridget/build.yml?logo=github) ![GitHub deployments](https://img.shields.io/github/deployments/Sped0n/bridget/Production?logo=vercel&label=deploy) + +Bridget is a minimal [Hugo](https://gohugo.io) theme designed for photographers / visual artists. + +It’s based on the https://github.com/tylermcrobert/bridget-pictures-www. + +## Getting Started + +Head to this [documentation](https://github.com/Sped0n/bridget/blob/main/doc/getStarted.md) for a complete guidance to get started with the Bridget theme. + +## Feature + +- **Blazingly fast**: 99/100 on mobile and 100/100 on desktop in [Google PageSpeed Insights](https://developers.google.com/speed/pagespeed/insights) + +- JS **dynamic loading** (powered by ES6 syntax) +- JS **code splitting** by [rollup.js](https://rollupjs.org) +- Image **Preloading**/**Lazy loading** +- **Dynamic resolution** based on view mode +- Multiple **analytics** services supported +- Search engine **verification** supported (Google, Bind, Yandex and Baidu) + +## Multilingual and i18n + +Bridget supports the following languages: + +- English +- Simplified Chinese +- Traditional Chinese +- Japanese +- Korean +- Deutsch +- Spanish +- Italian +- [Contribute with a new language](https://github.com/Sped0n/bridget/pulls) + +## Credits + +- https://github.com/tylermcrobert/bridget-pictures-www +- https://www.youtube.com/watch?v=Jt3A2lNN2aE +- https://github.com/d4cho/bridget-pictures-clone diff --git a/doc/getStarted.md b/doc/getStarted.md new file mode 100644 index 0000000..23ce1f0 --- /dev/null +++ b/doc/getStarted.md @@ -0,0 +1,171 @@ +# Getting Started + +The files in `exampleSite` is just a simple example. Now, we will introduce it based on the same structure. + +## Requirements + +Before you start, make sure you have installed Hugo **extended version**. For more information, see [Hugo's documentation](https://gohugo.io/getting-started/installing/). + +Once you have installed Hugo, you can check the version by running the following command: + +```shell +hugo version +``` + +Which should output something like this (the version number may be different), notice the `extended` keyword: + +```shell +hugo v0.120.3-a4892a07b41b7b3f1f143140ee4ec0a9a5cf3970+extended darwin/arm64 BuildDate=2023-11-01T17:57:00Z VendorInfo=brew +``` + +The minimum required Hugo version can be seen in the [`theme.toml`](https://github.com/Sped0n/bridget/blob/main/theme.toml#L19). + +## Installation + +### Git + +On the main branch, you can find the theme's latest source code. To use the latest version, you can clone the repository to `themes/bridget` by running the following command in the root directory of your Hugo site: + +```shell +git clone https://github.com/Sped0n/bridget themes/bridget +``` + +If you are already using Git for your site, you can add the theme as a submodule by running the following command in the root directory of your Hugo site: + +```shell +git submodule add https://github.com/Sped0n/bridget themes/bridget +``` + +### Module (recommended) + +> If you want to modify the theme, use Git installation instead. + +This theme is also available as a [Hugo module](https://gohugo.io/hugo-modules/). Run the following command in the root directory of your Hugo site: + +First turn your site into a Hugo module (in case you haven't done it yet): + +```shell +hugo mod init github.com/me/my-new-site +# or whatever you like, it doesn’t necessarily have to be a GitHub link. +hugo mod init blablabla +``` + +Then import the theme as a dependency adding the following line to the `module` section of your site's configuration file. + +```toml +# config/_default/hugo.toml +[module] +[[module.imports]] +path = "github.com/Sped0n/bridget" +``` + +If you want to upgrade the theme, just run: + +```shell +hugo mod get -u +``` + +## Content Management + +The content is where the pictures/text is stored, while the static refers to the website icons. + +``` +. +├── content +│ ├── Erwitt +│ │ ├── 1.jpg +│ │ ├── *** +│ │ └── index.md +│ ├── Gruyaert +│ │ ├── 1.jpg +│ │ ├── *** +│ │ └── index.md +│ ├── Info +│ │ └── index.md +│ └── Webb +│ ├── 1.jpg +│ ├── *** +│ └── index.md +└── static + ├── dot.png + └── dot.svg +``` + +In each index.md file, there is a configuration file like this: + +```markdown +--- +type: _default +layout: single +url: /erwitt/ +menu: + main: + weight: 3 + identifier: Erwitt + title: Erwitt +unifiedAlt: '© Elliott Erwitt' +--- +``` + +- keep the `type` and `layout` **untouched**; + +- `url` is the href link to this page, in this case, you can visit this page with `blabla.com/erwitt`; + +- `main` is the entry to `menu`; + +- `weight` determines the position of this link in the navigation bar, with the first one being 1, the second one being 2, and so on; + +- `identifier` should be the **same** as the name of the **upper-level directory**; + +- `title` refers to the text that appears on the navigation bar; + +- `unifiedAlt` is **optional**, If you left it empty, the alt attribute of the image will default to its file name; if it is set, the alt attributes of all images will be unified to the value you have set; + +- If this is a **showcase** page, simply place the images in the same directory as index.md. + +- If this is an **information** page, you can continue writing the information you want to display in index.md. + + > However, please note that the CSS for the information page **only provides simple styling for text**. If you have any requirements beyond text and the browser rendering does not meet your expectations, please modify [`_article.scss`](https://github.com/Sped0n/bridget/blob/main/assets/scss/_partial/_article.scss). + +As for the **website icon**, place the files in static and then go to config part for further reading. + +## Config + +You can simply copy this to the root directory of your site with minor modifications, and you’ll be ready to proceed. + +``` +. +└── config + └── _default + ├── hugo.toml + ├── markup.toml + ├── params.toml + └── sitemap.toml +``` + +### `hugo.toml` + +We will focus on introducing the part about `theme as module`, detailed comments are provided for other options, so we won’t repeat them here. + +```toml +# theme as module +[module] +replacements = "github.com/Sped0n/bridget -> ../.." +[[module.imports]] +path = "github.com/Sped0n/bridget" +``` + +- If you want to modify the theme or you have installation with Git, please keep the `replacements` configuration and change the path after the arrow to the location of your local theme file. +- If you have installation with Module, remove the `replacements` configuration. + +### `markup.toml` + +**DO NOT TOUCH THIS** + +### `params.toml` + +There is a detailed description in the comments. + +### `sitemap.toml` + +https://gohugo.io/templates/sitemap-template/#configuration diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 0b1176d..252ad53 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -30,7 +30,7 @@ sogou = "" # Analytics config [analytics] -enable = false +enable = true # Google Analytics [analytics.google] id = "" @@ -46,10 +46,10 @@ server = "" id = "" # Umami Analytics [analytics.umami] -data_website_id = "" -src = "" +data_website_id = "44a4a42d-ec8e-44c9-a38c-7533929e9845" +src = "https://umami.sped0nwen.com/script.js" data_host_url = "" -data_domains = "" +data_domains = "bridget-demo.sped0nwen.com" # Plausible Analytics [analytics.plausible] data_domain = "" diff --git a/i18n/de.toml b/i18n/de.toml index b40d115..d002021 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -6,3 +6,5 @@ other = "vorher" other = "schließen" [threshold] other = "schwelle" +[404] +other = "seite nicht gefunden" diff --git a/i18n/en.toml b/i18n/en.toml index c97351b..3e68700 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -6,3 +6,5 @@ other = "prev" other = "close" [threshold] other = "threshold" +[404] +other = "page not found" diff --git a/i18n/es.toml b/i18n/es.toml index b1a40d8..492e36c 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -6,3 +6,5 @@ other = "previo" other = "cerrar" [threshold] other = "umbral" +[404] +other = "página no encontrada" diff --git a/i18n/fr.toml b/i18n/fr.toml index b1982dc..1e8cded 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -6,3 +6,5 @@ other = "précédent" other = "fermer" [threshold] other = "seuil" +[404] +other = "page non trouvée" diff --git a/i18n/it.toml b/i18n/it.toml index c31b77b..8c5c330 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -6,3 +6,5 @@ other = "precedente" other = "chiudi" [threshold] other = "soglia" +[404] +other = "pagina non trovata" diff --git a/i18n/ja.toml b/i18n/ja.toml index 0eff0b5..02e803b 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -6,3 +6,5 @@ other = "後退" other = "閉じる" [threshold] other = "しきい値" +[404] +other = "ページが見つかりません" diff --git a/i18n/ko.toml b/i18n/ko.toml index 908bd1c..f3149e1 100644 --- a/i18n/ko.toml +++ b/i18n/ko.toml @@ -6,3 +6,5 @@ other = "물러나세요" other = "닫기" [threshold] other = "임계값" +[404] +other = "페이지를 찾을 수 없습니다" diff --git a/i18n/zh-cn.toml b/i18n/zh-cn.toml index 3649b93..31fcbb9 100644 --- a/i18n/zh-cn.toml +++ b/i18n/zh-cn.toml @@ -6,3 +6,5 @@ other = "后退" other = "关闭" [threshold] other = "阈值" +[404] +other = "页面不存在" diff --git a/i18n/zh-hk.toml b/i18n/zh-hk.toml index 81d2188..9de5480 100644 --- a/i18n/zh-hk.toml +++ b/i18n/zh-hk.toml @@ -6,3 +6,5 @@ other = "後退" other = "關閉" [threshold] other = "閾值" +[404] +other = "找不到頁面" diff --git a/i18n/zh-mo.toml b/i18n/zh-mo.toml index 81d2188..9de5480 100644 --- a/i18n/zh-mo.toml +++ b/i18n/zh-mo.toml @@ -6,3 +6,5 @@ other = "後退" other = "關閉" [threshold] other = "閾值" +[404] +other = "找不到頁面" diff --git a/i18n/zh-sg.toml b/i18n/zh-sg.toml index 3649b93..31fcbb9 100644 --- a/i18n/zh-sg.toml +++ b/i18n/zh-sg.toml @@ -6,3 +6,5 @@ other = "后退" other = "关闭" [threshold] other = "阈值" +[404] +other = "页面不存在" diff --git a/i18n/zh-tw.toml b/i18n/zh-tw.toml index 81d2188..9de5480 100644 --- a/i18n/zh-tw.toml +++ b/i18n/zh-tw.toml @@ -6,3 +6,5 @@ other = "後退" other = "關閉" [threshold] other = "閾值" +[404] +other = "找不到頁面" diff --git a/layouts/404.html b/layouts/404.html index a195bd3..e47c069 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -9,8 +9,8 @@ {{- partial "nav.html" . -}}
-

404 page not found ⛝

-

404 page not found ⛝

-

404 page not found ⛝

+

404 {{- i18n 404 -}} ⛝

+

404 {{- i18n 404 -}} ⛝

+

404 {{- i18n 404 -}} ⛝

{{- end -}}