Skip to content

Commit

Permalink
Strip protocol off URL under basics
Browse files Browse the repository at this point in the history
  • Loading branch information
aegershman committed May 5, 2022
1 parent b74f826 commit 55e75a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ fs.readdirSync(partialsDir)
Handlebars.registerPartial(path.basename(filename, extname), template),
)

Handlebars.registerHelper('STRIP_PROTOCOL', urlStr => {
const result = urlStr.replace(/(^\w+:|^)\/\//, '');
return result;
})

Handlebars.registerHelper('MONTH_YEAR', dateString =>
// https://dockyard.com/blog/2020/02/14/you-probably-don-t-need-moment-js-anymore
new Date(dateString).toLocaleDateString('en', {
Expand Down
2 changes: 1 addition & 1 deletion partials/basics.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{{#if url}}
<span class='divider'>|</span>
<span class='url'>
<a href='{{url}}'>{{url}}</a>
<a href='{{url}}'>{{STRIP_PROTOCOL url}}</a>
</span>
{{/if}}
{{#location}}
Expand Down

0 comments on commit 55e75a9

Please sign in to comment.