Skip to content

Commit 61acc53

Browse files
committed
Update documentation assets and enhance SEO; replace logo, adjust navigation links, add sitemap plugin, and create robots.txt
1 parent 74d6419 commit 61acc53

File tree

5 files changed

+159
-7
lines changed

5 files changed

+159
-7
lines changed

docs/.vitepress/config.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,61 @@
11
import { defineConfig } from 'vitepress'
2+
import { sitemapPlugin } from './plugins/sitemap.js'
23

34
export default defineConfig({
45
title: 'Diffyne',
56
description: 'Blazing-fast, server-driven UI framework for PHP powered by a lightweight Virtual DOM + Diff Engine',
67

78
base: '/',
89

9-
// Ignore dead links during build
10-
ignoreDeadLinks: true,
10+
// Plugins
11+
vite: {
12+
plugins: [sitemapPlugin()]
13+
},
1114

1215
head: [
13-
['link', { rel: 'icon', href: '/favicon.ico' }],
14-
['meta', { name: 'theme-color', content: '#3eaf7c' }]
16+
// Favicon
17+
['link', { rel: 'icon', href: '/logo.png', type: 'image/png' }],
18+
['link', { rel: 'apple-touch-icon', href: '/logo.png' }],
19+
20+
// Theme
21+
['meta', { name: 'theme-color', content: '#3eaf7c' }],
22+
23+
// Open Graph / Facebook
24+
['meta', { property: 'og:type', content: 'website' }],
25+
['meta', { property: 'og:url', content: 'https://diffyne.github.io/' }],
26+
['meta', { property: 'og:title', content: 'Diffyne - Server-Driven UI for PHP' }],
27+
['meta', { property: 'og:description', content: 'Blazing-fast, server-driven UI framework for PHP powered by a lightweight Virtual DOM + Diff Engine' }],
28+
['meta', { property: 'og:image', content: 'https://diffyne.github.io/logo.png' }],
29+
['meta', { property: 'og:image:width', content: '1200' }],
30+
['meta', { property: 'og:image:height', content: '630' }],
31+
['meta', { property: 'og:image:alt', content: 'Diffyne Logo' }],
32+
['meta', { property: 'og:site_name', content: 'Diffyne' }],
33+
['meta', { property: 'og:locale', content: 'en_US' }],
34+
35+
// Twitter Card
36+
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
37+
['meta', { name: 'twitter:url', content: 'https://diffyne.github.io/' }],
38+
['meta', { name: 'twitter:title', content: 'Diffyne - Server-Driven UI for PHP' }],
39+
['meta', { name: 'twitter:description', content: 'Blazing-fast, server-driven UI framework for PHP powered by a lightweight Virtual DOM + Diff Engine' }],
40+
['meta', { name: 'twitter:image', content: 'https://diffyne.github.io/logo.png' }],
41+
['meta', { name: 'twitter:image:alt', content: 'Diffyne Logo' }],
42+
['meta', { name: 'twitter:creator', content: '@diffyne' }],
43+
['meta', { name: 'twitter:site', content: '@diffyne' }],
44+
45+
// Additional SEO
46+
['meta', { name: 'author', content: 'Diffyne' }],
47+
['meta', { name: 'keywords', content: 'PHP, Laravel, Server-Driven UI, Virtual DOM, Reactive Components, Livewire Alternative, PHP Framework' }],
48+
['meta', { name: 'robots', content: 'index, follow' }],
49+
['meta', { name: 'language', content: 'English' }],
50+
['meta', { name: 'revisit-after', content: '7 days' }],
51+
52+
// Additional meta
53+
['meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0' }],
54+
['meta', { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' }]
1555
],
1656

1757
themeConfig: {
18-
logo: '/logo.svg',
58+
logo: '/logo.png',
1959

2060
nav: [
2161
{ text: 'Home', link: '/' },

docs/.vitepress/plugins/sitemap.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { writeFileSync, readdirSync, existsSync } from 'fs'
2+
import { join, extname, dirname, resolve } from 'path'
3+
import { fileURLToPath } from 'url'
4+
5+
const __filename = fileURLToPath(import.meta.url)
6+
const __dirname = dirname(__filename)
7+
8+
function getMarkdownFiles(dir, basePath = '') {
9+
const files = []
10+
11+
if (!existsSync(dir)) {
12+
return files
13+
}
14+
15+
const entries = readdirSync(dir, { withFileTypes: true })
16+
17+
for (const entry of entries) {
18+
const fullPath = join(dir, entry.name)
19+
const relativePath = join(basePath, entry.name)
20+
21+
if (entry.isDirectory()) {
22+
if (entry.name !== '.vitepress' && entry.name !== 'node_modules' && entry.name !== 'public') {
23+
files.push(...getMarkdownFiles(fullPath, relativePath))
24+
}
25+
} else if (entry.isFile() && extname(entry.name) === '.md') {
26+
let urlPath = '/' + relativePath.replace(/\.md$/, '').replace(/\\/g, '/')
27+
if (urlPath.endsWith('/index')) {
28+
urlPath = urlPath.replace(/\/index$/, '')
29+
}
30+
if (urlPath.endsWith('/README')) {
31+
urlPath = urlPath.replace(/\/README$/, '')
32+
}
33+
if (urlPath === '/index' || urlPath === '/README') {
34+
urlPath = '/'
35+
}
36+
files.push(urlPath)
37+
}
38+
}
39+
40+
return files
41+
}
42+
43+
export function sitemapPlugin() {
44+
let outDir = ''
45+
let base = '/'
46+
47+
return {
48+
name: 'sitemap-plugin',
49+
configResolved(config) {
50+
const relativeOutDir = config.build.outDir || '.vitepress/dist'
51+
outDir = resolve(process.cwd(), 'docs', relativeOutDir)
52+
base = config.base || '/'
53+
},
54+
closeBundle() {
55+
const baseUrl = 'https://diffyne.github.io'
56+
const lastmod = new Date().toISOString().split('T')[0]
57+
58+
const pages = []
59+
60+
const homeUrl = baseUrl + (base === '/' ? '' : base.replace(/\/$/, ''))
61+
pages.push({
62+
loc: homeUrl || baseUrl,
63+
lastmod,
64+
changefreq: 'daily',
65+
priority: '1.0'
66+
})
67+
68+
const docsDir = join(__dirname, '..', '..')
69+
const markdownFiles = getMarkdownFiles(docsDir)
70+
71+
console.log(`Found ${markdownFiles.length} markdown files in ${docsDir}`)
72+
73+
const uniqueFiles = [...new Set(markdownFiles)].sort()
74+
75+
uniqueFiles.forEach(path => {
76+
if (path === '/' || path === '') return
77+
78+
const fullPath = baseUrl + (base === '/' ? '' : base.replace(/\/$/, '')) + path
79+
const priority = path.startsWith('/getting-started') ? '0.9' :
80+
path.startsWith('/features') ? '0.8' :
81+
path.startsWith('/advanced') ? '0.7' : '0.6'
82+
83+
pages.push({
84+
loc: fullPath,
85+
lastmod,
86+
changefreq: 'weekly',
87+
priority
88+
})
89+
})
90+
91+
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
92+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
93+
${pages.map(page => ` <url>
94+
<loc>${page.loc}</loc>
95+
<lastmod>${page.lastmod}</lastmod>
96+
<changefreq>${page.changefreq}</changefreq>
97+
<priority>${page.priority}</priority>
98+
</url>`).join('\n')}
99+
</urlset>`
100+
101+
const sitemapPath = join(outDir, 'sitemap.xml')
102+
writeFileSync(sitemapPath, sitemap, 'utf-8')
103+
console.log(`✓ Generated sitemap.xml with ${pages.length} pages`)
104+
}
105+
}
106+
}
107+

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ hero:
66
text: Server-Driven UI for PHP
77
tagline: Blazing-fast, reactive components powered by Virtual DOM
88
image:
9-
src: /logo.svg
9+
src: /logo.png
1010
alt: Diffyne
1111
actions:
1212
- theme: brand
1313
text: Get Started
14-
link: /guide/
14+
link: /getting-started/installation
1515
- theme: alt
1616
text: View on GitHub
1717
link: https://github.com/diffyne/diffyne

docs/public/logo.png

75.4 KB
Loading

docs/public/robots.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
User-agent: *
2+
Allow: /
3+
4+
Sitemap: https://diffyne.github.io/sitemap.xml
5+

0 commit comments

Comments
 (0)