Skip to content
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
77 changes: 77 additions & 0 deletions .github/workflows/check-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Check links

on: pull_request

env:
HUGO_VERSION: 0.147.8
WORKING_DIR: _hugo-site

jobs:
check-links:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Restore lychee cache
uses: actions/cache@v4
with:
path: .lycheecache
key: cache-lychee-${{ runner.os }}-${{ github.ref_name }}
restore-keys: |
cache-lychee-${{ runner.os }}-
cache-lychee-

- name: Build Hugo
run: |
npm ci
env HUGO_LANGUAGES_EN_BASEURL=/ HUGO_LANGUAGES_ZH_BASEURL=/ \
hugo --environment development --minify
pwd

- name: Verify Hugo output exists
run: |
test -d public/en || (echo "${{ env.WORKING_DIR }}/public/en not found"; exit 1)
echo "EN HTML count:" $(find public/en -type f -name '*.html' | wc -l)
test -d public/zh || (echo "${{ env.WORKING_DIR }}/public/zh not found"; exit 1)
echo "ZH HTML count:" $(find public/zh -type f -name '*.html' | wc -l)

- name: Check links in English
uses: lycheeverse/lychee-action@5c4ee84814c983aa7164eaee476f014e53ff3963 # v2.5.0
env:
LYCHEE_USE_HTML5EVER: "1"
with:
workingDirectory: ${{ env.WORKING_DIR }}
args: >-
--verbose
--no-progress
--include-verbatim
--dump
--root-dir "${{ github.workspace }}/${{ env.WORKING_DIR }}/public/en"
./public/en
fail: true
failIfEmpty: false
debug: true
output: ./lychee/out.md
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/resources
public
_vendor
node_modules
.hugo_build.lock
jsconfig.json

# IntelliJ IDEA modules and interim config files
*.iml
.idea/*.xml
.idea/.name
.idea/artifacts
.idea/libraries
.idea/modules
.idea/shelf

!.idea/codeStyles/
!.idea/copyright/

.DS_Store
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions _hugo-site/config/_default/hugo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
baseURL = 'https://example.org/'
languageCode = 'en-us'
title = 'My New Hugo Site'
17 changes: 17 additions & 0 deletions _hugo-site/config/_default/languages.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[en]
languageName = "English"
contentDir = "content/en"
baseURL = "https://example.org/"
weight = 1
[en.params]
languageISO = "EN"
locale = "en_US"

[zh]
languageName = "Chinese"
contentDir = "content/zh"
baseURL = "https://example.org/"
weight = 2
[zh.params]
languageISO = "ZH"
locale = "zh_CN"
10 changes: 10 additions & 0 deletions _hugo-site/content/en/products/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Products
---

## Products

**Links**
* [Products](products/)
* [Product A](products/product-a/)
* [Product B](products/product-b/)
11 changes: 11 additions & 0 deletions _hugo-site/content/en/products/product-a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Product A
---

## Product A

[Internal broken link](products/no-this-internal-product-link/)

```md
https://broken-url
```
7 changes: 7 additions & 0 deletions _hugo-site/content/en/products/product-b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Product B
---

## Product B

[External broken link](https://the-site-not-exists.com)
12 changes: 12 additions & 0 deletions _hugo-site/content/zh/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Homepage
_build:
render: false
---

## The Homepage China

**Links**
* [Products](products/)
* [Product A](products/product-a/)
* [Product B](products/product-b/)
7 changes: 7 additions & 0 deletions _hugo-site/content/zh/products/product-a.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Product A
---

## Product A

[Internal broken link](products/no-this-internal-product-link/)
7 changes: 7 additions & 0 deletions _hugo-site/content/zh/products/product-b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Product B
---

## Product B

[External broken link](https://the-site-not-exists.com)
18 changes: 18 additions & 0 deletions _hugo-site/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en"
itemscope itemtype="https://schema.org/WebPage"
prefix="og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<title>Title</title>

<!-- Not existing favicons. -->
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
</head>
<body>
{{ block "main" . }}{{ end }}
</body>
</html>
3 changes: 3 additions & 0 deletions _hugo-site/layouts/_markup/render-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- $link := .Destination }}
<a href="{{ $link | relURL }}">{{ .Text | safeHTML }}</a>
{{- /* Strip trailing newline. */ -}}
4 changes: 4 additions & 0 deletions _hugo-site/layouts/products/section.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ define "main" }}
<p>Title: {{ .Title }}</p>
{{ .Content }}
{{ end }}
4 changes: 4 additions & 0 deletions _hugo-site/layouts/products/single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{ define "main" }}
<p>Title: {{ .Title }}</p>
{{ .Content }}
{{ end }}
Empty file added _hugo-site/lychee.toml
Empty file.
Loading