Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Errant404 committed Jun 28, 2024
0 parents commit 5739308
Show file tree
Hide file tree
Showing 25 changed files with 927 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

# Default to bash
defaults:
run:
shell: bash

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: 'latest'
extended: true
- name: Install Dart Sass Embedded
run: sudo snap install dart-sass-embedded
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./public

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Hugo output
public/
resources/
.hugo_build.lock

# Editor
.vscode/

# Mac
.DS_Store
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "themes/hextra"]
path = themes/hextra
url = https://github.com/imfing/hextra.git
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SHUSCT Wiki
5 changes: 5 additions & 0 deletions archetypes/default.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }}
draft = true
+++
73 changes: 73 additions & 0 deletions content/_index.zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: SHUSCT Wiki
layout: hextra-home
---

{{< hextra/hero-badge >}}
<div class="hx-w-2 hx-h-2 hx-rounded-full hx-bg-primary-400"></div>
<span>免费 开源</span>
{{< icon name="arrow-circle-right" attributes="height=14" >}}
{{< /hextra/hero-badge >}}

<div class="hx-mt-6 hx-mb-6">
{{< hextra/hero-headline >}}
创建现代化网站&nbsp;<br class="sm:hx-block hx-hidden" />由 Markdown 和 Hugo 驱动
{{< /hextra/hero-headline >}}
</div>

<div class="hx-mb-12">
{{< hextra/hero-subtitle >}}
极速且全能的 Hugo 主题框架&nbsp;<br class="sm:hx-block hx-hidden" />为构建现代化的静态网站而生
{{< /hextra/hero-subtitle >}}
</div>

<div class="hx-mb-6">
{{< hextra/hero-button text="现在开始" link="docs" >}}
</div>

<div class="hx-mt-6"></div>

{{< hextra/feature-grid >}}
{{< hextra/feature-card
title="快速且功能全面"
subtitle="简单易用,功能强大丰富。"
class="hx-aspect-auto md:hx-aspect-[1.1/1] max-md:hx-min-h-[340px]"
imageClass="hx-top-[40%] hx-left-[24px] hx-w-[180%] sm:hx-w-[110%] dark:hx-opacity-80"
style="background: radial-gradient(ellipse at 50% 80%,rgba(194,97,254,0.15),hsla(0,0%,100%,0));"
>}}
{{< hextra/feature-card
title="Markdown 写作"
subtitle="只需使用 Markdown 进行编辑。多样的 Shortcode 组件开箱即用。"
class="hx-aspect-auto md:hx-aspect-[1.1/1] max-lg:hx-min-h-[340px]"
imageClass="hx-top-[40%] hx-left-[36px] hx-w-[180%] sm:hx-w-[110%] dark:hx-opacity-80"
style="background: radial-gradient(ellipse at 50% 80%,rgba(142,53,74,0.15),hsla(0,0%,100%,0));"
>}}
{{< hextra/feature-card
title="全文搜索"
subtitle="内置 FlexSearch 全文搜索,无需额外设置。"
class="hx-aspect-auto md:hx-aspect-[1.1/1] max-md:hx-min-h-[340px]"
imageClass="hx-top-[40%] hx-left-[36px] hx-w-[110%] sm:hx-w-[110%] dark:hx-opacity-80"
style="background: radial-gradient(ellipse at 50% 80%,rgba(221,210,59,0.15),hsla(0,0%,100%,0));"
>}}
{{< hextra/feature-card
title="轻如羽毛"
subtitle="使用 Hextra 无需依赖 Node.js。由 Hugo 提供支持,Hugo 是最快的静态网站生成器之一,只需一个二进制文件即可在数秒内创建网站。"
>}}
{{< hextra/feature-card
title="响应式布局,暗黑模式"
subtitle="适应不同的屏幕尺寸。内置暗黑模式支持,并根据用户的系统偏好自动切换。"
>}}
{{< hextra/feature-card
title="免费构建和托管"
subtitle="使用 GitHub Actions 进行构建,并在 GitHub Pages 上免费托管。也可以托管在任何静态托管服务上。"
>}}
{{< hextra/feature-card
title="多语言轻松实现"
subtitle="仅需通过在 Markdown 文件后添加语言代码即可创建多语言页面。向您的站点添加 i18n 支持直观易行。"
>}}
{{< hextra/feature-card
title="还有更多..."
icon="sparkles"
subtitle="代码高亮 / 目录 / SEO / RSS / LaTeX 公式 / Mermaid 图标 / 自定义 / 等等..."
>}}
{{< /hextra/feature-grid >}}
20 changes: 20 additions & 0 deletions content/about/index.zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: 关于
toc: false
---

Hextra 是一款简洁、快速、灵活的主题,适用于构建现代化静态站点。Hextra 特别适用于文档网站,但也可用于构建博客、个人网站等各种类型的网站。

Hugo 和 Jekyll 类似,是一个静态网站生成器。但与其他生成器不同,Hugo 只有单个可执行文件,这使得它可以轻松地在各种平台上安装和运行。Hugo 的运行速度非常快且可靠性高,能够在几毫秒内渲染数千页的网站。

Hextra 被设计为轻量级,具有最小化的内存占用。使用 Hextra 无需安装繁杂的依赖,比如 Node.js;相反,你只需要一个简单的 YAML 配置文件和 Markdown 内容。因此,我们可以专注于内容而非在配置环境上浪费精力。

## 鸣谢

Hextra 的设计离不开这些项目的支持和其提供的灵感:

- [Hugo](https://gohugo.io/)
- [Tailwind CSS](https://tailwindcss.com/)
- [Heroicons](https://heroicons.com/)
- [Nextra](https://nextra.vercel.app/)
- [Next.js](https://nextjs.org/)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions content/blog/Connect-to-GitHub-with-SSH-Keys/index.zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: "利用 SSH 密钥链接 GitHub"
---

## 1. 简介

SSH 是一种网络协议, 用于计算机之间的加密登录和数据传输. 一对 SSH 密钥由一个私钥和一个公钥组成, 私钥保存在本地, 公钥保存在远程服务器上.

简单来说: 你将公钥分发给全世界; 他人用你的公钥加密信息, 只有你的私钥才能解密; 你用你的私钥签名信息, 只有你的公钥才能验证.

> 💬 目前有两种主流的算法生成密钥, 一种是 rsa, 另一种是 ed25519. ed25519 是一种 ECC 算法, 比起传统的 rsa 更加安全和高效. 参考资料: [Ed25519: high-speed high-security signatures](http://ed25519.cr.yp.to/) .
本文使用 ed25519 算法生成密钥.

**💡 重点**
- 当你将一对 SSH 密钥绑定到了你的 GitHub 账号后, 你可以在任何电脑上通过私钥访问你的 GitHub 账号.
- 你可以生成额外的密钥, 然后专门利用一对密钥控制一个储存库 (称为 Deploy Key). 该密钥只能访问一个储存库, 而不能访问你的账号.
- SSH 连接 GitHub 通过 443 端口 (而非 22 端口). 由于在国内连接 GitHub 走 22 端口很可能被屏蔽, 因此使用 SSH 连接 GitHub 会更加稳定.


## 2. 生成一对 SSH 密钥

在任意位置打开终端 (**Windows 用户请打开 Git Bash**), 通过以下命令在当前用户的个人文件夹下创建一个叫 `.ssh` 的文件夹 (如果已经创建, 终端会报错说文件夹已存在; 忽视即可):

```bash
mkdir ~/.ssh
```

通过以下命令创建一对 SSH 密钥:

```bash
ssh-keygen -t ed25519 -C "[email protected]" -f ~/.ssh/your-key-name
```

> 💡 **命令解释**
> - `ssh-keygen` 表示生成 ssh 密钥
> - `-t ed25519` 表示使用 ed25519 算法; 如果使用 rsa 算法, 建议输入 `-t rsa -b 4096`, 即生成 4096 bits 的密钥
> - `-C "[email protected]"` 是对该密钥的说明, 引号内的 `[email protected]` 可以替换成任何文字;
> - `-f ~/.ssh/your-key-name` 指出了密钥的生成路径以及密钥的文件名 (可以按需更改), 文件名可以依据自己的需求更改, 但是不要保留后缀名.
输入命令后终端提示设置密钥的密码, 建议设置一个密码.

> 📌 **注意**: 在你输入密码时, 终端的界面上不会显示出白色的输入内容字符 (看起来和没输入一样), 这是对周围环境的防范.
再次输入与刚刚相同的密码, 匹配成功后提示密钥成功生成, 并输出了密钥的指纹和随机图像; 可以忽略这些内容.

> 💡 **检查密钥是否成功生成**: 通过命令 `ls ~/.ssh` 可以查看路径下的所有文件; 你应该至少看到两个文件, 一个是 `your-key-name`, 另一个是 `your-key-name.pub`, 分别对应私钥和公钥.

## 3. 为密钥配置 config 文件

进入路径 `~/.ssh` ; 新建一个文件, 取名为 `config` (**不要保留任何后缀名**); 在文件末尾加入以下内容 (`Identity File` 是你的密钥路径):

```
Host github.com
Hostname ssh.github.com
Port 443
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/your-key-name
TCPKeepAlive yes
IdentitiesOnly yes
```

## 4. 将公钥添加到 GitHub

接着我们要在自己的 GitHub 账号中添加公钥, 这样就可以实现利用私钥访问 GitHub 账号.

在你的电脑上, 复制 `~/.ssh` 路径下 `your-key-name.pub` 文件中的所有内容.

根据 Fig.1:
1. 打开 Github, 登录账号, 点击右上角头像;
2. 点击 `Settings` 按钮进入设置页;
3. 在页面左侧栏中找到 `SSH and GPG keys` , 点击进入;
4. 点击右侧按钮 `New SSH key` 添加一个 ssh 公钥;
5. 为公钥随便取个名字;
6. 在 Key 窗口粘贴前面复制的 `your-key-name.pub` 内的内容;
7. 点击按钮 `Add SSH key`.


![](./add-ssh-key-to-github.png)

<p align="center">
Figure 1. 如何给 GitHub 添加 SSH 公钥
</p>

回到电脑, 任意位置打开终端, 输入以下命令测试和 github 的 ssh 连接:

```
ssh -T [email protected]
```


终端提示输入密码, 输入刚才设置的密码.

**终端提示该密钥还没被授权 (Authenticate), 询问否授权; 输入 `yes` 后再回车**.

接着会有类似于: `Hi jamesnulliu! You've successfully authenticated, but GitHub does not provide shell access.` 的提示.

## 5. 进阶: 为某个储存库添加 Deploy Key

To do ...
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5739308

Please sign in to comment.