Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data curation exploration #145

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 51 additions & 10 deletions federalist-eleventy.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,60 @@
const yaml = require('js-yaml');
/* CONSTANTS */
const baseUrl = process.env.BASEURL;

module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(require('/tmp/work/site_repo/.eleventy.js'));

// eleventyConfig.addDataExtension('yaml', (contents) => yaml.load(contents));

// eleventyConfig.addPassthroughCopy('assets/img');
// eleventyConfig.addPassthroughCopy('robots.txt');
/* MODULES */
const yaml = require('js-yaml');
const pluginRss = require("@11ty/eleventy-plugin-rss");
const md = require('markdown-it')({
html: false,
breaks: true,
linkify: true,
});

/* FILTERS */
const hashCode = function (s) {
var hash = 0,
i,
chr;
if (s.length === 0) return hash;
for (i = 0; i < s.length; i++) {
chr = s.charCodeAt(i);
hash = (hash << 5) - hash + chr;
hash |= 0;
}
return (hash >>> 0).toString(16);
};

module.exports = function (eleventyConfig) {
/* GLOBAL DATA */
eleventyConfig.addGlobalData("baseUrl", baseUrl);
/* PASSTHROUGH COPIES */
eleventyConfig.addPassthroughCopy('assets');
eleventyConfig.addPassthroughCopy('favicon.ico');
eleventyConfig.addPassthroughCopy('robots.txt');
/* DATA EXTENSIONS */
eleventyConfig.addDataExtension('yaml', (contents) => yaml.load(contents));
/* PLUGINS */
eleventyConfig.addPlugin(pluginRss);
/* FILTERS */
eleventyConfig.addFilter('hashcode', (s) => hashCode(s));
eleventyConfig.addFilter('markdown', (markdownString) =>
md.render(markdownString)
);
eleventyConfig.addFilter("absoluteUrl", function (url, base = eleventyConfig.globalData.baseUrl) {
try {
return new URL(url, base).href;
} catch (err) {
console.error(err);
return url;
}
});
eleventyConfig.addLiquidFilter("dateToRfc3339", pluginRss.dateToRfc3339);
eleventyConfig.addLiquidFilter("dateToRfc822", pluginRss.dateToRfc822);

return {
markdownTemplateEngine: "njk",
pathPrefix: baseUrl,
markdownTemplateEngine: 'njk',
dir: {
pathPrefix: baseUrl,
input: 'src',
includes: '_includes',
data: '_data',
Expand Down
28 changes: 24 additions & 4 deletions .eleventy.js → local-eleventy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
const yaml = require('js-yaml');
/* CONSTANTS */
const baseUrl = "http://localhost:8080";

const pluginRss = require('@11ty/eleventy-plugin-rss');
/* MODULES */
const yaml = require('js-yaml');
const pluginRss = require("@11ty/eleventy-plugin-rss");
const md = require('markdown-it')({
html: false,
breaks: true,
linkify: true,
});

/* FILTERS */
const hashCode = function (s) {
var hash = 0,
i,
Expand All @@ -21,20 +25,36 @@ const hashCode = function (s) {
};

module.exports = function (eleventyConfig) {
eleventyConfig.addDataExtension('yaml', (contents) => yaml.load(contents));
/* GLOBAL DATA */
eleventyConfig.addGlobalData("baseUrl", baseUrl);
/* PASSTHROUGH COPIES */
eleventyConfig.addPassthroughCopy('assets');
eleventyConfig.addPassthroughCopy('favicon.ico');
eleventyConfig.addPassthroughCopy('robots.txt');

/* DATA EXTENSIONS */
eleventyConfig.addDataExtension('yaml', (contents) => yaml.load(contents));
/* PLUGINS */
eleventyConfig.addPlugin(pluginRss);
/* FILTERS */
eleventyConfig.addFilter('hashcode', (s) => hashCode(s));
eleventyConfig.addFilter('markdown', (markdownString) =>
md.render(markdownString)
);
eleventyConfig.addFilter("absoluteUrl", function (url, base = eleventyConfig.globalData.baseUrl) {
try {
return new URL(url, base).href;
} catch (err) {
console.error(err);
return url;
}
});
eleventyConfig.addLiquidFilter("dateToRfc3339", pluginRss.dateToRfc3339);
eleventyConfig.addLiquidFilter("dateToRfc822", pluginRss.dateToRfc822);

return {
markdownTemplateEngine: 'njk',
dir: {
pathPrefix: baseUrl,
input: 'src',
includes: '_includes',
data: '_data',
Expand Down
Loading