diff --git a/.eleventy.js b/.eleventy.js index d58740c..7414ceb 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,19 +1,22 @@ const { DateTime } = require("luxon"); const fs = require("fs"); +const pluginNavigation = require("@11ty/eleventy-navigation"); const pluginRss = require("@11ty/eleventy-plugin-rss"); const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); -const pluginNavigation = require("@11ty/eleventy-navigation"); +const pluginAncestry = require("@tigersway/eleventy-plugin-ancestry"); +const metagen = require('eleventy-plugin-metagen'); const pluginTOC = require('eleventy-plugin-nesting-toc'); const markdownIt = require("markdown-it"); const markdownItAnchor = require("markdown-it-anchor"); -const markdownItPlantUML = require("assassin-custom-plantuml"); -const metagen = require('eleventy-plugin-metagen'); +const markdownItPlantUML = require("markdown-it-plantuml"); +const elasticlunr = require("elasticlunr"); module.exports = function(eleventyConfig) { + eleventyConfig.addPlugin(pluginNavigation); eleventyConfig.addPlugin(pluginRss); eleventyConfig.addPlugin(pluginSyntaxHighlight); - eleventyConfig.addPlugin(pluginNavigation); + eleventyConfig.addPlugin(pluginAncestry); eleventyConfig.addPlugin(metagen); eleventyConfig.addPlugin(pluginTOC, { tags: ['h1', 'h2', 'h3'] @@ -32,6 +35,12 @@ module.exports = function(eleventyConfig) { return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd'); }); + // Remove trailing # in automatic generated toc, because of + // anchors added at the end of the titles. + eleventyConfig.addFilter('stripHash', (toc) => { + return toc.replace(/ #\<\/a\>/g, ""); + }); + // Get the first `n` elements of a collection. eleventyConfig.addFilter("head", (array, n) => { if( n < 0 ) { @@ -41,17 +50,41 @@ module.exports = function(eleventyConfig) { return array.slice(0, n); }); + // Get the lowest in a list of numbers. eleventyConfig.addFilter("min", (...numbers) => { return Math.min.apply(null, numbers); }); + // Build a search index + eleventyConfig.addFilter("search", (collection) => { + // What fields we'd like our index to consist of + // TODO: remove html tags from content + var index = elasticlunr(function () { + this.addField("title"); + this.addField("content"); + this.setRef("id"); + }); + + // loop through each page and add it to the index + collection.forEach((page) => { + index.addDoc({ + id: page.url, + title: page.template.frontMatter.data.title, + content: page.template.inputContent, + }); + }); + + return index.toJSON(); + }); + eleventyConfig.addPassthroughCopy("img"); eleventyConfig.addPassthroughCopy("css"); + eleventyConfig.addPassthroughCopy("js"); /* Markdown Overrides */ let markdownLibrary = markdownIt({ html: true, - breaks: true, + breaks: false, linkify: true }).use(markdownItAnchor, { permalink: true, @@ -65,7 +98,7 @@ module.exports = function(eleventyConfig) { eleventyConfig.setBrowserSyncConfig({ callbacks: { ready: function(err, browserSync) { - const content_404 = fs.readFileSync('_site/404.html'); + const content_404 = fs.readFileSync('_dist/404.html'); browserSync.addMiddleware("*", (req, res) => { // Provides the 404 content without redirect. @@ -105,7 +138,7 @@ module.exports = function(eleventyConfig) { input: ".", includes: "_includes", data: "_data", - output: "_site" + output: "_dist" } }; }; diff --git a/.eleventyignore b/.eleventyignore index b43bf86..577d558 100644 --- a/.eleventyignore +++ b/.eleventyignore @@ -1 +1,2 @@ README.md +user-guide diff --git a/.gitignore b/.gitignore index 6704566..a0843b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Distribution files +_dist/* + # Logs logs *.log diff --git a/README.md b/README.md index cc6f740..9b9548c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ # penpot-docs -Website and documentation about Penpot +Penpot documentation website + +## Usage + +To view this site locally, first set up the environment: + +``` +nvm install (if necessary) +nvm use +npm install +``` + +And launch a development server: + +``` +npm start +``` + +You can then point a browser to [http://localhost:8081](http://localhost:8081). + + +## Tooling + +* [Eleventy (11ty)](https://www.11ty.dev/docs) +* [Diagrams](https://github.com/gmunguia/markdown-it-plantuml) with +[plantuml](https://plantuml.com). See also +[real-world-plantuml](https://real-world-plantuml.com). +* [Diagrams](https://github.com/agoose77/markdown-it-diagrams) with +[svgbob](https://github.com/ivanceras/svgbob) and +[mermaid](https://github.com/mermaid-js/mermaid). +* [arc42](https://arc42.org/overview) template. +* [c4model](https://c4model.com) for software architecture, and an +[implementation in plantuml](https://github.com/plantuml-stdlib/C4-PlantUML). + diff --git a/_data/metadata.json b/_data/metadata.json index a458a21..69eabe9 100755 --- a/_data/metadata.json +++ b/_data/metadata.json @@ -1,5 +1,5 @@ { - "title": "Penpot documentation site", + "title": "Help center", "url": "https://docs.penpot.app/", "description": "Design freedom for teams.", "feed": { diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk index 9492c5f..2a5df66 100644 --- a/_includes/layouts/base.njk +++ b/_includes/layouts/base.njk @@ -7,37 +7,113 @@ + + {% metagen title=title or metadata.title, desc=desc or metadata.desc, url=url + page.url, - img=image, + img="https://penpot.app/images/workspace-ui.jpg", img_alt=alt, twitterHandle=twitter or metadata.twitter, name=name %} + + +
-

{{ metadata.title }}

+ + + + + + + {{ metadata.title }} + + + +
{{ content | safe }} -