Skip to content

Commit 46d9db7

Browse files
authored
Merge branch 'VR-Rathod:Admin' into Admin
2 parents a81f9ea + 0403b3e commit 46d9db7

31 files changed

Lines changed: 9280 additions & 1560 deletions

.github/workflows/sync-logseq-content.yml

Lines changed: 69 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
name: Sync Logseq → Quartz Content
1+
name: Sync Logseq → Quartz Content & Build
22

33
on:
44
push:
55
branches:
66
- Admin
77
paths:
8-
- "pages/**" # only runs when .md files in pages/ actually change
8+
- "pages/**" # runs when notes in pages/ change
99

1010
workflow_dispatch: # allows manual trigger from GitHub Actions UI
1111

1212
jobs:
13-
sync:
13+
sync-and-build:
1414
runs-on: ubuntu-latest
1515
permissions:
1616
contents: write
@@ -21,6 +21,7 @@ jobs:
2121
with:
2222
ref: Admin
2323
path: logseq-source
24+
fetch-depth: 0
2425

2526
- name: Checkout Web-live branch (Quartz site)
2627
uses: actions/checkout@v4
@@ -35,45 +36,97 @@ jobs:
3536
SOURCE="logseq-source/pages"
3637
DEST="quartz-site/content"
3738
38-
# Count files before
39+
# Count files before sync
3940
before=$(find "$DEST" -name "*.md" ! -name "index.md" | wc -l)
4041
41-
# Remove stale .md files (deleted from Logseq) but keep index.md
42+
# Delete stale notes (keeps index.md intact)
4243
find "$DEST" -name "*.md" ! -name "index.md" -delete
4344
44-
# Copy all .md files from Logseq pages/
45+
# Copy notes from Admin branch to Web-live branch
4546
cp -r "$SOURCE"/. "$DEST"/
4647
47-
# Count files after
48-
after=$(find "../$DEST" -name "*.md" ! -name "index.md" | wc -l)
48+
# Count files after sync
49+
after=$(find "$DEST" -name "*.md" ! -name "index.md" | wc -l)
4950
echo "files_before=$before" >> $GITHUB_OUTPUT
5051
echo "files_after=$after" >> $GITHUB_OUTPUT
5152
52-
- name: Check for changes
53+
- name: Inject Git Timestamps into Frontmatter
54+
run: |
55+
cat << 'EOF' > inject_dates.py
56+
import os
57+
import subprocess
58+
import re
59+
60+
source_dir = 'logseq-source/pages'
61+
dest_dir = 'quartz-site/content'
62+
63+
if not os.path.exists(source_dir):
64+
exit(0)
65+
66+
for filename in os.listdir(source_dir):
67+
if not filename.endswith('.md'):
68+
continue
69+
70+
dest_path = os.path.join(dest_dir, filename)
71+
if not os.path.exists(dest_path):
72+
continue
73+
74+
created_cmd = ['git', 'log', '--diff-filter=A', '--format=%aI', '-1', '--', f"pages/{filename}"]
75+
updated_cmd = ['git', 'log', '-1', '--format=%aI', '--', f"pages/{filename}"]
76+
77+
try:
78+
created = subprocess.run(created_cmd, cwd='logseq-source', capture_output=True, text=True, check=True).stdout.strip()
79+
updated = subprocess.run(updated_cmd, cwd='logseq-source', capture_output=True, text=True, check=True).stdout.strip()
80+
except subprocess.CalledProcessError:
81+
continue
82+
83+
if not created or not updated:
84+
continue
85+
86+
with open(dest_path, 'r', encoding='utf-8') as f:
87+
content = f.read()
88+
89+
inject = ""
90+
if not re.search(r'^date:\s+', content, flags=re.MULTILINE):
91+
inject += f"date: {created}\n"
92+
if not re.search(r'^lastmod:\s+', content, flags=re.MULTILINE):
93+
inject += f"lastmod: {updated}\n"
94+
95+
if inject:
96+
if content.startswith('---'):
97+
content = content.replace('---', f'---\n{inject}', 1)
98+
else:
99+
content = f'---\n{inject}---\n' + content
100+
101+
with open(dest_path, 'w', encoding='utf-8') as f:
102+
f.write(content)
103+
EOF
104+
python3 inject_dates.py
105+
106+
- name: Check for changes in content/
53107
id: changes
54108
run: |
55109
cd quartz-site
56110
git add content/
57111
if git diff --staged --quiet; then
58112
echo "has_changes=false" >> $GITHUB_OUTPUT
59-
echo "No content changes detected — skipping commit."
113+
echo "No changes detected — skipping deploy."
60114
else
61115
changed=$(git diff --staged --name-only | wc -l)
62116
echo "has_changes=true" >> $GITHUB_OUTPUT
63117
echo "changed_count=$changed" >> $GITHUB_OUTPUT
64118
fi
65119
66-
- name: Commit and push to Web-live
120+
- name: Commit and push changes to Web-live
67121
if: steps.changes.outputs.has_changes == 'true'
68122
run: |
69123
cd quartz-site
70124
git config user.name "github-actions[bot]"
71125
git config user.email "github-actions[bot]@users.noreply.github.com"
72-
73-
CHANGED=${{ steps.changes.outputs.changed_count }}
74126
COMMIT_SHA=$(cd ../logseq-source && git rev-parse --short HEAD)
75127
76-
git commit -m "sync: $CHANGED file(s) updated from Logseq (Admin@$COMMIT_SHA)"
128+
git add content/
129+
git commit -m "sync: ${{ steps.changes.outputs.changed_count }} file(s) updated from Logseq (Admin@$COMMIT_SHA)"
77130
git push origin Web-live
78131
79132
- name: Summary
@@ -82,8 +135,8 @@ jobs:
82135
echo "### ✅ Sync complete" >> $GITHUB_STEP_SUMMARY
83136
echo "- **Files before:** ${{ steps.sync.outputs.files_before }}" >> $GITHUB_STEP_SUMMARY
84137
echo "- **Files after:** ${{ steps.sync.outputs.files_after }}" >> $GITHUB_STEP_SUMMARY
85-
echo "- **Changed:** ${{ steps.changes.outputs.changed_count }} file(s)" >> $GITHUB_STEP_SUMMARY
86-
echo "- Vercel will now redeploy automatically." >> $GITHUB_STEP_SUMMARY
138+
echo "- **Changed files:** ${{ steps.changes.outputs.changed_count }}" >> $GITHUB_STEP_SUMMARY
139+
echo "- Content files pushed to **Web-live**. Vercel will build and deploy." >> $GITHUB_STEP_SUMMARY
87140
else
88141
echo "### ⏭️ No changes" >> $GITHUB_STEP_SUMMARY
89142
echo "Content was already up to date — no commit made." >> $GITHUB_STEP_SUMMARY

CONTRIBUTING.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Thank you for contributing! This guide defines the **exact format and structure*
2020
## File Naming Convention
2121

2222
- Use the **exact display name** as the filename: `Kali Linux.md`, `Cpp.md`, `React js.md`
23-
- Use kebab-case only for multi-word algorithmic pages: `binary-search.md`, `dijkstras-algorithm.md`
23+
- Use kebab-case only for multi-word algorithmic pages: `Binary Search.md`, `Dijkstras Algorithm.md`
2424
- Place all pages inside the `/pages/` directory
2525
- Link pages in `index.md` under the correct section using Logseq `[[Page Name]]` syntax
2626

@@ -348,16 +348,7 @@ def example():
348348
### 2. `:::code-note` — Single-Language Focus Block
349349
Use for a **featured snippet** that deserves visual emphasis — a clean, dedicated display for one language.
350350
Perfect for: recursive variants, utility helpers, built-in usage examples.
351-
```
352-
:::code-note
353-
354-
```python
355-
def binary_search(arr, target):
356-
...
357-
```
358351

359-
:::
360-
```
361352

362353
### 3. `:::code-tabs` — Multi-Language Tab View
363354
Use when showing the **same algorithm in multiple languages** side by side as switchable tabs.

0 commit comments

Comments
 (0)