mirror of
https://github.com/laurent22/joplin.git
synced 2025-04-11 11:12:03 +02:00
init
This commit is contained in:
parent
2171132555
commit
0cdefcc61a
@ -45,7 +45,7 @@
|
|||||||
"updateIgnored": "gulp updateIgnoredTypeScriptBuild",
|
"updateIgnored": "gulp updateIgnoredTypeScriptBuild",
|
||||||
"updatePluginTypes": "./packages/generator-joplin/updateTypes.sh",
|
"updatePluginTypes": "./packages/generator-joplin/updateTypes.sh",
|
||||||
"watch": "lerna run watch --stream --parallel",
|
"watch": "lerna run watch --stream --parallel",
|
||||||
"watchWebsite": "nodemon --verbose --watch Assets/WebsiteAssets --watch packages/tools/website/build.js --ext md,ts,js,mustache,css,tsx,gif,png,svg --exec \"node packages/tools/website/build.js && http-server --port 8077 docs -a localhost\"",
|
"watchWebsite": "nodemon --verbose --watch Assets/WebsiteAssets --watch packages/tools/website/build.js --ext md,ts,js,mustache,css,tsx,gif,png,svg --exec \"node packages/tools/website/build.js && http-server --port 8077 ../joplin-website/docs -a localhost\"",
|
||||||
"i": "node packages/tools/lernaInstall"
|
"i": "node packages/tools/lernaInstall"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { readFileSync, readFile, mkdirpSync, writeFileSync, remove, copy } from 'fs-extra';
|
import { readFileSync, readFile, mkdirpSync, writeFileSync, remove, copy, pathExistsSync } from 'fs-extra';
|
||||||
import { insertContentIntoFile, rootDir } from '../tool-utils';
|
import { insertContentIntoFile, rootDir } from '../tool-utils';
|
||||||
import { pressCarouselItems } from './utils/pressCarousel';
|
import { pressCarouselItems } from './utils/pressCarousel';
|
||||||
import { getMarkdownIt, loadMustachePartials, markdownToPageHtml, renderMustache } from './utils/render';
|
import { getMarkdownIt, loadMustachePartials, markdownToPageHtml, renderMustache } from './utils/render';
|
||||||
@ -6,15 +6,19 @@ import { AssetUrls, Env, OrgSponsor, PlanPageParams, Sponsors, TemplateParams }
|
|||||||
import { getPlans, loadStripeConfig } from '@joplin/lib/utils/joplinCloud';
|
import { getPlans, loadStripeConfig } from '@joplin/lib/utils/joplinCloud';
|
||||||
import { shuffle } from '@joplin/lib/array';
|
import { shuffle } from '@joplin/lib/array';
|
||||||
import { stripOffFrontMatter } from './utils/frontMatter';
|
import { stripOffFrontMatter } from './utils/frontMatter';
|
||||||
|
import { dirname, basename } from 'path';
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
|
||||||
const dirname = require('path').dirname;
|
|
||||||
const glob = require('glob');
|
const glob = require('glob');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const md5File = require('md5-file/promise');
|
const md5File = require('md5-file/promise');
|
||||||
|
|
||||||
const env = Env.Prod;
|
const env = Env.Prod;
|
||||||
|
|
||||||
|
const docDir = `${dirname(dirname(dirname(dirname(__dirname))))}/joplin-website/docs`;
|
||||||
|
|
||||||
|
if (!pathExistsSync(docDir)) throw new Error(`Doc directory does not exist: ${docDir}`);
|
||||||
|
|
||||||
const websiteAssetDir = `${rootDir}/Assets/WebsiteAssets`;
|
const websiteAssetDir = `${rootDir}/Assets/WebsiteAssets`;
|
||||||
const mainTemplateHtml = readFileSync(`${websiteAssetDir}/templates/main-new.mustache`, 'utf8');
|
const mainTemplateHtml = readFileSync(`${websiteAssetDir}/templates/main-new.mustache`, 'utf8');
|
||||||
const frontTemplateHtml = readFileSync(`${websiteAssetDir}/templates/front.mustache`, 'utf8');
|
const frontTemplateHtml = readFileSync(`${websiteAssetDir}/templates/front.mustache`, 'utf8');
|
||||||
@ -231,8 +235,8 @@ const isNewsFile = (filePath: string): boolean => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
await remove(`${rootDir}/docs`);
|
await remove(`${docDir}`);
|
||||||
await copy(websiteAssetDir, `${rootDir}/docs`);
|
await copy(websiteAssetDir, `${docDir}`);
|
||||||
|
|
||||||
const sponsors = await loadSponsors();
|
const sponsors = await loadSponsors();
|
||||||
const partials = await loadMustachePartials(partialDir);
|
const partials = await loadMustachePartials(partialDir);
|
||||||
@ -247,13 +251,13 @@ async function main() {
|
|||||||
// HELP PAGE
|
// HELP PAGE
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|
||||||
renderPageToHtml(readmeMd, `${rootDir}/docs/help/index.html`, { sourceMarkdownFile: 'README.md', partials, sponsors, assetUrls });
|
renderPageToHtml(readmeMd, `${docDir}/help/index.html`, { sourceMarkdownFile: 'README.md', partials, sponsors, assetUrls });
|
||||||
|
|
||||||
// =============================================================
|
// =============================================================
|
||||||
// FRONT PAGE
|
// FRONT PAGE
|
||||||
// =============================================================
|
// =============================================================
|
||||||
|
|
||||||
renderPageToHtml('', `${rootDir}/docs/index.html`, {
|
renderPageToHtml('', `${docDir}/index.html`, {
|
||||||
templateHtml: frontTemplateHtml,
|
templateHtml: frontTemplateHtml,
|
||||||
partials,
|
partials,
|
||||||
pressCarouselRegular: {
|
pressCarouselRegular: {
|
||||||
@ -290,7 +294,7 @@ async function main() {
|
|||||||
|
|
||||||
const planPageContentHtml = renderMustache('', planPageParams);
|
const planPageContentHtml = renderMustache('', planPageParams);
|
||||||
|
|
||||||
renderPageToHtml('', `${rootDir}/docs/plans/index.html`, {
|
renderPageToHtml('', `${docDir}/plans/index.html`, {
|
||||||
...defaultTemplateParams(assetUrls),
|
...defaultTemplateParams(assetUrls),
|
||||||
pageName: 'plans',
|
pageName: 'plans',
|
||||||
partials,
|
partials,
|
||||||
@ -310,11 +314,21 @@ async function main() {
|
|||||||
const donateLinksMd = await getDonateLinks();
|
const donateLinksMd = await getDonateLinks();
|
||||||
|
|
||||||
const makeTargetFilePath = (input: string): string => {
|
const makeTargetFilePath = (input: string): string => {
|
||||||
|
const filenameNoExt = basename(input, '.md');
|
||||||
|
|
||||||
if (isNewsFile(input)) {
|
if (isNewsFile(input)) {
|
||||||
return `${input.replace(/\.md/, '').replace(/readme\/news\//, 'docs/news/')}/index.html`;
|
return `${docDir}/news/${filenameNoExt}/index.html`; // `${input.replace(/\.md/, '').replace(/readme\/news\//, 'docs/news/')}/index.html`;
|
||||||
} else {
|
} else {
|
||||||
return `${input.replace(/\.md/, '').replace(/readme\//, 'docs/')}/index.html`;
|
return `${docDir}/${filenameNoExt}/index.html`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return `${input.replace(/\.md/, '').replace(/readme\//, 'docs/')}/index.html`;
|
||||||
|
|
||||||
|
// if (isNewsFile(input)) {
|
||||||
|
// return `${input.replace(/\.md/, '').replace(/readme\/news\//, 'docs/news/')}/index.html`;
|
||||||
|
// } else {
|
||||||
|
// return `${input.replace(/\.md/, '').replace(/readme\//, 'docs/')}/index.html`;
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const newsFilePaths: string[] = [];
|
const newsFilePaths: string[] = [];
|
||||||
@ -338,9 +352,10 @@ async function main() {
|
|||||||
source[2].sourceMarkdownName = path.basename(source[0], path.extname(source[0]));
|
source[2].sourceMarkdownName = path.basename(source[0], path.extname(source[0]));
|
||||||
|
|
||||||
const sourceFilePath = `${rootDir}/${source[0]}`;
|
const sourceFilePath = `${rootDir}/${source[0]}`;
|
||||||
|
const targetFilePath = source[1];
|
||||||
const isNews = isNewsFile(sourceFilePath);
|
const isNews = isNewsFile(sourceFilePath);
|
||||||
|
|
||||||
renderFileToHtml(sourceFilePath, `${rootDir}/${source[1]}`, {
|
renderFileToHtml(sourceFilePath, targetFilePath, {
|
||||||
...source[2],
|
...source[2],
|
||||||
templateHtml: mainTemplateHtml,
|
templateHtml: mainTemplateHtml,
|
||||||
pageName: isNews ? 'news-item' : '',
|
pageName: isNews ? 'news-item' : '',
|
||||||
@ -355,7 +370,7 @@ async function main() {
|
|||||||
return a.toLowerCase() > b.toLowerCase() ? -1 : +1;
|
return a.toLowerCase() > b.toLowerCase() ? -1 : +1;
|
||||||
});
|
});
|
||||||
|
|
||||||
await makeNewsFrontPage(newsFilePaths, `${rootDir}/docs/news/index.html`, {
|
await makeNewsFrontPage(newsFilePaths, `${docDir}/news/index.html`, {
|
||||||
...defaultTemplateParams(assetUrls),
|
...defaultTemplateParams(assetUrls),
|
||||||
pageName: 'news',
|
pageName: 'news',
|
||||||
partials,
|
partials,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user