mirror of
https://github.com/umputun/reproxy.git
synced 2024-11-23 17:51:32 +03:00
ab9c5864bb
by @akellbl4 * make cool site for reproxy * remove meta tags with images * fix dark theme * flix styles for sidebar nav * add scroll in sidebar * fix dark theme * fix markdown * remove package lock * add package lock to ignore * add update date and edit button * add build command * move target to public * add build * use gitignore * add logos * Changes - add meta - add close button * add style for code tag * fix favicon color in safari * add logo styles * update favicon * add classic ico favicon * update touch icon * fix sharing images * fix logo * move data to site data file * add fancy mate glass effect on header * make readme as site base * update logo update logo * add stretching width for the content * add dockerfile * fix dark theme bugs * remove usless props * fix logo * fix node version * replce logo for the site * fix path to logo in readme * add more space on logo in readme * fix logo size in readme
90 lines
1.9 KiB
JavaScript
90 lines
1.9 KiB
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
const htmlmin = require('html-minifier')
|
|
const markdownIt = require('markdown-it')
|
|
const markdownItAnchor = require('markdown-it-anchor')
|
|
const toc = require('@thedigitalman/eleventy-plugin-toc-a11y')
|
|
const fns = require('date-fns')
|
|
|
|
function getVersion() {
|
|
return `reproxy-${Date.now()}`
|
|
}
|
|
|
|
function transformHTML(content, outputPath) {
|
|
if (!outputPath?.endsWith('.html')) {
|
|
return content
|
|
}
|
|
|
|
return htmlmin.minify(content, {
|
|
useShortDoctype: true,
|
|
removeComments: true,
|
|
collapseWhitespace: true,
|
|
})
|
|
}
|
|
|
|
function transformMarkdown() {
|
|
return markdownIt({
|
|
html: true,
|
|
breaks: true,
|
|
linkify: true,
|
|
}).use(markdownItAnchor, {
|
|
permalink: true,
|
|
permalinkClass: '',
|
|
permalinkSymbol: '',
|
|
})
|
|
}
|
|
|
|
function replaceLogo(content) {
|
|
const filepath = path.resolve(__dirname, './src/logo.svg')
|
|
const svg = fs.readFileSync(filepath, 'utf-8')
|
|
|
|
return content.replace(/<img class="logo"(.*?)>/gi, svg)
|
|
}
|
|
|
|
function getReadableDate(date) {
|
|
return fns.format(new Date(date), 'LLL dd, yyyy')
|
|
}
|
|
|
|
function getISODate(date) {
|
|
return fns.format(new Date(date), 'yyyy-mm-dd')
|
|
}
|
|
|
|
module.exports = (config) => {
|
|
config.addShortcode('version', getVersion)
|
|
|
|
// Pluigns
|
|
config.addPlugin(toc, {
|
|
tags: ['h2', 'h3'],
|
|
heading: false,
|
|
listType: 'ul',
|
|
wrapperClass: 'docs-nav',
|
|
listClass: 'pl-5',
|
|
listItemClass: 'mb-2',
|
|
listItemAnchorClass:
|
|
'inline-block p-1 hover:text-gray-900 dark:hover:text-gray-200',
|
|
})
|
|
|
|
// HTML transformations
|
|
config.addTransform('replaceLogo', replaceLogo)
|
|
config.addTransform('htmlmin', transformHTML)
|
|
// Date formaters
|
|
config.addFilter('humanizeDate', getReadableDate)
|
|
config.addFilter('isoDate', getISODate)
|
|
|
|
// Markdown
|
|
config.setLibrary('md', transformMarkdown())
|
|
|
|
// Other files
|
|
config.addPassthroughCopy({ 'src/public/*': '.' })
|
|
|
|
return {
|
|
dir: {
|
|
input: 'src',
|
|
output: 'public',
|
|
data: 'data',
|
|
layouts: 'layouts',
|
|
includes: 'includes',
|
|
},
|
|
}
|
|
}
|