Skip to content

Commit e8d600b

Browse files
authored
feat(website): add myfy website (#12)
1 parent 3abc7a8 commit e8d600b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+5603
-28
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
run: uv sync --all-extras
3131

3232
- name: Run Ruff linter
33-
run: uv run ruff check packages/ examples/
33+
run: uv run ruff check packages/ website/ examples/
3434

3535
- name: Check Ruff formatting
36-
run: uv run ruff format --check packages/ examples/
36+
run: uv run ruff format --check packages/ website/ examples/
3737

3838
typecheck:
3939
name: Type Check with ty
@@ -57,7 +57,7 @@ jobs:
5757
run: uv sync --all-extras
5858

5959
- name: Run ty type checker
60-
run: uv run ty check packages/ --exclude '**/stubs/**'
60+
run: uv run ty check packages/ website/ --exclude '**/stubs/**'
6161

6262
test:
6363
name: Test on Python ${{ matrix.python-version }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ wheels/
1212
# myfy CLI generated files
1313
_myfy_server.py
1414
site/
15+
16+
.DS_Store
17+
**/node_modules

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Be respectful and inclusive. We're here to build great software together.
2020
## Getting Started
2121

2222
1. Fork the repository
23-
2. Clone your fork: `git clone https://github.com/YOUR-USERNAME/myfy.git`
24-
3. Add upstream remote: `git remote add upstream https://github.com/ORIGINAL-OWNER/myfy.git`
23+
2. Clone your fork: `git clone https://github.com/psincraian/myfy.git`
24+
3. Add upstream remote: `git remote add upstream https://github.com/psincraian/myfy.git`
2525
4. Create a feature branch: `git checkout -b feat/my-feature`
2626

2727
## Development Setup

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,6 @@ Use admonitions for important notes:
127127

128128
## Links
129129

130-
- [Live Documentation](https://psincraian.github.io/myfy/)
130+
- [Live Documentation](https://myfy.dev)
131131
- [MkDocs Documentation](https://www.mkdocs.org/)
132132
- [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/)

mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
site_name: myfy
22
site_description: Opinionated Python framework with modularity, ergonomics, and power
3-
site_url: https://psincraian.github.io/myfy # Update with your GitHub username
4-
repo_url: https://github.com/psincraian/myfy # Update with your repo URL
3+
site_url: https://myfy.dev
4+
repo_url: https://github.com/psincraian/myfy
55
repo_name: myfy
66
edit_uri: edit/main/docs/
77

packages/myfy-frontend/myfy/frontend/assets.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, static_dir: str, settings: FrontendSettings):
2626
self.manifest_path = self.static_dir / "dist" / ".vite" / "manifest.json"
2727

2828
@lru_cache(maxsize=1) # noqa: B019
29-
def load_manifest(self) -> dict:
29+
def load_manifest(self) -> dict[str, str]:
3030
"""Load Vite manifest (cached in production)."""
3131
if self.manifest_path.exists():
3232
with self.manifest_path.open() as f:
@@ -43,7 +43,10 @@ def is_development(self) -> bool:
4343

4444
def get_asset_url(self, entry_name: str) -> str | None:
4545
"""
46-
Get asset URL for entry (main, theme-switcher, etc).
46+
Get asset URL for entry (main, theme-switcher, prism-init, etc).
47+
48+
Dynamically discovers entries from manifest.json (production) or
49+
constructs paths for Vite dev server (development).
4750
4851
Args:
4952
entry_name: Entry name from vite.config.js
@@ -52,25 +55,20 @@ def get_asset_url(self, entry_name: str) -> str | None:
5255
Asset URL (dev server or production URL with hash)
5356
"""
5457
if self.is_development() and self.settings.enable_vite_dev:
55-
# Development: proxy to Vite server
56-
entry_map = {
57-
"main": "frontend/js/main.js",
58-
"theme-switcher": "frontend/js/theme-switcher.js",
59-
}
60-
path = entry_map.get(entry_name)
61-
if path:
62-
return f"{self.settings.vite_dev_server}/{path}"
63-
else:
64-
# Production: use manifest
65-
manifest = self.load_manifest()
66-
entry_map = {
67-
"main": "frontend/js/main.js",
68-
"theme-switcher": "frontend/js/theme-switcher.js",
69-
}
70-
input_path = entry_map.get(entry_name)
71-
if input_path and input_path in manifest:
72-
file_path = manifest[input_path]["file"]
58+
# Development: construct path dynamically for Vite dev server
59+
path = f"frontend/js/{entry_name}.js"
60+
return f"{self.settings.vite_dev_server}/{path}"
61+
62+
# Production: dynamically search manifest for matching entry
63+
manifest = self.load_manifest()
64+
65+
# Look for entry by name in manifest
66+
for entry_data in manifest.values():
67+
# Check if this is an entry point with matching name
68+
if entry_data.get("isEntry") and entry_data.get("name") == entry_name:
69+
file_path = entry_data["file"]
7370
return f"{self.settings.static_url_prefix}/{file_path}"
71+
7472
return None
7573

7674
def get_css_url(self, entry_name: str) -> str | None:

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ members = [
1515
"packages/myfy-cli",
1616
"packages/myfy-frontend",
1717
"packages/myfy",
18+
"website",
1819
]
1920

2021
[tool.uv.sources]
@@ -23,6 +24,7 @@ myfy-web = { workspace = true }
2324
myfy = { workspace = true }
2425
myfy-frontend = { workspace = true }
2526
myfy-cli = { workspace = true, editable = true }
27+
myfy-website = { workspace = true }
2628

2729
[dependency-groups]
2830
dev = [

0 commit comments

Comments
 (0)