Skip to content

Commit

Permalink
Fixed build script to exclude untagged snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo committed Dec 14, 2017
1 parent 06018e1 commit cd4d6ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* [Current URL](#current-url)
* [Element is visible in viewport](#element-is-visible-in-viewport)
* [Get scroll position](#get-scroll-position)
* [Redirect to URL](#redirect-to-url)
* [Redirect to url](#redirect-to-url)
* [Scroll to top](#scroll-to-top)

### Function
Expand Down Expand Up @@ -528,7 +528,17 @@ const getScrollPos = (el = window) =>

[⬆ back to top](#table-of-contents)

undefined
### Redirect to URL

Use `window.location.href` or `window.location.replace()` to redirect to `url`.
Pass a second argument to simulate a link click (`true` - default) or an HTTP redirect (`false`).

```js
const redirect = (url, asLink = true) =>
asLink ? window.location.href = url : window.location.replace(url);
// redirect('https://google.com')
```

[⬆ back to top](#table-of-contents)

### Scroll to top
Expand Down
4 changes: 2 additions & 2 deletions scripts/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ catch (err){

try {
output += `${startPart+'\n'}`;
for(var tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].sort((a,b) => a.localeCompare(b))){
for(var tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].filter(v => v).sort((a,b) => a.localeCompare(b))){
output +=`### ${capitalize(tag, true)}\n`;
for(var taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
output += `* [${taggedSnippet[0][0].toUpperCase() + taggedSnippet[0].replace(/-/g,' ').slice(1)}](#${taggedSnippet[0].replace(/\(/g,'').replace(/\)/g,'').toLowerCase()})\n`
output += '\n';
}
for(var tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].sort((a,b) => a.localeCompare(b))){
for(var tag of [...new Set(Object.entries(tagDbData).map(t => t[1]))].filter(v => v).sort((a,b) => a.localeCompare(b))){
output +=`## ${capitalize(tag, true)}\n`;
for(var taggedSnippet of Object.entries(tagDbData).filter(v => v[1] === tag))
output += `\n${snippets[taggedSnippet[0]+'.md']+'\n[⬆ back to top](#table-of-contents)\n'}`;
Expand Down
2 changes: 1 addition & 1 deletion tag_database
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ powerset:math
promisify:function
random-integer-in-range:utility
random-number-in-range:utility
redirect-to-URL:browser
redirect-to-url:browser
reverse-a-string:string
RGB-to-hexadecimal:utility
run-promises-in-series:function
Expand Down

0 comments on commit cd4d6ba

Please sign in to comment.