1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Doc: Add "discuss" link to news posts

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

View File

@ -523,12 +523,17 @@ div.navbar-mobile-content a.sponsor-button {
.bottom-links {
display: flex;
flex-direction: row;
justify-content: center;
border-top: 1px solid #d4d4d4;
margin-top: 30px;
padding-top: 25px;
}
.bottom-links .bottom-link {
margin-right: 20px;
}
/* TOC */
#toc ul {

View File

@ -63,13 +63,20 @@ https://github.com/laurent22/joplin/blob/dev/{{{sourceMarkdownFile}}}
Running in {{env}} mode!
</div>
{{{contentHtml}}}
{{#showImproveThisDoc}}
{{#showBottomLinks}}
<div class="bottom-links">
<a href="https://github.com/laurent22/joplin/blob/dev/{{{sourceMarkdownFile}}}">
<i class="fab fa-github"></i> Improve this doc
</a>
{{#discussOnForumLink}}
<a class="bottom-link" href="{{{discussOnForumLink}}}">
<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>
{{/showImproveThisDoc}}
{{/showBottomLinks}}
</div>
</div>
</div>

View File

@ -22,6 +22,8 @@ const plansTemplateHtml = readFileSync(`${websiteAssetDir}/templates/plans.musta
const stripeConfig = loadStripeConfig(env, `${rootDir}/packages/server/stripeConfig.json`);
const partialDir = `${websiteAssetDir}/templates/partials`;
const discussLink = 'https://discourse.joplinapp.org/c/news/9';
let tocMd_: string = null;
let tocHtml_: string = null;
const tocRegex_ = /<!-- TOC -->([^]*)<!-- TOC -->/;
@ -109,6 +111,8 @@ function renderPageToHtml(md: string, targetPath: string, templateParams: Templa
...templateParams,
};
templateParams.showBottomLinks = templateParams.showImproveThisDoc || !!templateParams.discussOnForumLink;
const title = [];
if (!templateParams.title) {
@ -211,9 +215,10 @@ 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;
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[<i class="fab fa-discourse"></i> Discuss on the forum](${discussLink})`;
frontPageMd.push(md);
if (frontPageMd.length >= maxNewsPerPage) break;
}
@ -333,11 +338,14 @@ async function main() {
source[2].sourceMarkdownName = path.basename(source[0], path.extname(source[0]));
const sourceFilePath = `${rootDir}/${source[0]}`;
const isNews = isNewsFile(sourceFilePath);
renderFileToHtml(sourceFilePath, `${rootDir}/${source[1]}`, {
...source[2],
templateHtml: mainTemplateHtml,
pageName: isNewsFile(sourceFilePath) ? 'news-item' : '',
pageName: isNews ? 'news-item' : '',
discussOnForumLink: isNews ? discussLink : '',
showImproveThisDoc: !isNews,
partials,
assetUrls,
});

View File

@ -70,6 +70,8 @@ export interface TemplateParams {
navbar?: NavBar;
showJoplinCloudLinks?: boolean;
assetUrls: AssetUrls;
discussOnForumLink?: string;
showBottomLinks?: boolean;
}
export interface PlanPageParams extends TemplateParams {