diff --git a/conf.py b/conf.py index 75b904c..42e05e5 100644 --- a/conf.py +++ b/conf.py @@ -215,6 +215,7 @@ "embed", "gravatar", "sketchviz", + "notion", ] myst_enable_extensions = [ @@ -433,4 +434,4 @@ "image": "_static/logo/logo.png", } # Ensures og:image meta tag generation which is not always generated by sphinxext.opengraph -ogp_image = "_static/logo/logo.png" \ No newline at end of file +ogp_image = "_static/logo/logo.png" diff --git a/events.md b/events.md index 477737f..85373b3 100644 --- a/events.md +++ b/events.md @@ -9,3 +9,10 @@ list-style: circle excerpts: --- ``` + +```{toctree} +:caption: Secciones +:hidden: true + +talk-brainstorming.md +``` diff --git a/ext/gravatar.py b/ext/gravatar.py index b4241e4..54a89dc 100644 --- a/ext/gravatar.py +++ b/ext/gravatar.py @@ -38,7 +38,7 @@ def run(self): data = {} if klass is not None: - data['classes'] = klass + data["classes"] = klass image = nodes.image(alt=alt, classes=klass, uri=url) return [image] diff --git a/ext/notion.py b/ext/notion.py new file mode 100644 index 0000000..8fbe304 --- /dev/null +++ b/ext/notion.py @@ -0,0 +1,52 @@ +"""A directive to generate an iframe with a Notion page.""" + +import urllib.parse + +from docutils import nodes +from docutils.parsers.rst import Directive +from sphinx.application import Sphinx +from sphinx.util import logging + +logger = logging.getLogger(__name__) + +TEMPLATE: str = """ + +""" + + +class Notion(Directive): + has_content = True + final_argument_whitespace = False + + def run(self): + if not self.content: + raise self.error("Notion directive requires a URL") + if len(self.content) > 1: + raise self.error("Notion directive only accepts a single URL") + url = self.content[0] + # Basic validation that it's a Notion URL + if ( + not url.startswith( + ("https://notion.site", "https://www.notion.so") + ) + and "notion" not in url + ): + raise self.error("URL does not appear to be a valid Notion URL") + + para = nodes.raw( + "", + TEMPLATE.format(url=urllib.parse.quote(url, safe=":/?&=+")), + format="html", + ) + return [para] + + +def setup(app: Sphinx): + app.add_directive("notion", Notion) + + return { + "version": "0.1", + "parallel_read_safe": True, + "parallel_write_safe": True, + } diff --git a/index.md b/index.md index 3e8e282..5b4206b 100644 --- a/index.md +++ b/index.md @@ -79,7 +79,7 @@ Revisa nuestras normas de como integrarte en la comunidad de Python Perú. ``` ```{toctree} -:caption: Secciónes +:caption: Secciones :hidden: true about.md diff --git a/talk-brainstorming.md b/talk-brainstorming.md new file mode 100644 index 0000000..df6cbe4 --- /dev/null +++ b/talk-brainstorming.md @@ -0,0 +1,4 @@ +# Brainstorming de Charlas + +```{notion} https://forested-roadrunner-0a7.notion.site/ebd/1e114afe2a67809c9ff0eb9429b1d3c7?v=1e114afe2a6780d88e41000c2debb2b5 +```