add srt files
This commit is contained in:
35
.eleventy.js
35
.eleventy.js
@@ -3,6 +3,8 @@ const handlebars = require('handlebars');
|
||||
const sass = require("sass");
|
||||
const pluginRss = require("@11ty/eleventy-plugin-rss");
|
||||
const handlebarsHelpers = require('handlebars-helpers')
|
||||
const { parseSync } = require('subtitle')
|
||||
const path = require('path')
|
||||
|
||||
|
||||
const htmlmin = require("html-minifier");
|
||||
@@ -21,23 +23,36 @@ module.exports = function(eleventyConfig) {
|
||||
eleventyConfig.addPlugin(utilsPlugin, {immediate: true});
|
||||
eleventyConfig.addPlugin(handlebarsPlugin);
|
||||
eleventyConfig.addPlugin(pluginRss);
|
||||
|
||||
eleventyConfig.addTemplateFormats("srt");
|
||||
eleventyConfig.addExtension(
|
||||
"srt",
|
||||
{compile: (inputContent, inputPath)=>{
|
||||
const parsed = parseSync(inputContent.toString(), {type:'srt'})
|
||||
return async (data) => {
|
||||
data.transcript = parsed
|
||||
data.layout = "transcript"
|
||||
// data.tags = ['transcript']
|
||||
return JSON.stringify(parsed)
|
||||
}
|
||||
}})
|
||||
|
||||
|
||||
handlebarsHelpers({
|
||||
handlebars
|
||||
})
|
||||
|
||||
eleventyConfig.addTransform("htmlmin", (content, outputPath) => {
|
||||
if (outputPath.endsWith(".html")) {
|
||||
return htmlmin.minify(content, {
|
||||
collapseWhitespace: true,
|
||||
removeComments: true,
|
||||
useShortDoctype: true,
|
||||
});
|
||||
}
|
||||
// eleventyConfig.addTransform("htmlmin", (content, outputPath) => {
|
||||
// if (outputPath.endsWith(".html")) {
|
||||
// return htmlmin.minify(content, {
|
||||
// collapseWhitespace: true,
|
||||
// removeComments: true,
|
||||
// useShortDoctype: true,
|
||||
// });
|
||||
// }
|
||||
|
||||
return content;
|
||||
});
|
||||
// return content;
|
||||
// });
|
||||
|
||||
// Creates the extension for use
|
||||
eleventyConfig.addTemplateFormats("scss");
|
||||
|
||||
Reference in New Issue
Block a user