diff --git a/Assets/WebsiteAssets/templates/main-new.mustache b/Assets/WebsiteAssets/templates/main-new.mustache
index 8c98095cb..dfb7f0d93 100644
--- a/Assets/WebsiteAssets/templates/main-new.mustache
+++ b/Assets/WebsiteAssets/templates/main-new.mustache
@@ -65,11 +65,6 @@ https://github.com/laurent22/joplin/blob/dev/{{{sourceMarkdownFile}}}
{{{contentHtml}}}
{{#showBottomLinks}}
- {{#discussOnForumLink}}
-
- Discuss on the forum
-
- {{/discussOnForumLink}}
{{#showImproveThisDoc}}
Improve this doc
diff --git a/packages/tools/website/build.ts b/packages/tools/website/build.ts
index e5e70e40c..6b5f82b75 100644
--- a/packages/tools/website/build.ts
+++ b/packages/tools/website/build.ts
@@ -111,7 +111,7 @@ function renderPageToHtml(md: string, targetPath: string, templateParams: Templa
...templateParams,
};
- templateParams.showBottomLinks = templateParams.showImproveThisDoc || !!templateParams.discussOnForumLink;
+ templateParams.showBottomLinks = templateParams.showImproveThisDoc;
const title = [];
@@ -139,6 +139,9 @@ function renderPageToHtml(md: string, targetPath: string, templateParams: Templa
function renderFileToHtml(sourcePath: string, targetPath: string, templateParams: TemplateParams) {
let md = readFileSync(sourcePath, 'utf8');
+ if (templateParams.isNews) {
+ md = processNewsMarkdown(md, sourcePath);
+ }
md = stripOffFrontMatter(md).doc;
return renderPageToHtml(md, targetPath, templateParams);
}
@@ -168,6 +171,15 @@ async function loadSponsors(): Promise {
return output;
}
+const processNewsMarkdown = (md: string, mdFilePath: string): string => {
+ const info = stripOffFrontMatter(md);
+ md = info.doc.trim();
+ 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 += `\n\n* * *\n\n[ Discuss on the forum](${discussLink})`;
+ return md;
+};
+
const makeNewsFrontPage = async (sourceFilePaths: string[], targetFilePath: string, templateParams: TemplateParams) => {
const maxNewsPerPage = 20;
@@ -175,11 +187,7 @@ const makeNewsFrontPage = async (sourceFilePaths: string[], targetFilePath: stri
for (const mdFilePath of sourceFilePaths) {
let md = await readFile(mdFilePath, 'utf8');
- const info = stripOffFrontMatter(md);
- md = info.doc.trim();
- 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 += `\n\n* * *\n\n[ Discuss on the forum](${discussLink})`;
+ md = processNewsMarkdown(md, mdFilePath);
frontPageMd.push(md);
if (frontPageMd.length >= maxNewsPerPage) break;
}
@@ -344,8 +352,8 @@ async function main() {
...source[2],
templateHtml: mainTemplateHtml,
pageName: isNews ? 'news-item' : '',
- discussOnForumLink: isNews ? discussLink : '',
showImproveThisDoc: !isNews,
+ isNews,
partials,
assetUrls,
});
diff --git a/packages/tools/website/utils/types.ts b/packages/tools/website/utils/types.ts
index 154cea022..70fbfd03f 100644
--- a/packages/tools/website/utils/types.ts
+++ b/packages/tools/website/utils/types.ts
@@ -71,9 +71,9 @@ export interface TemplateParams {
navbar?: NavBar;
showJoplinCloudLinks?: boolean;
assetUrls: AssetUrls;
- discussOnForumLink?: string;
showBottomLinks?: boolean;
openGraph: OpenGraphTags;
+ isNews?: boolean;
}
export interface PlanPageParams extends TemplateParams {