|
42 | 42 | <option value="prism">Prism</option>
|
43 | 43 | </select>
|
44 | 44 | </div>
|
| 45 | + <p>What is your current Hexo version? <code>hexo -v</code></p> |
| 46 | + <div class="input-group mb-3"> |
| 47 | + <label class="input-group-text" for="version">Version</label> |
| 48 | + <select class="form-select" id="version"> |
| 49 | + <option value="blow-v7.0.0">below v7.0.0</option> |
| 50 | + <option value="v7.0.0+">v7.0.0+</option> |
| 51 | + </select> |
| 52 | + </div> |
45 | 53 | <p>Configuration in Hexo <code>_config.yml</code></p>
|
46 | 54 | <pre class="render hexo"></pre>
|
47 | 55 | <p>And run <code>hexo clean</code></p>
|
|
149 | 157 | constructor() {
|
150 | 158 | ;
|
151 | 159 | }
|
152 |
| - hexo(engine) { |
153 |
| - return `<code class="language-yaml">highlight: |
| 160 | + hexo(engine, version) { |
| 161 | + if (version === 'v7.0.0+') { |
| 162 | + return `<code class="language-yaml">syntax_highlighter: ${engine === 'highlight' ? 'highlightjs' : 'prismjs'} |
| 163 | +highlight: |
| 164 | + ... |
| 165 | +prismjs: |
| 166 | + ...</code>`; |
| 167 | + } else { |
| 168 | + return `<code class="language-yaml">highlight: |
154 | 169 | enable: ${engine === 'highlight'}
|
155 | 170 | ...
|
156 | 171 | prismjs:
|
157 | 172 | enable: ${engine !== 'highlight'}
|
158 | 173 | ...</code>`;
|
| 174 | + } |
159 | 175 | }
|
160 | 176 | next(engine, theme) {
|
161 | 177 | let content;
|
|
212 | 228 | this.code = new Code();
|
213 | 229 | this.element = {
|
214 | 230 | engine: document.getElementById('engine'),
|
| 231 | + version: document.getElementById('version'), |
215 | 232 | theme: document.getElementById('theme'),
|
216 | 233 | language: document.getElementById('language'),
|
217 | 234 | code: document.getElementById('code')
|
218 | 235 | };
|
219 | 236 | this.value = {
|
220 | 237 | engine: localStorage.getItem('engine') || 'highlight',
|
| 238 | + version: localStorage.getItem('version') || 'v7.0.0+', |
221 | 239 | theme: localStorage.getItem('theme') || 'tomorrow',
|
222 | 240 | language: localStorage.getItem('language') || 'rust',
|
223 | 241 | code: localStorage.getItem('code') || CODE
|
|
244 | 262 | if (theme.selectedIndex === -1) theme.selectedIndex = 0;
|
245 | 263 | this.update('theme');
|
246 | 264 | },
|
| 265 | + version: () => {}, |
247 | 266 | theme: () => {
|
248 | 267 | let href = this.element.theme.value;
|
249 | 268 | this.style.getStyle(href);
|
|
272 | 291 | this.render();
|
273 | 292 | }
|
274 | 293 | render() {
|
275 |
| - document.querySelector('.hexo').innerHTML = this.code.hexo(this.value.engine); |
| 294 | + document.querySelector('.hexo').innerHTML = this.code.hexo(this.value.engine, this.value.version); |
276 | 295 | document.querySelector('.next').innerHTML = this.code.next(this.value.engine, this.element.theme[this.value.theme].text);
|
277 | 296 | const preview = document.querySelector('#preview .render code');
|
278 | 297 | preview.className = `language-${this.value.language}`;
|
|
0 commit comments