Skip to content
Merged

d2m #1427

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 28 additions & 34 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,6 @@ export default defineConfig({
'link',
{ rel: 'alternate', type: 'application/rss+xml', href: '/blog.rss' }
],
['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }],
[
'link',
{
rel: 'preconnect',
href: 'https://fonts.gstatic.com',
crossorigin: 'true'
}
],
[
'link',
{
rel: 'preload',
href: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Manrope:wght@600&family=IBM+Plex+Mono:wght@400&display=swap',
as: 'style'
}
],
[
'link',
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Manrope:wght@600&family=IBM+Plex+Mono:wght@400&display=swap'
}
],
inlineScript('banner.js'),
['link', { rel: 'me', href: 'https://m.webtoo.ls/@vite' }],
['meta', { property: 'og:type', content: 'website' }],
Expand Down Expand Up @@ -449,16 +425,34 @@ export default defineConfig({
]
}
},
transformPageData(pageData) {
const canonicalUrl = `${ogUrl}/${pageData.relativePath}`
.replace(/\/index\.md$/, '/')
.replace(/\.md$/, '')
pageData.frontmatter.head ??= []
pageData.frontmatter.head.unshift(
['link', { rel: 'canonical', href: canonicalUrl }],
['meta', { property: 'og:title', content: pageData.title }]
)
return pageData
transformHead(ctx) {
const path = ctx.page.replace(/(^|\/)index\.md$/, '$1').replace(/\.md$/, '')

if (path !== '404') {
const canonicalUrl = path ? `${ogUrl}/${path}` : ogUrl
ctx.head.push(
['link', { rel: 'canonical', href: canonicalUrl }],
['meta', { property: 'og:title', content: ctx.pageData.title }],
)
}

// For the landing page, move the google font links to the top for better performance
if (path === '') {
const googleFontLinks: HeadConfig[] = []
for (let i = 0; i < ctx.head.length; i++) {
const tag = ctx.head[i]
if (
tag[0] === 'link' &&
(tag[1]?.href?.includes('fonts.googleapis.com') ||
tag[1]?.href?.includes('fonts.gstatic.com'))
) {
ctx.head.splice(i, 1)
googleFontLinks.push(tag)
i--
}
}
ctx.head.unshift(...googleFontLinks)
}
},
markdown: {
// languages used for twoslash and jsdocs in twoslash
Expand Down
2 changes: 1 addition & 1 deletion guide/rolldown.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Rolldown 专注于三个主要原则:

```json
{
"dependencies": {
"devDependencies": {
"vite": "^7.0.0" // [!code --]
"vite": "npm:rolldown-vite@latest" // [!code ++]
}
Expand Down
16 changes: 16 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ layout: home
aside: false
editLink: false
markdownStyles: false

head:
- - link
- rel: preconnect
href: https://fonts.googleapis.com
- - link
- rel: preconnect
href: https://fonts.gstatic.com
crossorigin: ''
- - link
- rel: preload
href: https://fonts.googleapis.com/css2?family=Manrope:wght@600&family=IBM+Plex+Mono:wght@400&display=swap
as: style
- - link
- rel: stylesheet
href: https://fonts.googleapis.com/css2?family=Manrope:wght@600&family=IBM+Plex+Mono:wght@400&display=swap
---

<script setup>
Expand Down