File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,16 +8,16 @@ import {
88 applyWithOverwrite ,
99 getPrefix ,
1010 getSrc ,
11- getFileContents ,
11+ getFileContents , toAscii ,
1212} from '../utils/utils' ;
1313import { RunSchematicTask } from '@angular-devkit/schematics/tasks' ;
1414
1515const SCULLY_CONF_FILE = '/scully.config.js' ;
1616const ANGULAR_CONF_FILE = './angular.json' ;
1717
1818export default ( options : Schema ) : Rule => {
19- options . name = options . name || 'blog' ;
20- options . slug = options . slug || 'id' ;
19+ options . name = toAscii ( options . name ) || 'blog' ;
20+ options . slug = toAscii ( options . slug ) || 'id' ;
2121 options . sourceDir = options . sourceDir || options . name ;
2222 return chain ( [
2323 addPost ( options , options . sourceDir ) ,
Original file line number Diff line number Diff line change @@ -229,3 +229,17 @@ export const yamlToJson = (filePath: string) => {
229229} ;
230230
231231export const jsonToJaml = ( metaData : { } ) => yaml . safeDump ( metaData ) ;
232+
233+
234+ export const toAscii = ( src : string ) => {
235+ // tslint:disable-next-line:one-variable-per-declaration
236+ let ch , str , i , result = '' ;
237+ str = JSON . stringify ( src ) ;
238+ for ( i = 1 ; i < str . length - 1 ; i ++ ) {
239+ ch = str . charCodeAt ( i ) ;
240+ if ( ch > 97 ) {
241+ result += str . charAt ( i ) ;
242+ }
243+ }
244+ return result ;
245+ } ;
You can’t perform that action at this time.
0 commit comments