Initalize
This commit is contained in:
14
node_modules/@lando/vitepress-theme-default-plus/client/collections.data.js
generated
vendored
Normal file
14
node_modules/@lando/vitepress-theme-default-plus/client/collections.data.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import Debug from 'debug';
|
||||
import {default as createContentLoader} from '../utils/create-content-loader.js';
|
||||
|
||||
const config = globalThis.VITEPRESS_CONFIG?.site?.themeConfig?.collections ?? {};
|
||||
const debug = Debug('@lando/collections.data.js'); // eslint-disable-line
|
||||
const siteConfig = globalThis.VITEPRESS_CONFIG;
|
||||
|
||||
const patterns = Object.entries(config)
|
||||
.map(([type, config]) => config.patterns)
|
||||
.flat(Number.POSITIVE_INFINITY);
|
||||
|
||||
debug('loading collections data with patterns config %o', patterns);
|
||||
|
||||
export default createContentLoader(patterns, {siteConfig}, {debug});
|
||||
5
node_modules/@lando/vitepress-theme-default-plus/client/enhance-app-with-layouts.js
generated
vendored
Normal file
5
node_modules/@lando/vitepress-theme-default-plus/client/enhance-app-with-layouts.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// DO NOT MODIFY THIS FILE!!!
|
||||
// if you do it or you will break things
|
||||
// it is automatically transformed by vite to statically include our layout imports
|
||||
export default function(app) {
|
||||
};
|
||||
17
node_modules/@lando/vitepress-theme-default-plus/client/tags.data.js
generated
vendored
Normal file
17
node_modules/@lando/vitepress-theme-default-plus/client/tags.data.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import Debug from 'debug';
|
||||
|
||||
import {default as getTags} from '../utils/get-tags.js';
|
||||
|
||||
const debug = Debug('@lando/tags.data.js'); // eslint-disable-line
|
||||
const siteConfig = globalThis.VITEPRESS_CONFIG;
|
||||
|
||||
export default {
|
||||
async load() {
|
||||
const config = siteConfig?.userConfig?.themeConfig?.multiVersionBuild ?? {};
|
||||
const root = siteConfig?.userConfig?.gitRoot;
|
||||
const tags = await getTags(root, config, {debug: debug.extend('get-tags')});
|
||||
debug('loading tag data %o', tags);
|
||||
return tags;
|
||||
},
|
||||
};
|
||||
17
node_modules/@lando/vitepress-theme-default-plus/client/team.data.js
generated
vendored
Normal file
17
node_modules/@lando/vitepress-theme-default-plus/client/team.data.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import Debug from 'debug';
|
||||
|
||||
import {default as getContributors} from '../utils/get-contributors.js';
|
||||
|
||||
const debug = Debug('@lando/team.data.js'); // eslint-disable-line
|
||||
const siteConfig = globalThis.VITEPRESS_CONFIG;
|
||||
|
||||
export default {
|
||||
async load() {
|
||||
const contributors = siteConfig?.userConfig?.themeConfig?.contributors ?? false;
|
||||
const root = siteConfig?.userConfig?.gitRoot;
|
||||
const team = contributors !== false ? await getContributors(root, contributors, {debug: debug.extend('get-contribs'), paths: []}) : [];
|
||||
debug('loading team data %o', team);
|
||||
return team;
|
||||
},
|
||||
};
|
||||
67
node_modules/@lando/vitepress-theme-default-plus/client/use-collection.js
generated
vendored
Normal file
67
node_modules/@lando/vitepress-theme-default-plus/client/use-collection.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import sortBy from 'lodash-es/sortBy.js';
|
||||
import uniq from 'lodash-es/uniq.js';
|
||||
|
||||
import {computed, reactive} from 'vue';
|
||||
import {useData, useRoute} from 'vitepress';
|
||||
import {data as collections} from './collections.data.js';
|
||||
|
||||
export default function useCollection(type = undefined) {
|
||||
const route = useRoute();
|
||||
const path = route.path;
|
||||
const {site, theme} = useData();
|
||||
const themeTags = theme.value?.tags ?? {};
|
||||
|
||||
function findCurrentIndex() {
|
||||
const result = pages.findIndex(p => `${site.value?.base ?? ''}${p.url}`.replace(/\/+/g, '/') === route.path);
|
||||
if (result === -1) console.error(`content missing: ${route.path}`);
|
||||
return result;
|
||||
}
|
||||
|
||||
// filter pages if needed
|
||||
const pages = type === undefined ? collections : collections.filter(page => page.type === type);
|
||||
|
||||
// current
|
||||
const page = computed(() => pages[findCurrentIndex()]);
|
||||
|
||||
// prev page or loop back to end unless the end is me
|
||||
const prevPage = computed(() => {
|
||||
const prev = pages[findCurrentIndex() - 1] ?? pages[pages.length - 1];
|
||||
return prev?.id !== page?.value?.id ? prev : undefined;
|
||||
});
|
||||
// next page or loop back to beginning unless the beginning is me
|
||||
const nextPage = computed(() => {
|
||||
const next = pages[findCurrentIndex() + 1] ?? pages[0];
|
||||
return next?.id !== page?.value?.id ? next : undefined;
|
||||
});
|
||||
|
||||
// these are meant to replace the core next|prev nav links
|
||||
const prevnext = computed(() => ({
|
||||
prev: prevPage.value ? {text: prevPage.value.title, link: prevPage.value.url} : undefined,
|
||||
next: nextPage.value ? {text: nextPage.value.title, link: nextPage.value.url} : undefined,
|
||||
}));
|
||||
|
||||
// get the tagz as well
|
||||
const sortedTags = sortBy(uniq(pages.map(page => page.tags).flat(Infinity)));
|
||||
const tags = reactive(Object.fromEntries(sortedTags.map(tag => ([tag, {
|
||||
selected: false,
|
||||
...themeTags[tag] ?? {},
|
||||
}]))));
|
||||
|
||||
// helper func to see if a set of tag filtered pages has items or not, useful for showing collection sections
|
||||
const hasItems = (items = [], tags = {}) => {
|
||||
const tagList = Object.entries(tags).filter(pair => pair[1].selected === true).map(pair => pair[0]);
|
||||
const filteredItems = items.filter(item => tagList.every(tag => item.tags.indexOf(tag) !== -1));
|
||||
return filteredItems.length > 0;
|
||||
};
|
||||
|
||||
return {
|
||||
hasItems,
|
||||
pages,
|
||||
page,
|
||||
nextPage,
|
||||
prevnext,
|
||||
prevPage,
|
||||
path,
|
||||
tags,
|
||||
};
|
||||
}
|
||||
32
node_modules/@lando/vitepress-theme-default-plus/client/use-tags.js
generated
vendored
Normal file
32
node_modules/@lando/vitepress-theme-default-plus/client/use-tags.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
import {data as tags} from './tags.data.js';
|
||||
|
||||
import {useData} from 'vitepress';
|
||||
|
||||
export default function useTags() {
|
||||
// get version path data
|
||||
const {theme} = useData();
|
||||
// if no mvb then just return tags
|
||||
if (!theme.value.multiVersionBuild) return tags;
|
||||
|
||||
// otherwise lets augment it with links and shit!
|
||||
const {base} = theme.value.multiVersionBuild;
|
||||
|
||||
// generate links we can pass into VPLVersionLink
|
||||
const links = tags.versions
|
||||
.map(version => ({
|
||||
text: version,
|
||||
href: `/${base}/${version}/`.replace(/\/{2,}/g, '/'),
|
||||
prerelease: /^v?\d+\.\d+\.\d+-\S+$/.test(version),
|
||||
stable: tags?.aliases?.stable === version,
|
||||
edge: tags?.aliases?.edge === version,
|
||||
}));
|
||||
|
||||
// also generate alias linkes
|
||||
const aliasLinks = {
|
||||
dev: `/${base}/dev/`.replace(/\/{2,}/g, '/'),
|
||||
edge: `/${base}/edge/`.replace(/\/{2,}/g, '/'),
|
||||
stable: `/${base}/stable/`.replace(/\/{2,}/g, '/'),
|
||||
};
|
||||
|
||||
return {...tags, links, aliasLinks};
|
||||
}
|
||||
5
node_modules/@lando/vitepress-theme-default-plus/client/use-team.js
generated
vendored
Normal file
5
node_modules/@lando/vitepress-theme-default-plus/client/use-team.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import {data as team} from './team.data.js';
|
||||
|
||||
export default function useTeam() {
|
||||
return team;
|
||||
}
|
||||
Reference in New Issue
Block a user