Skip to content

Commit

Permalink
Merge pull request #67 from infinitymdm/main
Browse files Browse the repository at this point in the history
Misc. Polishing
  • Loading branch information
infinitymdm authored Aug 12, 2023
2 parents a953b70 + 4a7ba2a commit 2c7e5bc
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 52 deletions.
98 changes: 53 additions & 45 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,57 @@
const { nunjucks } = require("nunjucks");

module.exports = function(eleventyConfig) {
const markdownIt = require('markdown-it')
const markdownItAttrs = require('markdown-it-attrs')
const markdownItOptions = {
html: true,
breaks: true,
linkify: true
}
eleventyConfig.addTemplateFormats('svg');
eleventyConfig.addExtension('svg', {
outputFileExtension: 'svg',
key: 'html'
/*compile: async (inputContent) => {
let output = nunjucks.renderString(inputContent)
return async () => {
return output;
};
}*/
});
const markdownLib = markdownIt(markdownItOptions).use(markdownItAttrs)

eleventyConfig.addPassthroughCopy('halfmoonui');
eleventyConfig.addPassthroughCopy('jsonpath-0.8.0.js');
eleventyConfig.addPassthroughCopy('custom-variables.css');

eleventyConfig.addPassthroughCopy('character-sheets/*.pdf');

eleventyConfig.addPassthroughCopy({'_data/parts.json': 'mechdb/parts.json'});
eleventyConfig.addPassthroughCopy({'_data/planets.json': 'lore/planets.json'});

eleventyConfig.addPassthroughCopy('images/*.svg');
eleventyConfig.addPassthroughCopy('images/planets/*.svg');

eleventyConfig.setNunjucksEnvironmentOptions({
throwOnUndefined: true
});
eleventyConfig.setLibrary('md', markdownLib);
eleventyConfig.addShortcode('keyword', function(word, glossary) {
return '<b class="keyword" onclick="halfmoon.initStickyAlert({content: \'' + glossary[word] + '\', title: \'' + word + '\', hasDismissButton: true, timeShown: 5000});">' + word + '</b>'
});
eleventyConfig.addFilter('getObjectsByAttribute', function(objects, attribute, value) {
return objects.filter((obj) => obj[attribute] == value);
});
return {
htmlTemplateEngine: 'njk'
}
// Configure markdown-it plugins
const markdownIt = require('markdown-it')
const markdownItAnchor = require('markdown-it-anchor')
const markdownItAttrs = require('markdown-it-attrs')
const markdownItOptions = {
html: true,
breaks: true,
linkify: true
}
const mdLib = markdownIt(markdownItOptions).use(markdownItAttrs).use(markdownItAnchor)
eleventyConfig.setLibrary('md', mdLib);

// Enable SVG templating
eleventyConfig.addTemplateFormats('svg');
eleventyConfig.addExtension('svg', {
outputFileExtension: 'svg',
key: 'html'
});

// Export css and js artifacts
eleventyConfig.addPassthroughCopy('halfmoonui');
eleventyConfig.addPassthroughCopy('jsonpath-0.8.0.js');
eleventyConfig.addPassthroughCopy('custom-variables.css');

// Export character sheets
eleventyConfig.addPassthroughCopy('character-sheets/*.pdf');

// Export MechDB artifacts
eleventyConfig.addPassthroughCopy({'_data/parts.json': 'mechdb/parts.json'});
eleventyConfig.addPassthroughCopy({'_data/planets.json': 'lore/planets.json'});

// Export images
eleventyConfig.addPassthroughCopy('images/*.svg');
eleventyConfig.addPassthroughCopy('images/planets/*.svg');

// ???
eleventyConfig.setNunjucksEnvironmentOptions({
throwOnUndefined: true
});

// Custom shortcodes
eleventyConfig.addShortcode('keyword', function(word, glossary) {
return '<b class="keyword" onclick="halfmoon.initStickyAlert({content: \'' + glossary[word] + '\', title: \'' + word + '\', hasDismissButton: true, timeShown: 5000});">' + word + '</b>'
});

// Custom filters
eleventyConfig.addFilter('getObjectsByAttribute', function(objects, attribute, value) {
return objects.filter((obj) => obj[attribute] == value);
});

return {
htmlTemplateEngine: 'njk'
}
};
2 changes: 1 addition & 1 deletion _data/navlinks.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"Mech Building" :
{
"Overview": "/rules/build-overview/",
"Components": "/rules/component-details/",
"Components": "/rules/component-types/",
"Planning": "/rules/build-planning/",
"Placing Components": "/rules/placing-components/",
"Calculations": "/rules/build-calculations/",
Expand Down
9 changes: 8 additions & 1 deletion custom-variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ body {

.keyword {
font-family: 'Inconsolata', monospace;
cursor: pointer;
color: #f478ff;
}

Expand All @@ -89,4 +90,10 @@ ul, ol {

li {
list-style-position: outside;
}
}

blockquote > p {
padding-left: 1rem;
border-left: 2px solid var(--dark-color);
background-color: var(--gray-color-light);
}
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default: serve

# Install dependencies
setup:
npm i @11ty/eleventy markdown-it markdown-it-attrs
npm i @11ty/eleventy markdown-it markdown-it-attrs markdown-it-anchor

build: clean setup
#!/usr/bin/env bash
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"dependencies": {
"@11ty/eleventy": "^2.0.1",
"markdown-it": "^13.0.1",
"markdown-it-anchor": "^8.6.7",
"markdown-it-attrs": "^4.1.6"
}
}
10 changes: 6 additions & 4 deletions rules/mech-building/components.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
---
layout: template.njk
title: Components
permalink: /rules/component-details/
title: Component Types
permalink: /rules/component-types/
tags: rules_page
---
<!-- The goal of this page is to provide a detailed reference for component information -->
## Components
A mech is exactly the sum of its parts. This page explains the details and stats of different mech {% keyword 'Parts' glossary %} and {% keyword 'Components' glossary %}, grouped by {% keyword 'Part Type' glossary %}.
## Component Types
A mech is exactly the sum of its {% keyword 'Parts' glossary %}. This page explains the different {% keyword 'Part Type' glossary %}s as well as what their accompanying stats and traits represent.

> Looking for somewhere to view component stats? Check out [MechDB]({{site.url}}/mechdb/viewer)!
<!-- TODO: Table of Contents -->

Expand Down

0 comments on commit 2c7e5bc

Please sign in to comment.