diff --git a/schematics/scully/src/create-markdown/index.ts b/schematics/scully/src/create-markdown/index.ts index adebd2e0b..56ec4f884 100644 --- a/schematics/scully/src/create-markdown/index.ts +++ b/schematics/scully/src/create-markdown/index.ts @@ -8,7 +8,7 @@ import { applyWithOverwrite, getPrefix, getSrc, - getFileContents, + getFileContents, toAscii, } from '../utils/utils'; import {RunSchematicTask} from '@angular-devkit/schematics/tasks'; @@ -16,8 +16,8 @@ const SCULLY_CONF_FILE = '/scully.config.js'; const ANGULAR_CONF_FILE = './angular.json'; export default (options: Schema): Rule => { - options.name = options.name || 'blog'; - options.slug = options.slug || 'id'; + options.name = toAscii(options.name) || 'blog'; + options.slug = toAscii(options.slug) || 'id'; options.sourceDir = options.sourceDir || options.name; return chain([ addPost(options, options.sourceDir), diff --git a/schematics/scully/src/utils/utils.ts b/schematics/scully/src/utils/utils.ts index 377e991cb..2338bdf9d 100644 --- a/schematics/scully/src/utils/utils.ts +++ b/schematics/scully/src/utils/utils.ts @@ -229,3 +229,17 @@ export const yamlToJson = (filePath: string) => { }; export const jsonToJaml = (metaData: {}) => yaml.safeDump(metaData); + + +export const toAscii = (src: string) => { + // tslint:disable-next-line:one-variable-per-declaration + let ch, str, i, result = ''; + str = JSON.stringify(src); + for (i = 1; i < str.length - 1; i++) { + ch = str.charCodeAt(i); + if (ch > 97) { + result += str.charAt(i); + } + } + return result; +};