Add toot embedding
This commit is contained in:
@ -1,20 +1,21 @@
|
||||
const { DateTime } = require("luxon");
|
||||
const markdownIt = require("markdown-it");
|
||||
const markdownItFootnote = require("markdown-it-footnote");
|
||||
const markdownItAnchor = require("markdown-it-anchor");
|
||||
const mdfigcaption = require('markdown-it-image-figures');
|
||||
const pluginRss = require("@11ty/eleventy-plugin-rss");
|
||||
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
|
||||
const pluginBundle = require("@11ty/eleventy-plugin-bundle");
|
||||
const pluginNavigation = require("@11ty/eleventy-navigation");
|
||||
const prettier = require("prettier");
|
||||
const { EleventyHtmlBasePlugin } = require("@11ty/eleventy");
|
||||
import { DateTime } from "luxon";
|
||||
import markdownIt from "markdown-it";
|
||||
import markdownItFootnote from "markdown-it-footnote";
|
||||
import markdownItAnchor from "markdown-it-anchor";
|
||||
import mdfigcaption from 'markdown-it-image-figures';
|
||||
import pluginRss from "@11ty/eleventy-plugin-rss";
|
||||
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
|
||||
import pluginBundle from "@11ty/eleventy-plugin-bundle";
|
||||
import pluginNavigation from "@11ty/eleventy-navigation";
|
||||
import prettier from "prettier";
|
||||
import { EleventyHtmlBasePlugin } from "@11ty/eleventy";
|
||||
import {dateSuffixAdder, monthMap, timeFormatter} from "./public/js/modules/mastodonDateTools.js";
|
||||
|
||||
const figoptions = {
|
||||
figcaption: true
|
||||
};
|
||||
|
||||
module.exports = eleventyConfig => {
|
||||
export default async function(eleventyConfig) {
|
||||
|
||||
// Helper Functions
|
||||
const multiReplace = (text, replacementTable) => {
|
||||
@ -88,12 +89,38 @@ module.exports = eleventyConfig => {
|
||||
`;
|
||||
});
|
||||
|
||||
eleventyConfig.addAsyncShortcode("toot", async function(instance, ID) {
|
||||
const tootData = await fetch(
|
||||
`https://${instance}/api/v1/statuses/${ID}`
|
||||
);
|
||||
|
||||
const toot = await tootData.json();
|
||||
|
||||
const dateObj = new Date(toot.created_at);
|
||||
|
||||
const dateTime = `${dateObj.getDate()}${dateSuffixAdder(dateObj.getDate())} of ${monthMap[dateObj.getMonth()]}, ${dateObj.getFullYear()}, at ${timeFormatter(dateObj.getHours(), dateObj.getMinutes())}`;
|
||||
|
||||
return `
|
||||
<wc-toot
|
||||
author_name="${toot.account.display_name}"
|
||||
author_url="${toot.url.replace(/\/[0-9]+/, "")}"
|
||||
author_username="${toot.account.username}"
|
||||
avatar_url="${toot.account.avatar_static}"
|
||||
toot_content="${toot.content}"
|
||||
toot_url="${toot.url}"
|
||||
publish_date="${dateTime}"
|
||||
sharp_corner="">
|
||||
</wc-toot>
|
||||
`
|
||||
});
|
||||
|
||||
// Passthrough
|
||||
eleventyConfig.addPassthroughCopy({ 'public/xsl/*': "/xsl/" });
|
||||
eleventyConfig.addPassthroughCopy({ 'public/img/*': "/img/" });
|
||||
eleventyConfig.addPassthroughCopy({ 'public/robots.txt': "/" });
|
||||
eleventyConfig.addPassthroughCopy({ 'public/js/*': "/js/" });
|
||||
eleventyConfig.addPassthroughCopy({ 'public/js/webComponents/*': "/js/webComponents" });
|
||||
eleventyConfig.addPassthroughCopy({ 'public/js/modules/*': "/js/modules" });
|
||||
// Copying so that basic.xsl can use it
|
||||
eleventyConfig.addPassthroughCopy({ 'public/css/index.css': "/css/index.css" });
|
||||
eleventyConfig.addPassthroughCopy({ 'public/css/webfonts/*': "/css/webfonts/" });
|
||||
|
Reference in New Issue
Block a user