Skip to content

Commit ae5339e

Browse files
committed
chore: update to vuepress 2
1 parent f625348 commit ae5339e

24 files changed

Lines changed: 18366 additions & 22458 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ RELEASE_NOTE*.md
1818

1919
playground/
2020
Makefile
21+
22+
# Vuepress files
23+
.temp
24+
.cache

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

docs/.vuepress/client.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { defineClientConfig } from '@vuepress/client'
2+
import MyLayout from './theme/layouts/Layout.vue'
3+
4+
export default defineClientConfig({
5+
6+
enhance({ router }) {
7+
router.addRoute('/', {
8+
path: '/ads.txt',
9+
redirect: '',
10+
beforeEnter: () => {
11+
window.location.replace('https://cdn4.buysellads.net/ads.txt')
12+
}
13+
})
14+
15+
router.addRoute('/', {
16+
path: '/app-ads.txt',
17+
redirect: '',
18+
beforeEnter: () => {
19+
window.location.replace('https://cdn4.buysellads.net/app-ads.txt')
20+
}
21+
})
22+
}
23+
})

docs/.vuepress/components/Demo/Demo.vue

Lines changed: 119 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,19 @@
6060
</div>
6161
</template>
6262

63-
<script>
63+
<script setup lang="ts">
64+
import 'prismjs/components/prism-json'
65+
import { defineComponent, onMounted, ref, shallowRef } from 'vue'
66+
6467
import Fuse from '../../../../dist/fuse.esm.js'
6568
import Books from './books.js'
6669
6770
import Prism from 'prismjs'
68-
import 'prismjs/components/prism-json'
6971
70-
import { codemirror } from 'vue-codemirror'
71-
import 'codemirror/lib/codemirror.css'
72-
import 'codemirror/mode/javascript/javascript.js'
73-
import 'codemirror/theme/monokai.css'
72+
// import { javascript } from '@codemirror/lang-javascript'
73+
import { javascript } from '@codemirror/lang-javascript'
74+
import { oneDark } from '@codemirror/theme-one-dark'
75+
import { Codemirror } from 'vue-codemirror'
7476
7577
let keys = []
7678
for (const key in Fuse.config) {
@@ -98,114 +100,129 @@ return fuse.search(pattern)`
98100
99101
// Purely here to make two-way binding possible:
100102
// Extend Fuse such that we can expose the pattern that was
101-
// modified direclty in the CodeMirror input.
103+
// modified directly in the CodeMirror input.
102104
class DemoFuse extends Fuse {
103-
constructor(list, options, index) {
104-
super(list, options, index)
105-
}
106-
search(pattern, opts = { limit: false }) {
105+
public override search(pattern: any, opts = { limit: -1 }) {
107106
const results = super.search(pattern, opts)
108107
return { pattern, results }
109108
}
110109
}
111110
112-
export default {
113-
name: 'Demo',
111+
let listJSON = ref(JSON.stringify(Books, null, 2))
112+
let list = ref(Books)
113+
let code = ref(codify(''))
114+
let result = ref('')
115+
let outputHtml = ref('')
116+
let count = ref(0)
117+
let searchTime = ref<string | number>(0)
118+
let listErrorMessage = ref('')
119+
let codeErrorMessage = ref('')
120+
let hasErrors = ref(false)
121+
let pattern = ref('')
122+
let showCode = ref(true)
123+
let listOptions = ref({
124+
tabSize: 2,
125+
mode: 'text/javascript',
126+
theme: 'default',
127+
lineNumbers: true,
128+
line: true
129+
})
130+
let cmOptions = ref({
131+
tabSize: 2,
132+
mode: 'text/javascript',
133+
theme: 'default',
134+
lineNumbers: true,
135+
line: true
136+
})
137+
138+
function toggleCode() {
139+
showCode.value = !showCode.value
140+
}
141+
142+
function onCmCodeChange(newCode) {
143+
code.value = newCode
144+
try {
145+
parse()
146+
update()
147+
} catch (err) {}
148+
}
149+
150+
function onCmListChange(newCode) {
151+
try {
152+
list.value = eval(newCode)
153+
listErrorMessage.value = null
154+
hasErrors.value = !!codeErrorMessage.value
155+
update()
156+
} catch (err) {
157+
listErrorMessage.value = err
158+
hasErrors.value = true
159+
outputHtml.value = ''
160+
throw err
161+
}
162+
}
163+
164+
function parse() {
165+
try {
166+
let func = eval(`[function (Fuse, list){${this.code}}][0]`)
167+
168+
let start = new Date().getTime()
169+
const { pattern, results } = func(DemoFuse, this.list)
170+
result.value = results
171+
pattern.value = pattern
172+
let end = new Date().getTime()
173+
searchTime.value = end - start + ' ms'
174+
codeErrorMessage.value = null
175+
hasErrors.value = !!this.listErrorMessage
176+
} catch (err) {
177+
codeErrorMessage.value = err
178+
hasErrors.value = true
179+
outputHtml.value = ''
180+
throw err
181+
}
182+
}
183+
184+
function update() {
185+
if (hasErrors.value) {
186+
return
187+
}
188+
const html = Prism.highlight(
189+
JSON.stringify(this.result, null, 2),
190+
Prism.languages.json,
191+
'json'
192+
)
193+
count.value = this.result.length
194+
outputHtml.value = html
195+
}
196+
function onPatternKeyUp() {
197+
code.value = codify(this.pattern)
198+
}
199+
200+
onMounted(() => {
201+
parse()
202+
update()
203+
})
204+
205+
defineComponent({
114206
components: {
115-
codemirror
207+
Codemirror
116208
},
117-
data: () => ({
118-
listJSON: JSON.stringify(Books, null, 2),
119-
list: Books,
120-
code: codify(''),
121-
result: '',
122-
outputHtml: '',
123-
count: 0,
124-
searchTime: 0,
125-
listErrorMessage: '',
126-
codeErrorMessage: '',
127-
hasErrors: false,
128-
pattern: '',
129-
showCode: true,
130-
listOptions: {
131-
tabSize: 2,
132-
mode: 'text/javascript',
133-
theme: 'default',
134-
lineNumbers: true,
135-
line: true
136-
},
137-
cmOptions: {
138-
tabSize: 2,
139-
mode: 'text/javascript',
140-
theme: 'default',
141-
lineNumbers: true,
142-
line: true
209+
setup: () => {
210+
const extensions = [javascript(), oneDark]
211+
212+
// Codemirror EditorView instance ref
213+
const view = shallowRef()
214+
const handleReady = (payload) => {
215+
view.value = payload.view
143216
}
144-
}),
145-
methods: {
146-
toggleCode() {
147-
this.showCode = !this.showCode
148-
},
149-
onCmCodeChange(newCode) {
150-
this.code = newCode
151-
try {
152-
this.parse()
153-
this.update()
154-
} catch (err) {}
155-
},
156-
onCmListChange(newCode) {
157-
try {
158-
this.list = eval(newCode)
159-
this.listErrorMessage = null
160-
this.hasErrors = !!this.codeErrorMessage
161-
this.update()
162-
} catch (err) {
163-
this.listErrorMessage = err
164-
this.hasErrors = true
165-
this.outputHtml = ''
166-
throw err
167-
}
168-
},
169-
parse() {
170-
try {
171-
let func = eval(`[function (Fuse, list){${this.code}}][0]`)
172217
173-
let start = new Date().getTime()
174-
const { pattern, results } = func(DemoFuse, this.list)
175-
this.result = results
176-
this.pattern = pattern
177-
let end = new Date().getTime()
178-
this.searchTime = end - start + ' ms'
179-
this.codeErrorMessage = null
180-
this.hasErrors = !!this.listErrorMessage
181-
} catch (err) {
182-
this.codeErrorMessage = err
183-
this.hasErrors = true
184-
this.outputHtml = ''
185-
throw err
186-
}
187-
},
188-
update() {
189-
if (this.hasErrors) {
190-
return
191-
}
192-
const html = Prism.highlight(
193-
JSON.stringify(this.result, null, 2),
194-
Prism.languages.json,
195-
'json'
196-
)
197-
this.count = this.result.length
198-
this.outputHtml = html
199-
},
200-
onPatternKeyUp() {
201-
this.code = codify(this.pattern)
218+
return {
219+
code,
220+
extensions,
221+
handleReady,
222+
log: console.log
202223
}
203-
},
204-
mounted() {
205-
this.parse()
206-
this.update()
207224
}
208-
}
225+
})
209226
</script>
210227

211228
<style lang="css">

docs/.vuepress/components/Donate/Donate.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77
</template>
88

9-
<script>
9+
<script lang="ts">
1010
export default {
1111
name: 'Donate'
1212
}

docs/.vuepress/components/Jobs/Jobs.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
</div>
2323
</template>
2424

25-
<script>
25+
<script lang="ts">
2626
import Fuse from '../../../../dist/fuse.esm.js'
27-
28-
let jobs = require('./jobs.json')
27+
import jobs from './jobs'
2928
3029
export default {
3130
name: 'Jobs',
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[
1+
export default [
22
{
33
"role": "Senior Full Stack Engineer",
44
"company": "RebelMouse",

docs/.vuepress/components/Sponsors/Sponsors.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</div>
1515
</template>
1616

17-
<script>
18-
let sponsors = require('./sponsors.json')
17+
<script lang="ts">
18+
import sponsors from './sponsors'
1919
2020
export default {
2121
name: 'Sponsors',

docs/.vuepress/components/Sponsors/sponsors.json renamed to docs/.vuepress/components/Sponsors/sponsors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[
1+
export default [
22
{
33
"name": "Worksome",
44
"imgUrl": "/assets/img/sponsors/worksome.svg",

0 commit comments

Comments
 (0)