Doc: Add "discuss" link to news posts

This commit is contained in:
Laurent Cozic committed 2021-12-18 16:45:59 +01:00
1 parent 3e1b1ae749
commit 2171132555
4 files changed
+29 -7

No files matched your search

+5
View File
@@ -523,12 +523,17 @@ div.navbar-mobile-content a.sponsor-button {
.bottom-links { .bottom-links {
display: flex; display: flex;
flex-direction: row;
justify-content: center; justify-content: center;
border-top: 1px solid #d4d4d4; border-top: 1px solid #d4d4d4;
margin-top: 30px; margin-top: 30px;
padding-top: 25px; padding-top: 25px;
} }
.bottom-links .bottom-link {
margin-right: 20px;
}
/* TOC */ /* TOC */
#toc ul { #toc ul {
@@ -63,13 +63,20 @@ https://github.com/laurent22/joplin/blob/dev/{{{sourceMarkdownFile}}}
Running in {{env}} mode! Running in {{env}} mode!
</div> </div>
{{{contentHtml}}} {{{contentHtml}}}
{{#showImproveThisDoc}} {{#showBottomLinks}}
<div class="bottom-links"> <div class="bottom-links">
<a href="https://github.com/laurent22/joplin/blob/dev/{{{sourceMarkdownFile}}}"> {{#discussOnForumLink}}
<i class="fab fa-github"></i> Improve this doc <a class="bottom-link" href="{{{discussOnForumLink}}}">
</a> <i class="fab fa-discourse"></i></i> Discuss on the forum
</a>
{{/discussOnForumLink}}
{{#showImproveThisDoc}}
<a class="bottom-link" href="https://github.com/laurent22/joplin/blob/dev/{{{sourceMarkdownFile}}}">
<i class="fab fa-github"></i> Improve this doc
</a>
{{/showImproveThisDoc}}
</div> </div>
{{/showImproveThisDoc}} {{/showBottomLinks}}
</div> </div>
</div> </div>
</div> </div>
+10 -2
View File
@@ -22,6 +22,8 @@ const plansTemplateHtml = readFileSync(`${websiteAssetDir}/templates/plans.musta
const stripeConfig = loadStripeConfig(env, `${rootDir}/packages/server/stripeConfig.json`); const stripeConfig = loadStripeConfig(env, `${rootDir}/packages/server/stripeConfig.json`);
const partialDir = `${websiteAssetDir}/templates/partials`; const partialDir = `${websiteAssetDir}/templates/partials`;
const discussLink = 'https://discourse.joplinapp.org/c/news/9';
let tocMd_: string = null; let tocMd_: string = null;
let tocHtml_: string = null; let tocHtml_: string = null;
const tocRegex_ = /<!-- TOC -->([^]*)<!-- TOC -->/; const tocRegex_ = /<!-- TOC -->([^]*)<!-- TOC -->/;
@@ -109,6 +111,8 @@ function renderPageToHtml(md: string, targetPath: string, templateParams: Templa
...templateParams, ...templateParams,
}; };
templateParams.showBottomLinks = templateParams.showImproveThisDoc || !!templateParams.discussOnForumLink;
const title = []; const title = [];
if (!templateParams.title) { if (!templateParams.title) {
@@ -211,9 +215,10 @@ const makeNewsFrontPage = async (sourceFilePaths: string[], targetFilePath: stri
for (const mdFilePath of sourceFilePaths) { for (const mdFilePath of sourceFilePaths) {
let md = await readFile(mdFilePath, 'utf8'); let md = await readFile(mdFilePath, 'utf8');
const info = stripOffFrontMatter(md); const info = stripOffFrontMatter(md);
md = info.doc; md = info.doc.trim();
const dateString = moment(info.created).format('D MMM YYYY'); const dateString = moment(info.created).format('D MMM YYYY');
md = md.replace(/^# (.*)/, `# [$1](https://github.com/laurent22/joplin/blob/dev/readme/news/${path.basename(mdFilePath)})\n\n*Published on **${dateString}***\n\n`); md = md.replace(/^# (.*)/, `# [$1](https://github.com/laurent22/joplin/blob/dev/readme/news/${path.basename(mdFilePath)})\n\n*Published on **${dateString}***\n\n`);
md += `\n\n* * *\n\n[<i class="fab fa-discourse"></i> Discuss on the forum](${discussLink})`;
frontPageMd.push(md); frontPageMd.push(md);
if (frontPageMd.length >= maxNewsPerPage) break; if (frontPageMd.length >= maxNewsPerPage) break;
} }
@@ -333,11 +338,14 @@ 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 isNews = isNewsFile(sourceFilePath);
renderFileToHtml(sourceFilePath, `${rootDir}/${source[1]}`, { renderFileToHtml(sourceFilePath, `${rootDir}/${source[1]}`, {
...source[2], ...source[2],
templateHtml: mainTemplateHtml, templateHtml: mainTemplateHtml,
pageName: isNewsFile(sourceFilePath) ? 'news-item' : '', pageName: isNews ? 'news-item' : '',
discussOnForumLink: isNews ? discussLink : '',
showImproveThisDoc: !isNews,
partials, partials,
assetUrls, assetUrls,
}); });
+2
View File
@@ -70,6 +70,8 @@ export interface TemplateParams {
navbar?: NavBar; navbar?: NavBar;
showJoplinCloudLinks?: boolean; showJoplinCloudLinks?: boolean;
assetUrls: AssetUrls; assetUrls: AssetUrls;
discussOnForumLink?: string;
showBottomLinks?: boolean;
} }
export interface PlanPageParams extends TemplateParams { export interface PlanPageParams extends TemplateParams {