Repository: eslint/eslint
File: docs/.eleventy.js (JavaScript)

Code before:
    /**
     * Takes in a string and converts to a slug
     * @param {string} text text to be converted into slug
     * @returns {string} slug to be used as anchors
     */
    function slugify(text) {
        return slug(text.replace(/[<>()[\]{}]/gu, ""))
        /* eslint-disable no-control-regex, require-unicode-regexp -- used regex to replace */

        // Remove control characters
            .replace(/[\u0000-\u001F]/g, "")

        // replace special characters
            .replace(/[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g, "-")

        // remove continuos separators

            .replace(/-{2,}/g, "-")

        // remove prefixing and trailing separtors
            .replace(/^-+|-+$/g, "")

        /* eslint-enable no-control-regex, require-unicode-regexp -- end */

        // lowercase
            .toLowerCase();

    }

    eleventyConfig.addFilter("slugify", str => {
        if (!str) {
            return "";
        }

        return slugify(str);
    });

    eleventyConfig.addFilter("URIencode", str => {
        if (!str) {
            return "";
        }
        return encodeURI(str);
    });

    /* order collection by the order specified in the front matter */
    eleventyConfig.addFilter("sortByPageOrder", values => values.slice().sort((a, b) => a.data.order - b.data.order));

    eleventyConfig.addFilter("readableDate", dateObj => {

        // turn it into a JS Date string
        const date = new Date(dateObj);

Review comment (suggestion):
Would a simple `return slug(text);` work well for zh-hans docs? I just tried it here and didn't see any diff in `site/` so it looks like we could easily make that change.

Code after:
    eleventyConfig.addFilter("slugify", str => {
        if (!str) {
            return "";
        }

        return slug(str);
    });

    eleventyConfig.addFilter("URIencode", str => {
        if (!str) {
            return "";
        }
        return encodeURI(str);
    });

    /* order collection by the order specified in the front matter */
    eleventyConfig.addFilter("sortByPageOrder", values => values.slice().sort((a, b) => a.data.order - b.data.order));

    eleventyConfig.addFilter("readableDate", dateObj => {

        // turn it into a JS Date string
        const date = new Date(dateObj);

        // pass it to luxon for formatting
        return DateTime.fromJSDate(date).toFormat("dd MMM, yyyy");
    });

    eleventyConfig.addFilter("blogPermalinkDate", dateObj => {

        // turn it into a JS Date string
        const date = new Date(dateObj);

        // pass it to luxon for formatting
        return DateTime.fromJSDate(date).toFormat("yyyy/MM");
    });

    eleventyConfig.addFilter("readableDateFromISO", ISODate => DateTime.fromISO(ISODate).toUTC().toLocaleString(DateTime.DATE_FULL));

    eleventyConfig.addFilter("dollars", value => new Intl.NumberFormat("en-US", {
        style: "currency",
        currency: "USD"
    }).format(value));

    /*
     * parse markdown from includes, used for author bios
     * Source: https://github.com/11ty/eleventy/issues/658
     */
    eleventyConfig.addFilter("markdown", value => {
        const markdown = require("markdown-it")({
            html: true
        });