Skip to content

chore: update site config #2232

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

Merged
merged 1 commit into from
Jan 17, 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
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: deploy

on:
push:
branches:
- main

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

- uses: actions/setup-python@v4
with:
python-version: 3.x

- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt

- run: |
python3 main.py
mkdocs build -f mkdocs.yml
mkdocs build -f mkdocs-en.yml

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
50 changes: 25 additions & 25 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
.idea/
.github/
node_modules/
/solution/CONTEST_README.md
/solution/CONTEST_README_EN.md
/solution/summary.md
/solution/summary_en.md
/solution/README.md
/solution/README_EN.md
/solution/readme_template.md
/solution/readme_template_en.md
/solution/problem_readme_template.md
/solution/problem_readme_template_en.md
/solution/bash_problem_readme_template.md
/solution/bash_problem_readme_template_en.md
/solution/0100-0199/0177.Nth Highest Salary/Solution.sql
/solution/0100-0199/0178.Rank Scores/Solution2.sql
/solution/0500-0599/0586.Customer Placing the Largest Number of Orders/Solution2.sql
/solution/1400-1499/1454.Active Users/Solution.sql
/solution/1600-1699/1635.Hopper Company Queries I/Solution.sql
/solution/2100-2199/2118.Build the Equation/Solution.sql
/solution/2100-2199/2175.The Change in Global Rankings/Solution.sql
/solution/2200-2299/2205.The Number of Users That Are Eligible for Discount/Solution.sql
/solution/2200-2299/2230.The Users That Are Eligible for Discount/Solution.sql
/solution/2200-2299/2252.Dynamic Pivoting of a Table/Solution.sql
/solution/2200-2299/2253.Dynamic Unpivoting of a Table/Solution.sql
.DS_Store
.vscode
.temp
.cache
/node_modules
/solution/result.json
/solution/contest.json
/solution/contest_list.json
/solution/raw.json
/lcof/lcof.json
/lcof/lcof_list.json
/lcci/lcci.json
/solution/__pycache__
/solution/.env
*.iml

site
/docs/lc
/docs/lcof
/docs/lcci
/docs/lcof2
/docs/lcp
/docs/lcs
/docs-en/lc
/docs-en/lcci
19 changes: 12 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@


def get_paths(dirs: str, m: int):
dirs = 'main' + os.sep + dirs
paths = []
for root, _, files in os.walk(dirs):
for file in files:
Expand All @@ -77,12 +76,12 @@ def get_paths(dirs: str, m: int):


dirs_mapping = {
"solution": ("lc", 5),
"lcof": ("lcof", 4),
"lcof2": ("lcof2", 4),
"lcci": ("lcci", 4),
"lcp": ("lcp", 4),
"lcs": ("lcs", 4),
"solution": ("lc", 4),
"lcof": ("lcof", 3),
"lcof2": ("lcof2", 3),
"lcci": ("lcci", 3),
"lcp": ("lcp", 3),
"lcs": ("lcs", 3),
}

dirs = ["solution", "lcof", "lcof2", "lcci", "lcp", "lcs"]
Expand All @@ -102,6 +101,12 @@ def get_paths(dirs: str, m: int):
for p in sorted(get_paths(dir, m)):
with open(p, "r", encoding="utf-8") as f:
content = f.read()

# [中文文档](/lcci/01.01.Is%20Unique/README.md)
# 正则匹配 [中文文档](xxx) 并且移除
content = re.sub(r"\[中文文档]\((.*?)\)", "", content)
content = re.sub(r"\[English Version]\((.*?)\)", "", content)

title = content[content.find("[") + 1 : content.find("]")]
dot = title.find(".") if dir != "lcci" else title.rfind(".")
num = (
Expand Down
9 changes: 6 additions & 3 deletions mkdocs-en.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
INHERIT: mkdocs.yml
site_description: LeetCode solutions in any programming language
site_dir: site/en
docs_dir: docs-en



theme:
language: en
font:
text: Roboto
code: Roboto Mono

nav:
- LeetCode:
Expand Down
5 changes: 2 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ site_name: LeetCode Wiki
site_url: https://doocs.github.io/leetcode
site_description: 多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
site_author: yanglbme
site_dir: site
docs_dir: docs
repo_name: doocs/leetcode
repo_url: https://github.com/doocs/leetcode
Expand Down Expand Up @@ -59,7 +60,7 @@ theme:

plugins:
- search:
separator: '[\s\-,:!=\[\]()"/]+|(?!\b)(?=[A-Z][a-z])|\.(?!\d)|&[lg]t;'
separator: '[\s\u200b\-_,:!=\[\]()"`/]+|\.(?!\d)|&[lg]t;|(?!\b)(?=[A-Z][a-z])'

markdown_extensions:
- pymdownx.superfences
Expand Down Expand Up @@ -91,8 +92,6 @@ extra:
lang: zh




nav:
- LeetCode:
- 1. 两数之和: lc/1.md
Expand Down