Skip to content

Commit

Permalink
fix(sort): update frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
liblaf committed Mar 25, 2023
1 parent 2643414 commit 85d961b
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ install: $(TARGET) | $(BIN)
pretty:
isort --profile black $(CURDIR)
black $(CURDIR)

poetry run utils.py sort yaml $(DATA)/github.yaml
poetry run utils.py sort yaml $(DATA)/websites.yaml
prettier --write $(CURDIR)/**/*.md
prettier --write $(CURDIR)/**/*.yaml

rename: $(TARGET)
ifneq ($(and $(OS), $(ARCH)), )
Expand Down
4 changes: 4 additions & 0 deletions docs/awesome-github.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
title: Awesome GitHub
category:
- Awesome
tag:
- GitHub
---

## Awesome
Expand Down
4 changes: 4 additions & 0 deletions docs/awesome-websites.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---
title: Awesome Websites
category:
- Awesome
tag:
- Website
---

## C/C++
Expand Down
12 changes: 8 additions & 4 deletions utils/sort/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ def sort_list(data: list) -> list:
try:
result = sorted(result)
except:
try:
result = sorted(result, key=lambda x: x["url"])
except:
pass
if isinstance(result[0], dict):
for key in sorted(result[0].keys()):
try:
result = sorted(result, key=lambda x: x[key])
except:
pass
else:
break
return result
4 changes: 4 additions & 0 deletions utils/sort/github/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FRONTMATTER: str = r"""
---
title: Awesome GitHub
category:
- Awesome
tag:
- GitHub
---
"""

Expand Down
3 changes: 2 additions & 1 deletion utils/sort/github/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import github.Repository

from ...utils import escape_markdown
from .constants import ITEM_TEMPLATE, SECTION_TEMPLATE


def format_item(repo: github.Repository.Repository) -> str:
template = string.Template(ITEM_TEMPLATE)
result = template.substitute(
{
"description": repo.description,
"description": escape_markdown(repo.description),
"full_name": repo.full_name,
"name": repo.name,
"url": repo.url,
Expand Down
4 changes: 4 additions & 0 deletions utils/sort/url/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FRONTMATTER: str = r"""
---
title: Awesome Websites
category:
- Awesome
tag:
- Website
---
"""

Expand Down
2 changes: 1 addition & 1 deletion utils/sort/url/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import urltitle

from ...utils import escape_markdown
from .constants import ITEM_TEMPLATE, SECTION_TEMPLATE
from .utils import escape_markdown


def format_item(url: dict) -> str:
Expand Down
File renamed without changes.

0 comments on commit 85d961b

Please sign in to comment.