methanol 0.0.18 → 0.0.19

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
@@ -64,6 +64,10 @@ export default () => ({
64
64
  })
65
65
  ```
66
66
 
67
+ ## Themes
68
+
69
+ Methanol includes built-in themes (`default`, `blog`). Use `--theme <name>` or set `theme: '<name>'` in config. For local themes inside your project, import the theme entry in `methanol.config.*` and pass the theme object/factory.
70
+
67
71
  ## CLI notes
68
72
 
69
73
  - `methanol preview` is an alias for `methanol serve`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "methanol",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Static site generator powered by rEFui and MDX",
5
5
  "main": "./index.js",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "hast-util-is-element": "^3.0.0",
37
37
  "json5": "^2.2.3",
38
38
  "null-prototype-object": "^1.2.5",
39
- "refui": "^0.16.4",
39
+ "refui": "^0.17.1",
40
40
  "refurbish": "^0.1.8",
41
41
  "rehype-slug": "^6.0.0",
42
42
  "rehype-starry-night": "^2.2.0",
@@ -0,0 +1,52 @@
1
+ # Themes
2
+
3
+ Methanol ships with built-in themes under `themes/`.
4
+
5
+ ## Built-in themes
6
+
7
+ - `default`: Documentation-style theme (sidebar + ToC).
8
+ - `blog`: Blog theme (post list, tags/categories UI).
9
+
10
+ ## Using a theme
11
+
12
+ CLI:
13
+
14
+ ```bash
15
+ methanol build --theme blog
16
+ methanol dev --theme default
17
+ ```
18
+
19
+ Config (`methanol.config.*`):
20
+
21
+ ```js
22
+ export default () => ({
23
+ theme: 'blog'
24
+ })
25
+ ```
26
+
27
+ ## Using a local theme (in your project)
28
+
29
+ Theme name resolution only applies when `theme` is a string (built-in or `methanol-theme-xxx` from `node_modules`).
30
+ If your theme lives inside your project, import it and pass the theme object/factory:
31
+
32
+ ```js
33
+ import createTheme from './themes/my-theme/index.js'
34
+
35
+ export default () => ({
36
+ theme: createTheme()
37
+ })
38
+ ```
39
+
40
+ ## Publishing a theme
41
+
42
+ If you publish a theme as an npm package named `methanol-theme-xxx`, users can enable it via `--theme xxx` or `theme: 'xxx'`.
43
+
44
+ ## Theme structure (convention)
45
+
46
+ - `index.js`: entrypoint that exports a theme object or a factory function (recommended).
47
+ - `src/`: theme runtime/template modules (e.g. `src/page.jsx`).
48
+ - `components/`: theme components (used by MDX).
49
+ - `pages/`: theme-provided pages (e.g. `_404.mdx`, `offline.mdx`).
50
+ - `public/`: theme static assets (merged with user `public/`).
51
+ - `sources/`: extra source mappings exposed via `theme.sources`.
52
+
@@ -1,26 +1,46 @@
1
1
  # Blog Theme
2
2
 
3
- A simple, clean blog theme for Methanol.
3
+ A blog theme for Methanol.
4
4
 
5
5
  ## Features
6
- - Clean typography
7
- - Post list on homepage
8
- - Responsive design
9
- - Dark mode support (via system preference)
6
+
7
+ - Post list and post pages
8
+ - Category/collection views (theme-provided client UI)
9
+ - Responsive layout
10
10
 
11
11
  ## Usage
12
12
 
13
- To use this theme, configure your Methanol project to point to this directory.
13
+ CLI:
14
+
15
+ ```bash
16
+ methanol build --theme blog
17
+ methanol dev --theme blog
18
+ ```
19
+
20
+ Config (`methanol.config.*`):
14
21
 
15
22
  ```js
16
- // methanol.config.js
17
- export default {
18
- theme: './themes/blog',
19
- // ...
20
- }
23
+ export default () => ({
24
+ theme: 'blog'
25
+ })
21
26
  ```
22
27
 
23
28
  ## Structure
24
- - `src/page.jsx`: Main layout template.
25
- - `sources/style.css`: Stylesheet.
26
- - `pages/`: Default pages (Home, 404, Offline).
29
+
30
+ - `src/page.jsx`: main layout template
31
+ - `pages/`: theme pages (including special pages like `_404.mdx` and `offline.mdx` when present)
32
+ - `components/`: theme components used by MDX
33
+ - `public/`: theme static assets
34
+ - `sources/`: theme source mappings (used by `theme.sources`)
35
+
36
+ ## Local development
37
+
38
+ If you want to use the theme from a local folder (instead of built-in name / npm package), import it in config:
39
+
40
+ ```js
41
+ import createBlogTheme from './themes/blog/index.js'
42
+
43
+ export default () => ({
44
+ theme: createBlogTheme()
45
+ })
46
+ ```
@@ -0,0 +1,26 @@
1
+ # Default Theme
2
+
3
+ The default Methanol theme is designed for documentation sites (sidebar navigation + table of contents).
4
+
5
+ ## Enable
6
+
7
+ CLI:
8
+
9
+ ```bash
10
+ methanol build --theme default
11
+ methanol dev --theme default
12
+ ```
13
+
14
+ Config:
15
+
16
+ ```js
17
+ export default () => ({
18
+ theme: 'default'
19
+ })
20
+ ```
21
+
22
+ ## Notes
23
+
24
+ - User `public/` assets override theme-provided `public/` assets.
25
+ - Theme pages under `pages/` can provide special routes like `_404.mdx` and `offline.mdx`.
26
+
@@ -75,6 +75,19 @@ export default function () {
75
75
  localStorage.setItem('methanol-theme', theme.value)
76
76
  document.documentElement.classList.toggle('light', theme.value === 'light')
77
77
  document.documentElement.classList.toggle('dark', theme.value === 'dark')
78
+
79
+ const metas = document.querySelectorAll('meta[name="theme-color"]')
80
+ let meta = metas[0]
81
+ if (!meta) {
82
+ meta = document.createElement('meta')
83
+ meta.name = 'theme-color'
84
+ document.head.appendChild(meta)
85
+ }
86
+ for (let i = 1; i < metas.length; i++) {
87
+ metas[i].remove()
88
+ }
89
+ meta.content = theme.value === 'light' ? '#ffffff' : '#09090b'
90
+ meta.removeAttribute('media')
78
91
  }
79
92
 
80
93
  const CurrentIcon = $(() => {
@@ -25,6 +25,19 @@
25
25
  document.documentElement.classList.toggle('light', theme === 'light')
26
26
  document.documentElement.classList.toggle('dark', theme === 'dark')
27
27
 
28
+ const metas = document.querySelectorAll('meta[name="theme-color"]')
29
+ let meta = metas[0]
30
+ if (!meta) {
31
+ meta = document.createElement('meta')
32
+ meta.name = 'theme-color'
33
+ document.head.appendChild(meta)
34
+ }
35
+ for (let i = 1; i < metas.length; i++) {
36
+ metas[i].remove()
37
+ }
38
+ meta.content = theme === 'light' ? '#ffffff' : '#09090b'
39
+ meta.removeAttribute('media')
40
+
28
41
  const savedAccent = localStorage.getItem('methanol-accent')
29
42
  if (savedAccent && savedAccent !== 'default') {
30
43
  document.documentElement.classList.add('accent-' + savedAccent)
@@ -108,6 +108,8 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
108
108
  <head>
109
109
  <meta charset="UTF-8" />
110
110
  <meta name="viewport" content="width=device-width" />
111
+ <meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)" />
112
+ <meta name="theme-color" content="#09090b" media="(prefers-color-scheme: dark)" />
111
113
  <title>
112
114
  {title} | {siteName}
113
115
  </title>