mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/JiboViteDocs.git
synced 2026-06-17 01:17:00 +00:00
Initalize
This commit is contained in:
29
node_modules/@lando/vitepress-theme-default-plus/vite/add-layout-components-plugin.js
generated
vendored
Normal file
29
node_modules/@lando/vitepress-theme-default-plus/vite/add-layout-components-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import Debug from 'debug';
|
||||
import {EOL} from 'node:os';
|
||||
|
||||
const pivot = 'export default function(app) {';
|
||||
|
||||
export default function(layouts = [], {debug = Debug('@lando/vite-plugin')}) { // eslint-disable-line
|
||||
return {
|
||||
name: 'inject-layouts',
|
||||
enforce: 'pre',
|
||||
transform: (code, id) => {
|
||||
const layoutfile = 'enhance-app-with-layouts.js';
|
||||
if (id.includes(layoutfile) && layouts.length > 0) {
|
||||
// get lines and pindex
|
||||
const lines = code.split(EOL);
|
||||
// get pivot line
|
||||
let pindex = lines.findIndex(line => line.startsWith(pivot));
|
||||
// loop through and add imports
|
||||
for (const layout of layouts.reverse()) lines.splice(pindex, 0, layout.import);
|
||||
// get pivot again
|
||||
pindex = lines.findIndex(line => line.startsWith(pivot)) + 1;
|
||||
// loop through again and add components
|
||||
for (const layout of layouts.reverse()) lines.splice(pindex, 0, layout.add);
|
||||
// debug
|
||||
debug('autogenerated layout import file %o with content %O', layoutfile, lines);
|
||||
return lines.join(EOL);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
15
node_modules/@lando/vitepress-theme-default-plus/vite/patch-vp-menu-columns-plugin.js
generated
vendored
Normal file
15
node_modules/@lando/vitepress-theme-default-plus/vite/patch-vp-menu-columns-plugin.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import Debug from 'debug';
|
||||
|
||||
export default function({debug = Debug('@lando/vite-plugin')}) { // eslint-disable-line
|
||||
return {
|
||||
name: 'vp-menugroup-columns',
|
||||
enforce: 'pre',
|
||||
transform: (code, id) => {
|
||||
const menufile = 'VPMenu.vue';
|
||||
if (id.endsWith(menufile)) {
|
||||
debug('patched %o to add columns support to dropdown menu groups', menufile);
|
||||
return code.replace(':items="item.items"', ':items="item.items" :columns="item.columns"');
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
39
node_modules/@lando/vitepress-theme-default-plus/vite/patch-vp-use-sidebar-control.js
generated
vendored
Normal file
39
node_modules/@lando/vitepress-theme-default-plus/vite/patch-vp-use-sidebar-control.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import Debug from 'debug';
|
||||
import {EOL} from 'node:os';
|
||||
|
||||
export default function({debug = Debug('@lando/vite-plugin')}) { // eslint-disable-line
|
||||
return {
|
||||
name: 'vp-use-sidebar-control',
|
||||
enforce: 'pre',
|
||||
transform: (code, id) => {
|
||||
const supportfile = 'dist/client/theme-default/composables/sidebar.js';
|
||||
if (id.includes(supportfile)) {
|
||||
// prepend our mvb normalizer
|
||||
code = `import { getItemNormalizedLink } from '@lando/vitepress-theme-default-plus';${EOL}${code}`;
|
||||
code = `import { normalizeItems } from '@lando/vitepress-theme-default-plus';${EOL}${code}`;
|
||||
|
||||
// make sure we get "site" as well
|
||||
code = code.replace(
|
||||
'const { page, hash } = useData()',
|
||||
'const { site, page, hash } = useData()',
|
||||
);
|
||||
|
||||
// and then use getItemNormalizedLink
|
||||
code = code.replace(
|
||||
'isActive(page.value.relativePath, item.value.link)',
|
||||
'isActive(page.value.relativePath, getItemNormalizedLink(item.value, site.value))',
|
||||
);
|
||||
|
||||
// and also use normalizeItems
|
||||
code = code.replace(
|
||||
'containsActiveLink(page.value.relativePath, item.value.items)',
|
||||
'containsActiveLink(page.value.relativePath, normalizeItems(item.value.items, site.value))',
|
||||
);
|
||||
|
||||
// log
|
||||
debug('patched %o to use getItemNormalizedLink', supportfile);
|
||||
return code;
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
79
node_modules/@lando/vitepress-theme-default-plus/vite/url-loader.js
generated
vendored
Normal file
79
node_modules/@lando/vitepress-theme-default-plus/vite/url-loader.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import axios from 'axios';
|
||||
import matter from 'gray-matter';
|
||||
import merge from 'lodash-es/merge.js';
|
||||
|
||||
import Debug from 'debug';
|
||||
import {EOL} from 'node:os';
|
||||
|
||||
// return updated content
|
||||
const getContent = (remote, og, config) => {
|
||||
switch (config.content) {
|
||||
case 'append': return `${og.content}${EOL}${remote.content}`;
|
||||
case 'prepend': return `${remote.content}${EOL}${og.content}`;
|
||||
case 'replace': return remote.content;
|
||||
default: return remote.content;
|
||||
}
|
||||
};
|
||||
|
||||
// return updated frontmatter
|
||||
const getFrontmatter = (remote, og, config) => {
|
||||
switch (config.frontmatter) {
|
||||
case 'merge': return merge({}, og.data, remote.data);
|
||||
case 'rebase': return merge({}, remote.data, og.data);
|
||||
case 'replace': return remote.data;
|
||||
case 'omit':
|
||||
case 'skip':
|
||||
case false:
|
||||
return og.data;
|
||||
default: return remote.data;
|
||||
}
|
||||
};
|
||||
|
||||
// return a standard url-loader config object with defaults
|
||||
const normalize = config => {
|
||||
// if config is a string then reset to an object
|
||||
if (typeof config === 'string') config = {source: config};
|
||||
// return with mixed in defaults
|
||||
return merge({}, {content: 'replace', frontmatter: 'replace'}, config);
|
||||
};
|
||||
|
||||
export default function({debug = Debug('@lando/url-loader')}) { // eslint-disable-line
|
||||
return {
|
||||
name: 'url-loader',
|
||||
enforce: 'pre',
|
||||
async transform(code, id) {
|
||||
if (id.endsWith('.md')) {
|
||||
// get original content stuff
|
||||
const og = matter(code);
|
||||
|
||||
// if we have a url-loader then proceed
|
||||
if (og?.data?.['url-loader']) {
|
||||
// normalize loader
|
||||
const config = normalize(og.data['url-loader']);
|
||||
debug('fetching content for %o from %o with %o', id, config.source, {config});
|
||||
|
||||
// attempt to get raw remote source code
|
||||
try {
|
||||
new URL(config.source);
|
||||
config.response = await axios.get(config.source);
|
||||
} catch (error) {
|
||||
error.message = `Fetching ${config.source} for ${id} failed with: ${error.message}`;
|
||||
throw error;
|
||||
}
|
||||
|
||||
// parse remote content
|
||||
const remote = matter(config?.response?.data ?? '');
|
||||
|
||||
// build new content/frontmatter
|
||||
const content = getContent(remote, og, config);
|
||||
const frontmatter = getFrontmatter(remote, og, config);
|
||||
|
||||
// stringify and retturn
|
||||
return matter.stringify(content, frontmatter);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user