mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 01:54:48 +00:00
feat(cli): set title by lang
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import glob from 'fast-glob';
|
||||
import { join, parse } from 'path';
|
||||
import { existsSync } from 'fs-extra';
|
||||
import { existsSync, readdirSync } from 'fs-extra';
|
||||
import {
|
||||
pascalize,
|
||||
removeExt,
|
||||
getVantConfig,
|
||||
getComponents,
|
||||
smartOutputFile
|
||||
} from '../common';
|
||||
import {
|
||||
@@ -96,8 +95,8 @@ function genExportConfig() {
|
||||
}
|
||||
|
||||
export function genSiteDesktopShared() {
|
||||
const components = getComponents();
|
||||
const documents = resolveDocuments(components);
|
||||
const dirs = readdirSync(SRC_DIR);
|
||||
const documents = resolveDocuments(dirs);
|
||||
|
||||
const code = `${genImportConfig()}
|
||||
${genImportDocuments(documents)}
|
||||
|
@@ -1,12 +1,11 @@
|
||||
import { join } from 'path';
|
||||
import { existsSync } from 'fs-extra';
|
||||
import { existsSync, readdirSync } from 'fs-extra';
|
||||
import { SRC_DIR, SITE_MODILE_SHARED_FILE } from '../common/constant';
|
||||
import {
|
||||
pascalize,
|
||||
removeExt,
|
||||
decamelize,
|
||||
getVantConfig,
|
||||
getComponents,
|
||||
smartOutputFile
|
||||
} from '../common';
|
||||
|
||||
@@ -90,8 +89,8 @@ ${genConfig(demos)}
|
||||
}
|
||||
|
||||
export function genSiteMobileShared() {
|
||||
const components = getComponents();
|
||||
const code = genCode(components);
|
||||
const dirs = readdirSync(SRC_DIR);
|
||||
const code = genCode(dirs);
|
||||
|
||||
smartOutputFile(SITE_MODILE_SHARED_FILE, code);
|
||||
}
|
||||
|
@@ -9,8 +9,28 @@ import {
|
||||
SITE_DESKTOP_SHARED_FILE
|
||||
} from '../common/constant';
|
||||
|
||||
const siteConfig = getVantConfig().site;
|
||||
const title = `${siteConfig.title} - ${siteConfig.description}`;
|
||||
function getSiteConfig() {
|
||||
const siteConfig = getVantConfig().site;
|
||||
|
||||
if (siteConfig.locales) {
|
||||
return siteConfig.locales[siteConfig.defaultLang || 'en-US'];
|
||||
}
|
||||
|
||||
return siteConfig;
|
||||
}
|
||||
|
||||
function getTitle(config: { title: string, description?: string }) {
|
||||
let { title } = config;
|
||||
|
||||
if (config.description) {
|
||||
title += ` - ${config.description}`;
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
const siteConfig = getSiteConfig();
|
||||
const title = getTitle(siteConfig);
|
||||
|
||||
export const siteDevBaseConfig = merge(baseConfig as any, {
|
||||
entry: {
|
||||
|
Reference in New Issue
Block a user