canonical / canonicalwebteam.discourse

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

Unexpected render of any topic on discourse #114

Closed anthonydillon closed 2 years ago

anthonydillon commented 2 years ago

A person can create a URL that unexpectedly renders any discourse topic as a doc? For example, https://anbox-cloud.io/docs/t/nvidia-driver-specific-flutter-bug/25269. This should not happen and topics listed in the index should only be rendered as a page.

evildmp commented 2 years ago

In the case of a topic not explicitly listed in the index, I think this should raise a 404 (and not redirect, e.g. to the Discourse topic).

evildmp commented 2 years ago

Regarding the behaviour of the navigation index, can you confirm if these are the expected and implemented (or soon to be implemented) behaviours.

They all seem to work like this on the Charmhub instance at least:

Add an entry without any link to the navigation menu:

| Level | Path                 | Navlink                                   |
| 1     |                      | Some entry in the navigation with no link |

Add an entry, with a link to a documentation source page in this Discourse instance:

| 1     | some-url-fragment    | [Some entry with link](/t/some-link/1234) |

As above, but the page will be rendered at some/url/path:

| 1     | some/url/path        | [Title](/t/another-link/5678)             |

Add an entry to an external resource:

| 1     |                      | [External resource](https://example.com)  |

Allow a Discourse topic to be rendered at another-url-fragment, but don't put it in the navigation (Discourse topics not listed should not be rendered, the subject of this particular issue):

| 1     | another-url-fragment |                                           |
jkfran commented 2 years ago

Add an entry without any link to the navigation menu:

| Level | Path                 | Navlink                                   |
| 1     |                      | Some entry in the navigation with no link |

Add an entry, with a link to a documentation source page in this Discourse instance:

| 1     | some-url-fragment    | [Some entry with link](/t/some-link/1234) |

As above, but the page will be rendered at some/url/path:

| 1     | some/url/path        | [Title](/t/another-link/5678)             |

Add an entry to an external resource:

| 1     |                      | [External resource](https://example.com)  |

I think all of these are totally valid. They should do the expected behaviour.

Allow a Discourse topic to be rendered at another-url-fragment, but don't put it in the navigation (Discourse topics not listed should not be rendered, the subject of this particular issue):

| 1     | another-url-fragment |                                           |

This is not valid and not expected by our parser, you will likely get an error/ignored. There is no topic URL in this example so we don't know what topic you are mapping. Ideally, all the URLs should be part of the navigation, but if you would like to do an exception for some URLs then you need to leave the level column empty:

 |      | another-url-fragment  | [Title](/t/another-link/5678)             |

This was implemented and needed on snapcraft.io: https://forum.snapcraft.io/t/snap-documentation/11127 You can try to use it on other projects, but I am not sure it will work, we will probably need to enable it for other projects.