Skip to content

Commit 251f48f

Browse files
Benanna2019filmaj
authored andcommitted
added suggestions from comments
1 parent 5c2d461 commit 251f48f

File tree

6 files changed

+54
-53
lines changed

6 files changed

+54
-53
lines changed

public/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-env browser */
2-
(function (){
2+
(function () {
33
const activeLink = document.querySelector('a.active')
44
const main = document.getElementById('main')
55
const menuButton = document.getElementById('menu-button')
@@ -11,7 +11,7 @@
1111
if (activeLink)
1212
activeLink.scrollIntoView({
1313
behavior: 'smooth',
14-
block: 'center'
14+
block: 'center',
1515
})
1616

1717
// Toggle sidebar on mobile
@@ -33,23 +33,25 @@
3333
// Copy Markdown button for LLM use
3434
const copyMarkdownBtn = document.getElementById('copy-markdown-btn')
3535
if (copyMarkdownBtn) {
36+
const svgCopy = '<svg><use xlink:href="#copy"></use></svg>'
37+
const svgCheck = '<svg><use xlink:href="#check"></use></svg>'
3638
copyMarkdownBtn.onclick = () => {
3739
const markdown = copyMarkdownBtn.getAttribute('data-markdown')
3840
.replace(/&quot;/g, '"')
3941
.replace(/&lt;/g, '<')
4042
.replace(/&gt;/g, '>')
4143
.replace(/&amp;/g, '&')
42-
const textSpan = document.getElementById('copy-markdown-text')
44+
const iconSpan = copyMarkdownBtn.querySelector('.icon')
4345

4446
navigator.clipboard.writeText(markdown).then(
4547
() => {
46-
textSpan.textContent = 'Copied!'
47-
setTimeout(() => textSpan.textContent = 'Copy for LLM', 2000)
48+
iconSpan.innerHTML = svgCheck
49+
setTimeout(() => iconSpan.innerHTML = svgCopy, 2000)
4850
},
4951
() => {
50-
textSpan.textContent = 'Error!'
51-
setTimeout(() => textSpan.textContent = 'Copy for LLM', 2000)
52-
}
52+
iconSpan.innerHTML = 'Error!'
53+
setTimeout(() => iconSpan.innerHTML = svgCopy, 2000)
54+
},
5355
)
5456
}
5557
}
@@ -89,7 +91,7 @@
8991
target.innerHTML = svgCheck
9092
setTimeout(() => target.innerHTML = svgCopy, 2000)
9193
},
92-
() => target.innerHTML = 'Error copying!'
94+
() => target.innerHTML = 'Error copying!',
9395
)
9496
}
9597

src/http/get-llms_full_txt/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ async function _handler () {
163163
statusCode: 200,
164164
headers: {
165165
'content-type': 'text/plain; charset=utf-8',
166-
'cache-control': 'no-cache, no-store, must-revalidate',
166+
'cache-control': 'max-age=86400',
167167
},
168168
body,
169169
}

src/http/get-llms_txt/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function handler () {
7777
statusCode: 200,
7878
headers: {
7979
'content-type': 'text/plain; charset=utf-8',
80-
'cache-control': 'max-age=3600, s-maxage=3600, stale-while-revalidate=86400',
80+
'cache-control': 'max-age=86400',
8181
},
8282
body: content,
8383
}

src/views/modules/components/copy-markdown.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default function CopyMarkdown (state = {}) {
2020
<span class="icon fill-current">
2121
<svg><use xlink:href="#copy"></use></svg>
2222
</span>
23-
<span id="copy-markdown-text">Copy for LLM</span>
2423
</button>
2524
`
2625
}

test/backend/redirect-map-test.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ test('redirect map middleware', async t => {
1212
http: {
1313
method: 'GET',
1414
path: '/examples',
15-
}
16-
}
15+
},
16+
},
1717
})
1818
const expectedResponse = {
1919
statusCode: 301,
@@ -27,19 +27,19 @@ test('redirect map middleware', async t => {
2727
requestContext: {
2828
http: {
2929
method: 'get',
30-
path: '/unmapped/path'
31-
}
32-
}
30+
path: '/unmapped/path',
31+
},
32+
},
3333
})
3434
assert.ok(!nonRedirectResponse, "Don't respond to unmapped path")
3535

3636
const postResponse = await redirect({
3737
requestContext: {
3838
http: {
3939
method: 'POST',
40-
path: '/examples'
41-
}
42-
}
40+
path: '/examples',
41+
},
42+
},
4343
})
4444
assert.ok(!postResponse, "Don't respond to POST method")
4545
})

test/frontend/sidebar-test.mjs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ function Item (state = {}) {
3131
? Heading3({
3232
children: Anchor({
3333
children: child,
34-
href: slugify(child)
34+
href: slugify(child),
3535
}),
36-
depth
36+
depth,
3737
})
3838
: ''
3939
}
4040
${children}
41-
`
41+
`,
4242
})
4343
}
4444

@@ -69,26 +69,26 @@ const map = {
6969
item: Li,
7070
headings: [
7171
Heading3,
72-
Heading4
73-
]
72+
Heading4,
73+
],
7474
}
7575

7676
test('render object to list', t => {
7777
const map = {
7878
list: Ul,
79-
item: Li
79+
item: Li,
8080
}
8181
const data = {
8282
'one': [
8383
'a',
8484
'b',
85-
'c'
85+
'c',
8686
],
8787
'two': [
8888
'd',
8989
'e',
90-
'f'
91-
]
90+
'f',
91+
],
9292
}
9393
const expected = `
9494
<ul>
@@ -118,25 +118,25 @@ test('render object to list', t => {
118118
test('render nested object to list', t => {
119119
const map = {
120120
list: Ul,
121-
item: Li
121+
item: Li,
122122
}
123123
const data = {
124124
'label': [
125125
{
126126
'one': [
127127
'a',
128128
'b',
129-
'c'
130-
]
129+
'c',
130+
],
131131
},
132132
{
133133
'two': [
134134
'd',
135135
'e',
136-
'f'
137-
]
138-
}
139-
]
136+
'f',
137+
],
138+
},
139+
],
140140
}
141141
const expected = `
142142
<ul>
@@ -177,21 +177,21 @@ test('render deeply nested object to list', t => {
177177
'a': [
178178
'1',
179179
'2',
180-
'3'
181-
]
180+
'3',
181+
],
182182
},
183183
'b',
184-
'c'
185-
]
184+
'c',
185+
],
186186
},
187187
{
188188
'two': [
189189
'd',
190190
'e',
191-
'f'
192-
]
193-
}
194-
]
191+
'f',
192+
],
193+
},
194+
],
195195
}
196196
const expected = `
197197
<ul>
@@ -235,13 +235,13 @@ test('should use custom component map', t => {
235235
'one': [
236236
'a',
237237
'b',
238-
'c'
238+
'c',
239239
],
240240
'two': [
241241
'd',
242242
'e',
243-
'f'
244-
]
243+
'f',
244+
],
245245
}
246246
const expected = `
247247
<ul>
@@ -311,8 +311,8 @@ test('should use custom component map', t => {
311311
data,
312312
map: {
313313
list: Ul,
314-
item: Item
315-
}
314+
item: Item,
315+
},
316316
})
317317
assert.strictEqual(strip(actual), strip(expected), 'Should render object to custom list', actual)
318318
})
@@ -324,19 +324,19 @@ test('Should create correct href', t => {
324324
const href = slugify(path.join('/'))
325325
assert.ok(href, href)
326326
},
327-
list: function list () {}
327+
list: function list () {},
328328
}
329329
const data = {
330330
'one & done': [
331331
'a',
332332
'b',
333-
'c'
333+
'c',
334334
],
335335
'ok "maybe" one or two': [
336336
'd',
337337
'e',
338-
'f'
339-
]
338+
'f',
339+
],
340340
}
341341
listFromObject({ data, map, path })
342342
})

0 commit comments

Comments
 (0)