Skip to content

Commit afceeaf

Browse files
committed
docs(site): add dual license, social preview meta, sitemap and robots
Licensing: add the full CC BY-SA 4.0 text for docs content (LICENSE), an MIT license for theme/config/script code (LICENSE-CODE), and document the split in README. Sharing: add an og-image plus per-page canonical, og:url, og:title and og:description generated in transformHead, so shared links resolve to the page itself instead of the site root. Discoverability: enable the built-in sitemap and add robots.txt pointing at it. Repo hygiene: add .gitattributes to keep line endings consistent across platforms.
1 parent 4ea047a commit afceeaf

7 files changed

Lines changed: 501 additions & 1 deletion

File tree

‎.gitattributes‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Normalize line endings so Windows and Linux contributors produce identical diffs.
2+
* text=auto eol=lf
3+
4+
# Binary assets should never be text-normalized.
5+
*.png binary
6+
*.jpg binary
7+
*.jpeg binary
8+
*.gif binary
9+
*.webp binary
10+
*.ico binary
11+
*.woff binary
12+
*.woff2 binary

‎LICENSE‎

Lines changed: 430 additions & 0 deletions
Large diffs are not rendered by default.

‎LICENSE-CODE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023-2026 final
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@ Chinese pages live at the root (`docs/guide/...`); the English mirror lives unde
6868
- Every Chinese page has an English counterpart with the same path under `docs/en/`.
6969
- Screenshots live under `docs/public/images/<section>/` and are shared by both languages.
7070
- Keep the reference address in examples as `https://kuncode.120403.xyz`, but note that it is replaceable.
71-
- Internal links use root-absolute paths with the right locale prefix, e.g. `/guide/errors` and `/en/guide/errors`.
71+
- Internal links use root-absolute paths with the right locale prefix, e.g. `/guide/errors` and `/en/guide/errors`.
72+
73+
## License
74+
75+
Documentation content under `docs/` is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](LICENSE). If you redistribute or adapt it, you must give appropriate credit and share your contributions under the same license.
76+
77+
Code in `docs/.vitepress/`, `scripts/`, and configuration files is licensed under the [MIT License](LICENSE-CODE).

‎docs/.vitepress/config.mts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
// GitHub Pages project sites live at https://<user>.github.io/<repo>/.
88
// The deploy workflow injects BASE_PATH; local dev keeps '/'.
99
const base = process.env.BASE_PATH || '/'
10+
const siteUrl = 'https://120403.xyz/kuncode-docs/'
11+
const ogImageUrl = `${siteUrl}og-image.png`
1012

1113
const zhNav = [
1214
{ text: '开始使用', link: '/guide/' },
@@ -175,9 +177,34 @@ export default defineConfig({
175177
description: '一份面向所有人的 AI 编程工具接入参考,不绑定任何服务。',
176178
cleanUrls: true,
177179
lastUpdated: true,
180+
sitemap: { hostname: siteUrl },
181+
transformHead({ page, title, description, siteData }) {
182+
if (page === '404.md') return []
183+
184+
const cleanPath = page
185+
.replace(/\.md$/, '')
186+
.replace(/(^|\/)index$/, '$1')
187+
.replace(/^\/+/, '')
188+
const pageUrl = new URL(cleanPath, siteUrl).toString()
189+
const siteName = siteData.title ?? ''
190+
191+
return [
192+
['link', { rel: 'canonical', href: pageUrl }],
193+
['meta', { property: 'og:url', content: pageUrl }],
194+
['meta', { property: 'og:site_name', content: siteName }],
195+
['meta', { property: 'og:title', content: title }],
196+
['meta', { property: 'og:description', content: description }],
197+
['meta', { name: 'twitter:title', content: title }],
198+
['meta', { name: 'twitter:description', content: description }],
199+
]
200+
},
178201
head: [
179202
['link', { rel: 'icon', href: base + 'favicon.svg' }],
180203
['meta', { name: 'theme-color', content: '#4f46e5' }],
204+
['meta', { property: 'og:type', content: 'website' }],
205+
['meta', { property: 'og:image', content: ogImageUrl }],
206+
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
207+
['meta', { name: 'twitter:image', content: ogImageUrl }],
181208
],
182209
markdown: {
183210
theme: { light: 'github-light', dark: 'github-dark' },

‎docs/public/og-image.png‎

231 KB
Loading

‎docs/public/robots.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
User-agent: *
2+
Allow: /
3+
4+
Sitemap: https://120403.xyz/kuncode-docs/sitemap.xml

0 commit comments

Comments
 (0)