From 207fda48cee151627d47ecd18d3f9ae50ad9cb10 Mon Sep 17 00:00:00 2001 From: Yusheng Zheng Date: Mon, 21 Oct 2024 21:35:55 +0000 Subject: [PATCH] update --- Makefile | 1 + hooks/socialmedia.py | 21 +++++++++++++++++++++ material/overrides/comments.html | 2 +- mkdocs.yaml | 7 +++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 hooks/socialmedia.py diff --git a/Makefile b/Makefile index a4b3ffa8f..82c668520 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ install: docs/CNAME pip install mkdocs-git-revision-date-localized-plugin pip install mkdocs-git-authors-plugin pip3 install mkdocs-exclude + pip install mkdocs-rss-plugin tutorial: git clone https://github.com/eunomia-bpf/bpf-developer-tutorial tutorial --depth=1 diff --git a/hooks/socialmedia.py b/hooks/socialmedia.py new file mode 100644 index 000000000..3bd74fb82 --- /dev/null +++ b/hooks/socialmedia.py @@ -0,0 +1,21 @@ +from textwrap import dedent +import urllib.parse +import re + +x_intent = "https://x.com/intent/tweet" +fb_sharer = "https://www.facebook.com/sharer/sharer.php" +# include = re.compile(r"blog/[1-9].*") + +def on_page_markdown(markdown, **kwargs): + page = kwargs['page'] + config = kwargs['config'] + # if not include.match(page.url): + # return markdown + + page_url = config.site_url+page.url + page_title = urllib.parse.quote(page.title+'\n') + + return markdown + "\n\n" + dedent(f""" + [Share on :simple-x:]({x_intent}?text={page_title}&url={page_url}){{ .md-button }} + [Share on :simple-facebook:]({fb_sharer}?u={page_url}){{ .md-button }} + """) diff --git a/material/overrides/comments.html b/material/overrides/comments.html index 063b3a5a3..6ddef5be7 100644 --- a/material/overrides/comments.html +++ b/material/overrides/comments.html @@ -1,4 +1,4 @@ -{% if page.meta.comments %} +{% if true %}

{{ lang.t("meta.comments") }}