2022-09-10 14:26:21 +05:00
|
|
|
const markdownIt = require("markdown-it")
|
|
|
|
const markdownItAnchor = require("markdown-it-anchor")
|
|
|
|
const markdownItReplaceLink = require('markdown-it-replace-link')
|
|
|
|
const slugify = require("slugify")
|
|
|
|
const uri = require('fast-uri')
|
|
|
|
|
2022-11-12 12:04:23 +00:00
|
|
|
const globalConfig = {
|
2022-11-12 12:08:37 +00:00
|
|
|
onionLocation: "http://isdb4l77sjqoy2qq7ipum6x3at6hyn3jmxfx4zdhc72ufbmuq4ilwkqd.onion",
|
2022-11-12 12:04:23 +00:00
|
|
|
siteLocation: "https://simplex.chat"
|
|
|
|
}
|
|
|
|
|
2022-09-10 14:26:21 +05:00
|
|
|
module.exports = function (ty) {
|
2022-11-12 12:04:23 +00:00
|
|
|
ty.addShortcode("cfg", (name) => globalConfig[name])
|
|
|
|
|
2022-09-10 14:26:21 +05:00
|
|
|
// Keeps the same directory structure.
|
|
|
|
ty.addPassthroughCopy("src/assets/")
|
2022-11-08 11:04:02 +00:00
|
|
|
ty.addPassthroughCopy("src/fonts")
|
2022-09-10 14:26:21 +05:00
|
|
|
ty.addPassthroughCopy("src/img")
|
2022-11-08 11:04:02 +00:00
|
|
|
ty.addPassthroughCopy("src/video")
|
2022-09-10 14:26:21 +05:00
|
|
|
ty.addPassthroughCopy("src/css")
|
|
|
|
ty.addPassthroughCopy("src/js")
|
2022-10-12 17:16:10 +01:00
|
|
|
ty.addPassthroughCopy("src/contact/*.js")
|
2022-09-25 11:16:28 +01:00
|
|
|
ty.addPassthroughCopy("src/call")
|
2022-10-24 21:00:35 +01:00
|
|
|
ty.addPassthroughCopy("src/hero-phone")
|
|
|
|
ty.addPassthroughCopy("src/hero-phone-dark")
|
2022-09-10 14:26:21 +05:00
|
|
|
ty.addPassthroughCopy("src/blog/images")
|
|
|
|
ty.addPassthroughCopy("src/images")
|
|
|
|
ty.addPassthroughCopy("src/CNAME")
|
2022-12-05 11:28:22 +00:00
|
|
|
ty.addPassthroughCopy("src/.well-known")
|
2022-09-10 14:26:21 +05:00
|
|
|
|
|
|
|
ty.addCollection('blogs', function (collection) {
|
|
|
|
return collection.getFilteredByGlob('src/blog/*.md').reverse()
|
|
|
|
})
|
|
|
|
|
|
|
|
ty.addWatchTarget("src/css")
|
|
|
|
ty.addWatchTarget("markdown/")
|
|
|
|
ty.addWatchTarget("components/Card.js")
|
|
|
|
|
|
|
|
const markdownLib = markdownIt({
|
|
|
|
html: true,
|
|
|
|
breaks: true,
|
|
|
|
linkify: true,
|
|
|
|
replaceLink: function (link, _env) {
|
|
|
|
let parsed = uri.parse(link)
|
|
|
|
if (parsed.scheme || parsed.host || !parsed.path.endsWith(".md")) {
|
|
|
|
return link
|
|
|
|
}
|
|
|
|
parsed.path = parsed.path.replace(/\.md$/, ".html")
|
|
|
|
return uri.serialize(parsed)
|
|
|
|
}
|
|
|
|
}).use(markdownItAnchor, {
|
|
|
|
slugify: (str) =>
|
|
|
|
slugify(str, {
|
|
|
|
lower: true,
|
|
|
|
strict: true,
|
|
|
|
})
|
|
|
|
}).use(markdownItReplaceLink)
|
|
|
|
|
|
|
|
// replace the default markdown-it instance
|
|
|
|
ty.setLibrary("md", markdownLib)
|
|
|
|
|
|
|
|
return {
|
|
|
|
dir: {
|
|
|
|
input: 'src',
|
|
|
|
includes: '_includes',
|
|
|
|
output: '_site',
|
|
|
|
},
|
|
|
|
templateFormats: ['md', 'njk', 'html'],
|
|
|
|
markdownTemplateEngine: 'njk',
|
|
|
|
htmlTemplateEngine: 'njk',
|
|
|
|
dataTemplateEngine: 'njk',
|
|
|
|
}
|
|
|
|
}
|