mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 16:00:14 +01:00
Gh pages deploy fix (#5669)
* fix(app):redirect after 404 * fix(app):docs building script * fix(app):add gulpfile for docs * fix(app): directory splitting * fix(app): build docs script * fix(app): build docs script * fix(app): build docs script * fix(app): relative path for scss * fix(app): relative path for scss * fix(app): relative path for scss * fix(app):fix footer icons * fix(app):fix footer icons * fix(app):fix footer icons * fix(app):config * fix(app):remove small-social * fix(docs): footer icons style * fix(docs): material page index file * fix(docs): descriptions and keyword * fix(docs): og description * fix(docs): og description and title * fix(docs): dem,o branch url * fix(docs): dynamic title for docs page * fix(docs): remove unused script * fix(docs): static title Co-authored-by: Evgeny Lupanov <e.lupanov@akveo.com>
This commit is contained in:
parent
5cfe9dee9c
commit
63ac65eada
26 changed files with 3723 additions and 61 deletions
85
scripts/gulp/tasks/docs/docs.ts
Normal file
85
scripts/gulp/tasks/docs/docs.ts
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
import { task, series } from 'gulp';
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
||||
import { isAbsolute, join, resolve, sep } from 'path';
|
||||
|
||||
import { structure as DOCS } from '../../../../docs/structure';
|
||||
import { structure as LANDING } from '../../../../docs/structure-landing';
|
||||
import { DOCS_DIST } from '../config';
|
||||
|
||||
task('create-docs-dirs', (done) => {
|
||||
const docsStructure = flatten('docs', routesTree(DOCS));
|
||||
createDirsStructure(docsStructure);
|
||||
|
||||
const landingStructure = flatten('', routesTree(LANDING));
|
||||
createDirsStructure(landingStructure);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
function routesTree(structure) {
|
||||
return structure
|
||||
.filter((page: any) => ['section', 'page', 'tabs'].includes(page.type))
|
||||
.map((page: any) => {
|
||||
if (page.type === 'tabs') {
|
||||
page.children = ['overview', 'api', 'theme', 'examples']
|
||||
.map(name => ({ name, type: 'page'}));
|
||||
}
|
||||
return page;
|
||||
})
|
||||
.map((page: any) => {
|
||||
return {
|
||||
path: prepareSlag(page.name),
|
||||
children: page.children ? routesTree(page.children) : [],
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function prepareSlag(name) {
|
||||
return name.replace(/[^a-zA-Z0-9\s]+/g, '')
|
||||
.replace(/\s/g, '-')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
function flatten(root, arr) {
|
||||
let res: any[] = [];
|
||||
arr.forEach((item: any) => {
|
||||
const path = `${root}/${item.path}`;
|
||||
res.push(path);
|
||||
if (item.children) {
|
||||
res = res.concat(flatten(path, item.children));
|
||||
}
|
||||
});
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function createDirsStructure(dirs) {
|
||||
const index = readFileSync(join(DOCS_DIST, 'index.html'), 'utf8');
|
||||
dirs.forEach((dir: any) => {
|
||||
|
||||
const fullPath = join(DOCS_DIST, dir);
|
||||
if (!existsSync(fullPath)) {
|
||||
mkDirByPathSync(fullPath);
|
||||
}
|
||||
|
||||
writeFileSync(join(fullPath, 'index.html'), index);
|
||||
});
|
||||
}
|
||||
|
||||
function mkDirByPathSync(targetDir, {isRelativeToScript = false} = {}) {
|
||||
const initDir = isAbsolute(targetDir) ? sep : '';
|
||||
const baseDir = isRelativeToScript ? __dirname : '.';
|
||||
|
||||
targetDir.split(sep).reduce((parentDir, childDir) => {
|
||||
const curDir = resolve(baseDir, parentDir, childDir);
|
||||
try {
|
||||
mkdirSync(curDir);
|
||||
} catch (err) {
|
||||
if (err.code !== 'EEXIST') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
return curDir;
|
||||
}, initDir);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue