@x-wave/blog 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -152,7 +152,6 @@ export default function App() {
152
152
  <BlogProvider
153
153
  config={{
154
154
  title: 'My Documentation',
155
- siteUrl: 'https://docs.example.com',
156
155
  supportedLanguages: SUPPORTED_LANGUAGES,
157
156
  navigationData: NAVIGATION_DATA,
158
157
  header: {
@@ -213,54 +212,6 @@ export default function App() {
213
212
 
214
213
  This ensures internal navigation (search, tags, language switching) uses the correct base path.
215
214
 
216
- ### Vite config helper (with SSG + basePath)
217
-
218
- The framework exports a reusable Vite config helper so consumers can plug in prerendering without re-implementing build logic.
219
-
220
- ```ts
221
- // vite.config.ts
222
- import { createBlogViteConfig } from '@x-wave/blog/vite'
223
-
224
- export default createBlogViteConfig({
225
- basePath: process.env.VITE_BASE_PATH || '/',
226
- docsDir: 'src/docs',
227
- renderTarget: '#root',
228
- renderAfterTime: 1200,
229
- })
230
- ```
231
-
232
- You can also extend an existing Vite config by passing `baseConfig`:
233
-
234
- ```ts
235
- // vite.config.ts
236
- import { createBlogViteConfig } from '@x-wave/blog/vite'
237
-
238
- export default createBlogViteConfig({
239
- basePath: process.env.VITE_BASE_PATH || '/',
240
- docsDir: 'src/docs',
241
- renderTarget: '#root',
242
- renderAfterTime: 1200,
243
- baseConfig: {
244
- // Your custom Vite config
245
- resolve: { /* ... */ },
246
- server: { /* ... */ },
247
- // etc.
248
- },
249
- })
250
- ```
251
-
252
- Options:
253
-
254
- - `basePath`: Public base path for deployed assets/routes (e.g. `/`, `/docs`, `/multilingual-documentation`)
255
- - `docsDir`: Relative path to language MDX folders (default: `src/docs`)
256
- - `renderTarget`: Selector where prerendered HTML is injected (default: `#root`)
257
- - `renderAfterTime`: Delay in ms before snapshotting pages in Puppeteer
258
- - `additionalPrerenderRoutes`: Extra non-MDX routes to prerender
259
- - `enableTypeChecker`: Enable/disable `vite-plugin-checker`
260
- - `baseConfig`: Optional. Extend the default Vite config with your own settings. The blog config intelligently merges with your base config (plugins, CSS, and optimizeDeps are combined)
261
-
262
- For local preview at root, keep `VITE_BASE_PATH=/` (default). For subpath deploys, set `VITE_BASE_PATH` in your build environment.
263
-
264
215
  ## Writing content
265
216
 
266
217
  ### File naming
@@ -586,7 +537,6 @@ These are the exact functions used by the built-in header, so you get the same f
586
537
  | Property | Type | Required | Description |
587
538
  |---|---|---|---|
588
539
  | `title` | `string` | Yes | Site title displayed in header and sidebar |
589
- | `siteUrl` | `string` | Yes | Full canonical origin used for absolute SEO URLs (e.g., `https://docs.example.com`) |
590
540
  | `supportedLanguages` | `string[]` | Yes | Array of language codes (e.g., `['en', 'es', 'zh']`) |
591
541
  | `navigationData` | `NavigationEntry[]` | Yes | Sidebar navigation structure |
592
542
  | `basePath` | `string` | No | Base path prefix for all routes. Use when mounting docs under a subpath like `/blog` or `/docs`. Default: `''` (root) |
package/consts/index.ts CHANGED
@@ -6,6 +6,4 @@ export const GITHUB_REPO_URL = 'https://github.com/polkadot-cloud'
6
6
 
7
7
  export const STAKING_DASHBOARD_URL = 'https://staking.polkadot.cloud'
8
8
 
9
- export const DEFAULT_SITE_URL = 'https://staking.polkadot.cloud'
10
-
11
9
  export { NAVIGATION_DATA } from './navigation'
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "@x-wave/blog",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
7
7
  "import": "./index.js",
8
8
  "types": "./index.d.ts"
9
9
  },
10
- "./vite": {
11
- "import": "./vite/index.js"
12
- },
13
10
  "./locales": {
14
11
  "import": "./locales/index.js",
15
12
  "types": "./locales/index.d.ts"
package/vite/index.js DELETED
@@ -1,143 +0,0 @@
1
- import fs from 'node:fs'
2
- import { createRequire } from 'node:module'
3
- import path from 'node:path'
4
- import react from '@vitejs/plugin-react-swc'
5
- import { defineConfig } from 'vite'
6
- import checker from 'vite-plugin-checker'
7
- import svgr from 'vite-plugin-svgr'
8
- import tsconfigPaths from 'vite-tsconfig-paths'
9
-
10
- const require = createRequire(import.meta.url)
11
- const vitePrerender = require('vite-plugin-prerender')
12
-
13
- const normalizeBasePath = (basePath) => {
14
- const value = basePath || '/'
15
- if (value === '/') return '/'
16
- const withLeadingSlash = value.startsWith('/') ? value : `/${value}`
17
- return withLeadingSlash.endsWith('/')
18
- ? withLeadingSlash.slice(0, -1)
19
- : withLeadingSlash
20
- }
21
-
22
- const normalizeRoute = (route) => {
23
- if (route === '/') return '/'
24
- const withLeadingSlash = route.startsWith('/') ? route : `/${route}`
25
- return withLeadingSlash.endsWith('/')
26
- ? withLeadingSlash.slice(0, -1)
27
- : withLeadingSlash
28
- }
29
-
30
- const resolvePrerenderRoutes = (docsAbsolutePath, additionalRoutes = []) => {
31
- const routes = new Set(['/'])
32
-
33
- for (const route of additionalRoutes) {
34
- routes.add(normalizeRoute(route))
35
- }
36
-
37
- if (!fs.existsSync(docsAbsolutePath)) {
38
- return Array.from(routes)
39
- }
40
-
41
- const languageDirs = fs
42
- .readdirSync(docsAbsolutePath, { withFileTypes: true })
43
- .filter((entry) => entry.isDirectory())
44
- .map((entry) => entry.name)
45
-
46
- for (const language of languageDirs) {
47
- routes.add(`/${language}`)
48
-
49
- const languageDir = path.join(docsAbsolutePath, language)
50
- const mdxFiles = fs
51
- .readdirSync(languageDir, { withFileTypes: true })
52
- .filter((entry) => entry.isFile() && entry.name.endsWith('.mdx'))
53
-
54
- for (const file of mdxFiles) {
55
- if (file.name.endsWith('-advanced.mdx')) continue
56
- const slug = file.name.replace(/\.mdx$/, '')
57
- routes.add(`/${language}/${slug}`)
58
- }
59
- }
60
-
61
- return Array.from(routes)
62
- }
63
-
64
- export function createBlogViteConfig(options = {}) {
65
- const {
66
- basePath = process.env.VITE_BASE_PATH || '/',
67
- docsDir = 'src/docs',
68
- renderTarget = '#root',
69
- renderAfterTime = 1200,
70
- additionalPrerenderRoutes = [],
71
- enableTypeChecker = true,
72
- baseConfig = {},
73
- } = options
74
-
75
- const base = normalizeBasePath(basePath)
76
- const docsAbsolutePath = path.resolve(process.cwd(), docsDir)
77
- const routes = resolvePrerenderRoutes(
78
- docsAbsolutePath,
79
- additionalPrerenderRoutes,
80
- )
81
-
82
- const plugins = [react(), svgr(), tsconfigPaths()]
83
-
84
- if (enableTypeChecker) {
85
- plugins.push(checker({ typescript: true }))
86
- }
87
-
88
- plugins.push(
89
- vitePrerender({
90
- staticDir: path.join(process.cwd(), 'dist'),
91
- renderTarget,
92
- routes,
93
- renderer: new vitePrerender.PuppeteerRenderer({
94
- renderAfterTime,
95
- }),
96
- }),
97
- )
98
-
99
- const blogConfig = {
100
- base,
101
- plugins,
102
- css: {
103
- preprocessorOptions: {
104
- scss: {
105
- api: 'modern-compiler',
106
- },
107
- },
108
- modules: {
109
- localsConvention: 'camelCase',
110
- },
111
- },
112
- optimizeDeps: {
113
- include: ['react/jsx-runtime'],
114
- },
115
- }
116
-
117
- // Merge with base config
118
- return defineConfig({
119
- ...baseConfig,
120
- ...blogConfig,
121
- plugins: [...(baseConfig.plugins || []), ...plugins],
122
- css: {
123
- ...(baseConfig.css || {}),
124
- ...blogConfig.css,
125
- preprocessorOptions: {
126
- ...(baseConfig.css?.preprocessorOptions || {}),
127
- ...blogConfig.css.preprocessorOptions,
128
- },
129
- modules: {
130
- ...(baseConfig.css?.modules || {}),
131
- ...blogConfig.css.modules,
132
- },
133
- },
134
- optimizeDeps: {
135
- ...(baseConfig.optimizeDeps || {}),
136
- ...blogConfig.optimizeDeps,
137
- include: [
138
- ...(baseConfig.optimizeDeps?.include || []),
139
- ...(blogConfig.optimizeDeps?.include || []),
140
- ],
141
- },
142
- })
143
- }