Add id= URL query parameter - #3358
Conversation
|
This seems ok.. I'm still kind of wary of considering these NSI keys as stable, but we can try it. You might need to include the disambiguation text too. (I really consider the keys like
Yes this is ok to commit.. We change this pretty infrequently, and it needs to be committed because the site is hosted on a GitHub page. |
| const kv = `${k}/${v}`; | ||
| const entries = data.dict && data.dict[k] && data.dict[k][v]; | ||
| const hash = props.location.hash; | ||
| const slug = id ? id[3] : (hash && hash.slice(1)); // remove leading '#' |
There was a problem hiding this comment.
We need to prefer the hash over the slug in the ID. In fact, when the user clicks one of the “#” links, we should erase that part of the slug in the id parameter.
| const params = parseParams(routeProps.location.search); | ||
| if (params.k && params.v) { | ||
| if ((params.k && params.v) || params.id) { | ||
| return ( |
There was a problem hiding this comment.
What if params are null or undefined?
Can we add a null check for params as well, something like below
let paramObj = params ? params : {}
if ((paramObj.k && paramObj.v) || paramObj.id) {
There was a problem hiding this comment.
ParseParams will not return null or undefined. It returns Array.reduce seeded with an empty Object.
| const k = props.k; | ||
| const v = props.v; | ||
| const id = props.id && props.id.match(/^(\w+?)\/(\w+?)\|(.+)$/); | ||
| const k = id ? id[1] : props.k; |
There was a problem hiding this comment.
Again check if props are not undefined
Added
idas an alternative URL query parameter tokandvthat takes an entry identifier. For example,?id=amenity/fast_food|McDonald'snot only goes to theamenity/fast_foodcategory but also highlights the McDonald’s entry, just as?k=amenity&v=fast_food#McDonald'swould. This unified query parameter would make it possible for a proposed Wikidata external identifier property (#2620) to automatically link to NSI.I considered also filtering on the name part of the identifier, which would be quite nice for discovering internationalized variants of a brand, but I couldn’t figure out how to get the name to show up in the “Tag text” field.
nom run docbuildalso made tons of changes in docs/src.a2b27638.js due to a React version mismatch. I can commit that too if desired, but it’s probably better for someone who’s been building the app lately to take care of that before release.