canonical / canonicalwebteam.discourse

GNU Lesser General Public License v3.0
11 stars 16 forks source link

[Feature] Configure URL mappings in Python code rather than in Discourse #126

Open bartaz opened 2 years ago

bartaz commented 2 years ago

For Vanilla docs we need the discourse content to be aligned with docs we have in the code. We also don't need the navigation handled and maintained in Discourse.

It would be good if we could configure URL mappings (path to discourse post) in Python rather than having to maintain empty page on discourse just to maintain a "Navigation" table there.

It seems that if we could pass URL mapping directly to discourse module it could also directly fetch the required content without the need to fetch the index topic and parse Navigation out of it.

Some "pseudo-code" suggestion to what I mean:

discourse_docs = Docs(
    parser=DocParser(
        api=DiscourseAPI(
            base_url="https://discourse.ubuntu.com/", session=session
        ),
        # instead of index_topic pass the URL mapping
        # mapping could be full discourse URLs, just paths, or maybe just post IDs
        url_mapping = {
           "pattern/notification": "/t/12345",
           "pattern/code-snippet": "/t/54321",
        },
        url_prefix="/design",
    ),
    document_template="/_layouts/docs_discourse.html",
    url_prefix="/design",
)
anthonydillon commented 2 years ago

To be discussed in the infra guild meeting on the 28th of March.

anthonydillon commented 2 years ago

@carkod what it the property of this issue? It's not triaged without one.