Skip to content

Commit adae2d8

Browse files
committed
update
1 parent 5f7561e commit adae2d8

File tree

7 files changed

+112
-2
lines changed

7 files changed

+112
-2
lines changed

docs/blog/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Blog

docs/index.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
# Tutorials
1+
# Welcome to MkDocs
2+
3+
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
4+
5+
## Commands
6+
7+
* `mkdocs new [dir-name]` - Create a new project.
8+
* `mkdocs serve` - Start the live-reloading docs server.
9+
* `mkdocs build` - Build the documentation site.
10+
* `mkdocs -h` - Print help message and exit.
11+
12+
## Project layout
13+
14+
mkdocs.yml # The configuration file.
15+
docs/
16+
index.md # The documentation homepage.
17+
... # Other markdown pages, images and other files.

docs/tags.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Tag index
2+
<!-- material/tags -->

ext/__init__.py

Whitespace-only changes.

ext/slugs.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
import re, functools, unicodedata
3+
4+
RE_HTML_TAGS = re.compile(r'</?[^>]*>', re.UNICODE)
5+
RE_INVALID_SLUG_CHAR = re.compile(r'[^\w\- ]', re.UNICODE)
6+
RE_WHITESPACE = re.compile(r'\s', re.UNICODE)
7+
8+
def _make_slug(text, sep, **kwargs):
9+
slug = unicodedata.normalize('NFC', text)
10+
slug = RE_HTML_TAGS.sub('', slug)
11+
slug = RE_INVALID_SLUG_CHAR.sub('', slug)
12+
slug = slug.strip().lower()
13+
slug = RE_WHITESPACE.sub(sep, slug)
14+
return slug
15+
16+
def _make_slug_short(text, sep, **kwargs):
17+
words = _make_slug(text, sep, **kwargs).split(sep)
18+
return sep.join(words[:5])
19+
20+
def slugify(**kwargs):
21+
if 'short' in kwargs and kwargs['short']:
22+
return functools.partial(_make_slug_short, **kwargs)
23+
return functools.partial(_make_slug, **kwargs)

hooks/socialmedia.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from textwrap import dedent
2+
import urllib.parse
3+
import re
4+
5+
x_intent = "https://twitter.com/intent/tweet"
6+
fb_sharer = "https://www.facebook.com/sharer/sharer.php"
7+
include = re.compile(r"blog/[1-9].*")
8+
9+
def on_page_markdown(markdown, **kwargs):
10+
page = kwargs['page']
11+
config = kwargs['config']
12+
if not include.match(page.url):
13+
return markdown
14+
15+
page_url = config.site_url+page.url
16+
page_title = urllib.parse.quote(page.title+'\n')
17+
18+
return markdown + dedent(f"""
19+
[Share on :simple-x:]({x_intent}?text={page_title}&url={page_url}){{ .md-button }}
20+
[Share on :simple-facebook:]({fb_sharer}?u={page_url}){{ .md-button }}
21+
""")

mkdocs.yaml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,51 @@
11
site_name: H2 invent Docs
22
site_url: https://h2-invent.github.io/docs
33
theme:
4-
name: material
4+
name: material
5+
features:
6+
- navigation.indexes
7+
8+
plugins:
9+
- search
10+
- blog:
11+
blog_toc: true
12+
archive_date_format: MMMM yyyy
13+
categories_allowed:
14+
- Holidays
15+
- News
16+
authors_profiles: true
17+
pagination_per_page: 5
18+
archive_pagination_per_page: 10
19+
categories_pagination_per_page: 10
20+
post_slugify: !!python/object/apply:ext.slugs.slugify
21+
kwds:
22+
short: true
23+
- meta
24+
- tags
25+
- rss:
26+
match_path: "blog/posts/.*"
27+
date_from_meta:
28+
as_creation: date.created
29+
as_update: date.updated
30+
31+
extra:
32+
social:
33+
- icon: fontawesome/brands/mastodon
34+
name: squidfunk on Mastodon
35+
link: https://fosstodon.org/@squidfunk
36+
37+
hooks:
38+
- hooks/socialmedia.py
39+
40+
markdown_extensions:
41+
- attr_list
42+
- pymdownx.emoji:
43+
emoji_index: !!python/name:material.extensions.emoji.twemoji
44+
emoji_generator: !!python/name:material.extensions.emoji.to_svg
45+
46+
nav:
47+
- Home: index.md
48+
- Tags: tags.md
49+
- Blog:
50+
- blog/index.md
51+
- blog/tags.md

0 commit comments

Comments
 (0)