Skip to content

Commit

Permalink
firtst commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yejian committed Jul 7, 2023
0 parents commit 9a1c3ff
Show file tree
Hide file tree
Showing 3,351 changed files with 102,881 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
25 changes: 25 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 1000
assignees:
- "Lruihao"
labels:
- "dependencies"
- package-ecosystem: "gitsubmodule" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
open-pull-requests-limit: 1000
assignees:
- "Lruihao"
labels:
- "dependencies"
69 changes: 69 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Hugo build and deploy
on:
push:
branches: [ main ]
paths:
- 'assets/**'
- 'config/**'
- 'content/**'
- 'data/**'
- 'static/**'
- 'themes/**'
workflow_run:
workflows: ['Update theme']
types:
- completed
workflow_dispatch:
jobs:
Actions-Hugo-Deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SYNC_CONTENT }}
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Install
run: npm install
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: latest
extended: true
- name: Build
run: npm run build
- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.GP_DEPLOY_KEY }}
external_repository: Lruihao/lruihao.github.io
publish_branch: main
publish_dir: ./public
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ':rocket: ${{ github.event.head_commit.message }}'
force_orphan: false # once a year
- name: Update Algolia index
env:
ALGOLIA_APP_ID: MTJNHU0JVB
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
ALGOLIA_INDEX_NAME: 'index'
ALGOLIA_INDEX_FILE: './public/index.json'
run: npm run algolia
# - name: Install coscmd
# run: sudo pip install coscmd
# - name: Configure coscmd
# env:
# COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
# COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
# COS_BUCKET_NAME: blog-1256932288
# COS_BUCKET_REGION: ap-chengdu
# run: coscmd config -a $COS_SECRET_ID -s $COS_SECRET_KEY -b $COS_BUCKET_NAME -r $COS_BUCKET_REGION
# - name: Deploy to COS Bucket
# run: coscmd upload -r -s --delete -f public/ /
# - name: Refresh Qcloud CDN cache
# env:
# SECRET_ID: ${{ secrets.COS_SECRET_ID }}
# SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
# run: npm run qcloudcdn
37 changes: 37 additions & 0 deletions .github/workflows/update-theme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update theme

# Controls when the workflow will run
on:
schedule:
# Update theme automatically everyday at 00:00 UTC
- cron: "0 0 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
Update-FixIt:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SYNC_CONTENT }}
submodules: true
fetch-depth: 0

- name: Update theme
run: git submodule update --remote --merge themes/FixIt

- name: Change remote origin
run: |
git remote remove origin
git remote add origin https://github.com/Lruihao/hugo-blog.git
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: ':arrow_up: Chore(theme): update FixIt version'
commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
push_options: '--set-upstream'
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules/
build/
public/
resources/

.hugo_build.lock
jsconfig.json
13 changes: 13 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[submodule "themes/FixIt"]
path = themes/FixIt
url = https://github.com/hugo-fixit/FixIt.git
branch = dev
[submodule "private"]
path = content/private
url = git@github.com:Lruihao/blog-private.git
[submodule "themes/shortcode-mmt-netease"]
path = themes/shortcode-mmt-netease
url = https://github.com/Lruihao/hugo-shortcode-mmt-netease.git
[submodule "themes/shortcode-sponsor-log"]
path = themes/shortcode-sponsor-log
url = https://github.com/Lruihao/hugo-shortcode-sponsor-log.git
18 changes: 18 additions & 0 deletions .scripts/qcloudcdn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Refresh Qcloud CDN cache
* @command `node qcloudcdn.js $SECRET_ID $SECRET_KEY`
*/
const qcloudSDK = require('qcloud-cdn-node-sdk');

// Get the config from https://console.qcloud.com/capi
qcloudSDK.config({
secretId: process?.argv[2],
secretKey: process?.argv[3]
})

qcloudSDK.request('RefreshCdnDir', {
// See https://cloud.tencent.com/document/api/228/3947
'dirs.0': 'https://lruihao.cn/'
}, (res) => {
res.code && console.log(res)
})
10 changes: 10 additions & 0 deletions .shell/auto_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
#author: Lruihao
cd ..
git add .
read -p "Please enter commit message: " commitMsg
if [ -z $commitMsg ];then
commitMsg="Docs: Lruihao's Note update $(date +'%F %a %T')"
fi
git commit -m ":pencil: $commitMsg"
git push
43 changes: 43 additions & 0 deletions .shell/hugo_main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#author: Lruihao
echo "--------------Hugo Admin--------------"
echo "Please enter the serial number to work"
echo "--------------------------------------"
echo "1. post"
echo "2. server"
echo "3. server:production"
echo "4. build"
echo "5. submodule-sync"
echo "6. push"
echo "--------------------------------------"
echo "Press Ctrl+C to stop"

read num
case $num in
1)
sh post_generator.sh
;;
2)
hugo server --disableFastRender --navigateToChanged --source=../ --bind 0.0.0.0
;;
3)
hugo server --disableFastRender --navigateToChanged --environment production --source=../ --bind 0.0.0.0
;;
4)
hugo -v --gc --minify --source=../
;;
5)
sh submodule_sync.sh
;;
6)
sh auto_push.sh
;;
*)
echo "There is no such serial number"
;;
esac

echo "Press any key to continue..."
read x
clear
sh hugo_main.sh
15 changes: 15 additions & 0 deletions .shell/post_generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#author: Lruihao
cd ..
read -p "Please enter the article name: " postName
if [ -z $postName ];then
echo "The article name is required!"
else
read -p "Will there be pictures in this article? [y/n]..." choice
if [ $choice = "y" ];then
hugo new --kind post-bundle posts/$postName
# hugo new posts/$postName/index.md
else
hugo new posts/$postName.md
fi
fi
7 changes: 7 additions & 0 deletions .shell/submodule_sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
echo "Checking for all submodule updates ..."
cd ..
git submodule update --remote --merge
git add themes/FixIt
git commit -m ":arrow_up: Chore(theme): update FixIt version"
git add content/private
git commit -m ":memo: Docs: update private content"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-2023 Lruihao (https://lruihao.cn)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Lruihao Blog (Hugo)

[![Hugo](https://img.shields.io/badge/Hugo-%5E0.109.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/Lruihao/hugo-blog?style=flat)](https://github.com/Lruihao/hugo-blog/blob/main/LICENSE)
[![Hugo build and deploy](https://github.com/Lruihao/hugo-blog/actions/workflows/deploy.yml/badge.svg?branch=main)](https://github.com/Lruihao/hugo-blog/actions/workflows/deploy.yml)
[![GitHub commit activity (main)](https://img.shields.io/github/commit-activity/m/Lruihao/hugo-blog/main?style=flat)](https://github.com/Lruihao/hugo-blog/commits/main)

![blog-flow](/assets/images/blog-flow.png)

> 《菠菜眾長》,这是一个前端程序猿的技术博客, 基于 [Hugo](https://github.com/gohugoio/hugo)[FixIt](https://github.com/Lruihao/FixIt) 主题搭建,主要记录和分享一些 Web 前端开发工作学习中遇到的问题和知识点。
## Directory structure

```bash
▸ .github/ # GitHub configuration
▸ .scripts/ # custom scripts
▸ .shell/ # shell commands for hugo project, entrance: hugo_main.sh
▸ archetypes/ # page archetypes (like scaffolds of archetypes)
▸ assets/ # css, js, third-party libraries etc.
▸ config/ # configuration files
▸ content/ # markdown files for hugo project
▸ private/ # private submodule for encrypted content
▸ data/ # blog data (allow: yaml, json, toml), e.g. friends.yml
▸ public/ # build directory
▸ static/ # static files, e.g. favicon.ico
▸ themes/ # theme submodules
```

## Quick Start

只需根据操作系统(Windows、Linux、macOS)安装最新版本的 [Hugo(>= 0.109.0)](https://gohugo.io/installation/)

```bash
git clone --recursive git@github.com:Lruihao/hugo-blog.git
```

有两种方法可以启动这个博客。

### NPM

```bash
npm install
# build the blog
npm run build
# run a local debugging server with watch
npm run server
# run a local debugging server in production environment
npm run server:production
# update theme submodules
npm run update:theme
```

---

如果没有全局安装 Hugo,甚至可以通过 `npm install hugo-bin --save-dev` 来安装一个 Hugo 的包装器。

`package.json` 需配置 `extended` 版本:

```json
{
...
"hugo-bin": {
"buildTags": "extended"
}
}
```

再通过 `npx hugo` 启动。

### Hugo

```bash
# Development environment
hugo server --disableFastRender --navigateToChanged --bind 0.0.0.0
# Production environment
hugo server --disableFastRender --navigateToChanged --environment production --bind 0.0.0.0
```

此外,还可以运行 `hugo_main.sh` 来选择常用的 Hugo 命令:

```bash
cd .shell && sh hugo_main.sh
```

```text
--------------Hugo Admin--------------
Please enter the serial number to work
--------------------------------------
1. post
2. server
3. server:production
4. build
5. submodule-sync
6. push
--------------------------------------
Press Ctrl+C to stop
```

## 作者

[Lruihao](https://github.com/Lruihao "在 GitHub 上关注我")
8 changes: 8 additions & 0 deletions archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: {{ replace .TranslationBaseName "-" " " | title }}
subtitle:
date: {{ .Date }}
description:
keywords:
draft: true
---

0 comments on commit 9a1c3ff

Please sign in to comment.