Skip to content

Commit

Permalink
feat: trying to load story markdown from stac information
Browse files Browse the repository at this point in the history
  • Loading branch information
santilland committed Jul 24, 2023
1 parent 61c830c commit 9bf0d04
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/src/components/DataPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,12 @@ export default {
'customAreaIndicator',
]),
story() {
let markdown;
// If markdown is coming from stac collection show it direclty
if (this.indicatorObject && 'markdown' in this.indicatorObject) {
return this.$marked(this.indicatorObject.markdown);
}
// If not do previous checks to see if other option can be found
let markdown = '';
try {
const demoItem = this.$route.name === 'demo'
? this.appConfig.demoMode[this.$route.query.event]
Expand Down
12 changes: 12 additions & 0 deletions app/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,18 @@ export async function loadIndicatorData(baseConfig, payload) {
times.sort((a, b) => ((DateTime.fromISO(a) > DateTime.fromISO(b)) ? 1 : -1));
}

// Check for stac story asset
if ('assets' in jsonData) {
if ('story' in jsonData.assets) {
const mdUrl = `${
baseConfig.STACEndpoint.replace('collection.json', '')
}/${jsonData.assets.story.href}`;
indicatorObject.story = mdUrl;
// Now we fetch the markdown info direcly
indicatorObject.markdown = await fetch(mdUrl).then((md) => md.text());
}
}

const features = [];
if (payload.endpointType === 'GeoDB') {
// We create all relevant features (pois) to be shown on map
Expand Down

0 comments on commit 9bf0d04

Please sign in to comment.