Skip to content

Commit 9f4e59d

Browse files
committed
feat: update metadata links title
1 parent 9ad1f46 commit 9f4e59d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

fields.config.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,36 @@ Registry.addMetadataField('contacts', {
2222
ext: "osc",
2323
});
2424

25+
const formatLink = (type, value, links, jsonName) => {
26+
const link = links.find(link => link.rel === 'related' && link.href.includes(value));
27+
return Helper.toLink(`/#/${type}/${value}/${jsonName}.json`, link.title.split(":")[1], "", "_self");
28+
}
29+
2530
Registry.addMetadataField('osc:project', {
2631
label: "Project",
2732
ext: "osc",
28-
formatter: value => Helper.toLink(`/stac-browser/#/projects/${value}/collection.json`, value, "", "_self")
33+
formatter: (value, field, spec, { links }) => {
34+
return formatLink("projects", value, links, "collection")
35+
}
2936
});
3037

3138
Registry.addMetadataField('osc:themes', {
3239
label: "Themes",
3340
ext: "osc",
34-
formatter: value =>
35-
value.map(theme => Helper.toLink(`/stac-browser/#/themes/${theme}/catalog.json`, theme, "", "_self")).join(", ")
41+
formatter: (value, field, spec, { links }) =>
42+
value.map(theme => formatLink("themes", theme, links, "catalog")).join(", ")
3643
});
3744

3845
Registry.addMetadataField('osc:variables', {
3946
label: "Variables",
4047
ext: "osc",
41-
formatter: value =>
42-
value.map(variable => Helper.toLink(`/stac-browser/#/variables/${variable}/catalog.json`, variable, "", "_self")).join(", ")
48+
formatter: (value, field, spec, { links }) =>
49+
value.map(variable => formatLink("variables", variable, links, "catalog")).join(", ")
4350
});
4451

4552
Registry.addMetadataField('osc:missions', {
4653
label: "Missions",
4754
ext: "osc",
48-
formatter: value =>
49-
value.map(mission => Helper.toLink(`/stac-browser/#/eo-missions/${mission}/catalog.json`, mission, "", "_self")).join(", ")
55+
formatter: (value, field, spec, { links }) =>
56+
value.map(mission => formatLink("eo-missions", mission, links, "catalog")).join(", ")
5057
});

0 commit comments

Comments
 (0)