docs(edit): added edit on github link

This commit is contained in:
Christopher Pickering 2022-06-22 10:03:18 -05:00
parent c28637aaa3
commit b7b8214acd
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
9 changed files with 84 additions and 28 deletions

View file

@ -9,7 +9,8 @@ const locales = require('./src/_data/locales');
const fs = require('fs');
const outdent = require('outdent');
const schema = require("@quasibit/eleventy-plugin-schema");
const editOnGithub = require('eleventy-plugin-edit-on-github');
const i18n_func = require('eleventy-plugin-i18n/i18n.js');
const slugifyCustom = (s) =>
slugify(s, { lower: true, remove: /[*+~.()'"!:@]/g });
@ -72,8 +73,29 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(syntaxHighlight);
eleventyConfig.addPlugin(metagen);
eleventyConfig.addPlugin(criticalCss);
eleventyConfig.addPlugin(schema);
eleventyConfig.addPlugin(editOnGithub, {
// required
github_edit_repo: 'https://github.com/Riverside-Healthcare/djLint',
// optional: defaults
github_edit_path: "/docs/", // non-root location in git url. root is assumed
github_edit_branch: 'master',
github_edit_text: (page) => {
i18n_options = Object.assign({},{
translations,
fallbackLocales: {
'*': 'en-US'
}})
return `<span class="icon-text"><span class="icon mr-1"><i class="fas fa-pencil-alt"></i></span><span>${i18n_func("edit_page", undefined,undefined, i18n_options, page)}</span></span>`;
return x.inputPath
},
github_edit_class: 'edit-on-github',
github_edit_tag: 'a',
github_edit_attributes: 'target="_blank" rel="noopener"',
github_edit_wrapper: undefined, //ex: "<div stuff>${edit_on_github}</div>"
});
/* Markdown Plugins */
const markdownItAnchor = require("markdown-it-anchor");

19
docs/package-lock.json generated
View file

@ -34,6 +34,7 @@
"bulma-pricingtable": "0.2.0",
"cssnano": "5.1.7",
"cz-conventional-changelog": "3.3.0",
"eleventy-plugin-edit-on-github": "^1.1.0",
"eleventy-plugin-metagen": "1.7.1",
"esbuild": "0.14.38",
"eslint": "8.18.0",
@ -3862,6 +3863,15 @@
"critical": "^4.0.1"
}
},
"node_modules/eleventy-plugin-edit-on-github": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eleventy-plugin-edit-on-github/-/eleventy-plugin-edit-on-github-1.1.0.tgz",
"integrity": "sha512-Hjp70ELdDwrmQ1hXa20bOKgtru9sCiD95Y6OnR2WZBtHZhSYi4ESP+ZUc6pvZkjqoPOiQ2LeG9rs5Mm0401KqQ==",
"dev": true,
"dependencies": {
"@11ty/eleventy": "^1.0.1"
}
},
"node_modules/eleventy-plugin-i18n": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/eleventy-plugin-i18n/-/eleventy-plugin-i18n-0.1.3.tgz",
@ -15175,6 +15185,15 @@
"critical": "^4.0.1"
}
},
"eleventy-plugin-edit-on-github": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eleventy-plugin-edit-on-github/-/eleventy-plugin-edit-on-github-1.1.0.tgz",
"integrity": "sha512-Hjp70ELdDwrmQ1hXa20bOKgtru9sCiD95Y6OnR2WZBtHZhSYi4ESP+ZUc6pvZkjqoPOiQ2LeG9rs5Mm0401KqQ==",
"dev": true,
"requires": {
"@11ty/eleventy": "^1.0.1"
}
},
"eleventy-plugin-i18n": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/eleventy-plugin-i18n/-/eleventy-plugin-i18n-0.1.3.tgz",

View file

@ -38,6 +38,7 @@
"bulma-pricingtable": "0.2.0",
"cssnano": "5.1.7",
"cz-conventional-changelog": "3.3.0",
"eleventy-plugin-edit-on-github": "^1.1.0",
"eleventy-plugin-metagen": "1.7.1",
"esbuild": "0.14.38",
"eslint": "8.18.0",

View file

@ -125,4 +125,9 @@ module.exports = {
ru: 'Вклад в работу сайта приветствуется. Пришлите письмо с новой функцией или ознакомьтесь со <a href="https://github.com/Riverside-Healthcare/djlint/issues">списком проблем</a> и помогите, чем можете.',
fr: 'Les contributions sont les bienvenues. Envoyez un pr avec une nouvelle fonctionnalité, ou consultez la <a href="https://github.com/Riverside-Healthcare/djlint/issues">liste</a> et aidez où vous pouvez.'
},
edit_page: {
'en-US': 'Edit this page',
ru: 'Редактировать эту страницу',
fr: 'Modifier cette page',
}
};

View file

@ -3,27 +3,29 @@ layout: layout.njk
---
<div class="container">
<div class="columns">
<div class="column is-narrow mr-5">
<aside class="menu is-sticky">
<p class="menu-label">
{{ "documentation" | i18n }}
</p>
<ul class="menu-list">
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/getting-started/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/getting-started/">{{ "getting_started" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/formatter/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/formatter/">{{ "formatter" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/linter/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/linter">{{ "linter" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/configuration/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/configuration/">{{ "configuration" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/integrations/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/integrations">{{ "integrations" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/best-practices/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/best-practices/">{{ "best_practices" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/changelog/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/changelog">{{ "changelog" | i18n }}</a></li>
</ul>
</aside>
</div>
<div class="column mb-5">
{{ content | safe }}
</div>
<div class="columns">
<div class="column is-narrow mr-5">
<aside class="menu is-sticky">
<p class="menu-label">
{{ "documentation" | i18n }}
</p>
<ul class="menu-list">
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/getting-started/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/getting-started/">{{ "getting_started" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/formatter/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/formatter/">{{ "formatter" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/linter/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/linter">{{ "linter" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/configuration/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/configuration/">{{ "configuration" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/integrations/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/integrations">{{ "integrations" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/best-practices/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/best-practices/">{{ "best_practices" | i18n }}</a></li>
<li><a class="{% if page.url == "lang_code_url" | i18n + "/docs/changelog/" %}is-active{% endif %}" href="{{ "lang_code_url" | i18n }}/docs/changelog">{{ "changelog" | i18n }}</a></li>
</ul>
</aside>
</div>
<div class="column mb-5">
{{ content | safe }}
<div class="is-flex is-justify-content-space-between">
<span>{% gh_edit page %}</span>
<em><small>{{ "updated" | i18n }} <strong>{{ page.date | niceDate }}</strong></small></em>
</div>
</div>
</div>
</div>

View file

@ -12,7 +12,7 @@
<div class="column"></div>
<div class="column">
<p class="copyright has-text-grey">
djLint © 2021 Riverside Healthcare <br><br> {{ "updated" | i18n }} {{ page.date | niceDate }}
djLint | ©2021 Riverside Healthcare
</p>
</div>
</div>

View file

@ -23,7 +23,7 @@ module.exports = class {
return await postcss([
require('postcss-nested'),
purgecss({
content: ['./src/**/*.njk', './src/**/*.md'],
content: ['./src/**/*.njk', './src/**/*.md', './src/**/*.js'],
safelist: {
deep: [
/headShake/,
@ -46,6 +46,9 @@ module.exports = class {
/is-light/,
/is-active/,
/is-info/,
/fa-*/,
/mr-1/,
/mr-2/
],
},
}),

View file

@ -1,3 +1,4 @@
{
"layout": "docs_layout.njk"
"layout": "docs_layout.njk",
"date": "git Last Modified"
}

View file

@ -45,6 +45,9 @@
"automerge": true
}
],
"pre-commit": {
"enabled": true
},
"schedule": ["on monday before 8:00am"],
"timezone": "America/Chicago"
}