Skip to content

Commit

Permalink
fix(compat): remove use of array.at
Browse files Browse the repository at this point in the history
Co-authored-by: Divyansh Singh <[email protected]>
  • Loading branch information
gittig11 and brc-dd authored Feb 22, 2023
1 parent 191ac86 commit fd99590
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export default defineConfig({
function nav() {
return [
{ text: 'Guide', link: '/guide/what-is-vitepress', activeMatch: '/guide/' },
{ text: 'Config Reference', link: '/config/introduction', activeMatch: '/config/' },
{
text: 'Config Reference',
link: '/config/introduction',
activeMatch: '/config/'
},
{
text: pkg.version,
items: [
Expand Down
3 changes: 2 additions & 1 deletion src/node/markdown/plugins/lineNumbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export const lineNumberPlugin = (md: MarkdownIt, enable = false) => {

const lineNumbersCode = [
...Array(
lines.length - (lines.at(-1) === `<span class="line"></span>` ? 1 : 0)
lines.length -

This comment has been minimized.

Copy link
@jd-solanki

jd-solanki Feb 27, 2023

Contributor

I'm curious, why we removed the usage of at method?

This comment has been minimized.

Copy link
@brc-dd

This comment has been minimized.

Copy link
@jd-solanki

jd-solanki Feb 27, 2023

Contributor

oh, Thanks for pointing that out 👍🏻

(lines[lines.length - 1] === `<span class="line"></span>` ? 1 : 0)
)
]
.map((_, index) => `<span class="line-number">${index + 1}</span><br>`)
Expand Down
2 changes: 1 addition & 1 deletion src/node/markdown/plugins/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const snippetPlugin = (md: MarkdownIt, srcDir: string) => {
rawTitle = ''
] = (rawPathRegexp.exec(rawPath) || []).slice(1)

const title = rawTitle || filename.split('/').at(-1) || ''
const title = rawTitle || filename.split('/').pop() || ''

state.line = startLine + 1

Expand Down

0 comments on commit fd99590

Please sign in to comment.