mirror of
https://github.com/fmhy/edit.git
synced 2026-03-11 08:55:38 +00:00
fix: properly index <h2> sections
ref: https://github.com/wotakumoe/wotaku/pull/86
This commit is contained in:
parent
84ae282b2b
commit
d6b9979464
10 changed files with 49 additions and 68 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
|
@ -198,7 +198,7 @@ TODO text
|
|||
*.tmpl text
|
||||
*.tpl text
|
||||
*.twig text
|
||||
*.vue text
|
||||
*.vue text diff=vue
|
||||
|
||||
# Configs
|
||||
*.cnf text
|
||||
|
|
|
|||
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
|
|
@ -100,7 +100,7 @@ #### Manually
|
|||
|
||||
1. Fork the repository by clicking the "Fork" button in the top right corner.
|
||||
|
||||
2. Make sure you have [Node.js](https://nodejs.org/en/), [pnpm](https://pnpm.io/), [git](https://git-scm.com/), and [VSCode](https://code.visualstudio.com/) or any other editor installed.
|
||||
2. Make sure you have [Node.js](https://nodejs.org/en/), [pnpm](https://pnpm.io/), [git](https://git-scm.com/), and [VSCode](https://code.visualstudio.com/) or any other editor installed. Alternatively, `pnpm` has `pnpm env` you can use to manage Node.
|
||||
|
||||
3. Clone your forked repository to your local machine.
|
||||
|
||||
|
|
|
|||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
1
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -1 +0,0 @@
|
|||
|
||||
1
.github/POST_TEMPLATE.md
vendored
1
.github/POST_TEMPLATE.md
vendored
|
|
@ -20,7 +20,6 @@ ### Post Template
|
|||
description: Month 20YY updates
|
||||
date: 20YY-MM-DD
|
||||
next: false
|
||||
aside: left
|
||||
prev: false
|
||||
sidebar: false
|
||||
footer: true
|
||||
|
|
|
|||
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
|
@ -1,23 +0,0 @@
|
|||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
## Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Context
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
## Types of changes
|
||||
<!--- What types of changes does your Pull Request introduce? Put an `x` in all the boxes that apply: -->
|
||||
- [ ] Bad / Deleted sites removal
|
||||
- [ ] Grammar / Markdown fixes
|
||||
- [ ] Content addition (sites, projects, tools, etc.)
|
||||
- [ ] New Wiki section
|
||||
- [ ] Section Improvement
|
||||
|
||||
## Checklist:
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply to this Pull Request. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
- [ ] I have read the [contribution guide](https://fmhy.net/other/contributing).
|
||||
- [ ] I have made sure to [search](https://api.fmhy.net/single-page) before making any changes.
|
||||
- [ ] My code follows the code style of this project.
|
||||
9
.github/labeler.yml
vendored
9
.github/labeler.yml
vendored
|
|
@ -1,9 +0,0 @@
|
|||
# See https://github.com/actions/labeler
|
||||
|
||||
docs:
|
||||
- 'docs/**/*.md'
|
||||
|
||||
core:
|
||||
- 'api/**'
|
||||
- '.github/**'
|
||||
- 'docs/.vitepress/**'
|
||||
17
.github/workflows/labeler.yml
vendored
17
.github/workflows/labeler.yml
vendored
|
|
@ -1,17 +0,0 @@
|
|||
name: 'Pull Request Housekeeping'
|
||||
|
||||
on: [pull_request_target]
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Label PRs
|
||||
uses: actions/labeler@v4
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) taskylizard. All rights reserved.
|
||||
* Copyright (c) 2024 taskylizard
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -13,20 +13,53 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { MarkdownRenderer } from 'vitepress'
|
||||
import { headers } from '../transformer/constants'
|
||||
|
||||
const titles = Object.keys(headers).map((key) => headers[key].title)
|
||||
const excluded = ['Credits']
|
||||
|
||||
export const headersPlugin = (md: MarkdownRenderer) => {
|
||||
// Add the Feedback component after the heading and close the container
|
||||
md.renderer.rules.heading_close = (tokens, idx, options, env, self) => {
|
||||
const result = self.renderToken(tokens, idx, options)
|
||||
const heading = tokens[idx - 1]
|
||||
const level = tokens[idx].tag.slice(1)
|
||||
if (!titles.includes(env.frontmatter.title) || level !== '2') return result
|
||||
// Add the Feedback component in the heading, before the link.
|
||||
//
|
||||
// Adding it after the link is closed prevents vitepress from properly
|
||||
// indexing the file's content.
|
||||
|
||||
return `<Feedback heading="${heading.content}" />${result}`
|
||||
md.renderer.rules.heading_open = (tokens, idx, options, env, self) => {
|
||||
const result = self.renderToken(tokens, idx, options)
|
||||
|
||||
const idxClose =
|
||||
idx +
|
||||
tokens.slice(idx).findIndex((token) => token.type === 'heading_close')
|
||||
if (idxClose <= idx) return result
|
||||
|
||||
const level = tokens[idx].tag.slice(1)
|
||||
if (excluded.includes(env.frontmatter.title) || level !== '2') return result
|
||||
|
||||
// Find the token for the link.
|
||||
//
|
||||
// The token after `heading_open` contains the link as a child token.
|
||||
const children = tokens[idx + 1].children || []
|
||||
const linkOpenToken = children.find((c) => c.type === 'link_open')
|
||||
if (!linkOpenToken) return result
|
||||
|
||||
const heading = tokens[idxClose - 1]
|
||||
|
||||
linkOpenToken.meta = linkOpenToken.meta || {}
|
||||
linkOpenToken.meta.feedback = {
|
||||
heading: heading.content
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
|
||||
const result = self.renderToken(tokens, idx, options)
|
||||
|
||||
const meta = tokens[idx].meta
|
||||
if (!meta || !meta.feedback) return result
|
||||
|
||||
const heading = meta.feedback.heading || ''
|
||||
if (!heading) return result
|
||||
|
||||
return `<Feedback heading="${heading}" />${result}`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
"docs:dev": "vitepress dev docs/",
|
||||
"docs:preview": "vitepress preview docs/",
|
||||
"format": "prettier -w --cache --check .",
|
||||
"postinstall": "nitropack prepare",
|
||||
"lint": "biome lint .",
|
||||
"lint:fix": "biome lint . --write",
|
||||
"lint:fix:unsafe": "biome lint . --write --unsafe",
|
||||
|
|
@ -33,15 +32,15 @@
|
|||
"nitro-cors": "^0.7.1",
|
||||
"nitropack": "^2.10.4",
|
||||
"nprogress": "^0.2.0",
|
||||
"pathe": "^1.1.2",
|
||||
"unocss": "^0.63.4",
|
||||
"pathe": "^2.0.1",
|
||||
"unocss": "65.4.0",
|
||||
"vitepress": "^1.5.0",
|
||||
"vue": "^3.5.12",
|
||||
"x-satori": "^0.2.0",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.9.3",
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@cloudflare/workers-types": "^4.20241230.0",
|
||||
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
|
||||
"@iconify-json/carbon": "^1.2.3",
|
||||
|
|
|
|||
BIN
pnpm-lock.yaml
BIN
pnpm-lock.yaml
Binary file not shown.
Loading…
Reference in a new issue