on master help sign in
Merge pull request #293 from joshavanier/master
79898b9Лu Лinveгa
scripts/wiki.js+7−3
@@ -9,6 +9,8 @@ const Wiki = sites => {
9 const authors = new Set()
9 const authors = new Set()
10 const terms = new Set()
10 const terms = new Set()
11
11
12+ const encodeUrl = text => text.replace(/ /g, '+').trim().toLowerCase()
13+
12 const cleanEntry = entry => {
14 const cleanEntry = entry => {
13 const temp = document.createElement('div')
15 const temp = document.createElement('div')
14 temp.textContent = entry
16 temp.textContent = entry
@@ -63,7 +65,7 @@ const Wiki = sites => {
63 const formatSideBarCat = (key, entries) => (currentHtml, cat) => {
65 const formatSideBarCat = (key, entries) => (currentHtml, cat) => {
64 const catLength = Object.keys(entries[cat]).length
66 const catLength = Object.keys(entries[cat]).length
65 const newHtml = `<li class='${selected(key, cat)}'}'>
67 const newHtml = `<li class='${selected(key, cat)}'}'>
66− <a href='#${cat}' data-msgs='${catLength}'>${cat.toLowerCase()}</a>
68+ <a href='#${encodeUrl(cat)}' data-msgs='${catLength}'>${cat.toLowerCase()}</a>
67 </li>`
69 </li>`
68 return `${currentHtml}${newHtml}`
70 return `${currentHtml}${newHtml}`
69 }
71 }
@@ -162,11 +164,13 @@ const Wiki = sites => {
162 }
164 }
163}
165}
164
166
167+const decodeUrl = text => text.replace(/\+/g, ' ').trim().toUpperCase()
168+
165const stripHash = hash => {
169const stripHash = hash => {
166 const decoded = decodeURIComponent(hash)
170 const decoded = decodeURIComponent(hash)
167− return decoded.charAt(0) === '#' ? decoded.substring(1) : decoded
171+ return decoded.charAt(0) === '#' ? decodeUrl(decoded.substring(1)) : decoded
168}
172}
169
173
170window.addEventListener('hashchange', () => {
174window.addEventListener('hashchange', () => {
171− wiki.refresh(stripHash(window.location.hash).toUpperCase())
175+ wiki.refresh(stripHash(window.location.hash))
172})
176})