Skip to content

Commit

Permalink
Fix bash docker (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanistan committed Jul 11, 2023
1 parent 1fd0ece commit 9f2caef
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions frontend/components/DiffBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,39 @@ const props = defineProps({
});
// we grab the file extension and map it to the diff-language
const languageMap = { rs: 'rust', vue: 'html', Dockerfile: 'docker' };
const languageMap = {
rs: 'rust',
vue: 'html',
Dockerfile: 'docker'
};
function basename(str, sep) {
return str.substr(str.lastIndexOf(sep) + 1);
}
function detectedLanguage(path) {
// basename and split on extension...
const base = basename(path, '/');
const pieces = base.split('.');
const ext = pieces[pieces.length - 1];
// if there's an extension go the standard path
if (pieces.length > 1) {
return languageMap[ext] || ext;
}
if (base === 'Dockerfile') {
return 'docker';
}
return 'bash';
}
const language = computed(() => {
const pieces = props.comment.path.split('.');
const lang = pieces[pieces.length - 1];
return `diff-highlight language-diff-${languageMap[lang] || lang}`;
return `diff-highlight language-diff-${detectedLanguage(props.comment.path)}`;
});
</script>

<style type="text/css">
Expand Down

0 comments on commit 9f2caef

Please sign in to comment.