Skip to content

Commit c48c3c0

Browse files
authored
[85] Add version name to location hash url (#178)
* Add version name to location hash url * refactor version name with default empty
1 parent 90107f9 commit c48c3c0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/components/LocationProvider/LocationProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export function LocationProvider({ children }: ILocationProviderProps) {
4646
const version =
4747
newParams?.version.substring(0, SHORT_COMMIT_HASH_LENGTH) ||
4848
metadata.versions[metadata.latest]?.hash.substring(0, SHORT_COMMIT_HASH_LENGTH);
49+
const versionName = newParams ? metadata.versions[newParams.version]?.name : undefined;
4950

5051
const stringifiedParams = [];
5152

@@ -58,7 +59,8 @@ export function LocationProvider({ children }: ILocationProviderProps) {
5859
].join("");
5960
}
6061

61-
window.location.hash = `${SEGMENT_SEPARATOR}${stringifiedParams.join(SEGMENT_SEPARATOR)}`;
62+
const newHash = `${SEGMENT_SEPARATOR}${stringifiedParams.join(SEGMENT_SEPARATOR)}`;
63+
window.location.hash = versionName ? `${newHash}?v=${versionName}` : newHash;
6264
},
6365
[metadata],
6466
);

0 commit comments

Comments
 (0)