-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e16a4f0
commit 193177d
Showing
10 changed files
with
108 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { createSitemap } from './src/index'; | ||
|
||
createSitemap('https://example.com/', { debug: false, resetTime: true }); | ||
createSitemap({ domain: 'https://bartweb.cz', debug: false, resetTime: true, outDir: 'build' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { OptionsSvelteSitemap } from '../interfaces/global.interface'; | ||
import { OUT_DIR } from './../vars'; | ||
import { loadFile } from './file'; | ||
|
||
export const loadConfig = (path: string): OptionsSvelteSitemap => { | ||
const baseConfig = loadFile<OptionsSvelteSitemap>(path); | ||
return withDefaultConfig(baseConfig!); | ||
}; | ||
|
||
export const defaultConfig: OptionsSvelteSitemap = { | ||
debug: false, | ||
changeFreq: null, | ||
resetTime: false, | ||
outDir: OUT_DIR, | ||
attribution: true, | ||
ignore: null, | ||
trailingSlashes: false, | ||
domain: null | ||
}; | ||
|
||
export const updateConfig = ( | ||
currConfig: OptionsSvelteSitemap, | ||
newConfig: OptionsSvelteSitemap | ||
): OptionsSvelteSitemap => { | ||
return { ...currConfig, ...newConfig }; | ||
}; | ||
|
||
export const withDefaultConfig = (config: OptionsSvelteSitemap): OptionsSvelteSitemap => { | ||
return updateConfig(defaultConfig, config); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { existsSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { cliColors } from './vars.helper'; | ||
|
||
export const loadFile = <T>(fileName: string, throwError = true): T => { | ||
const filePath = resolve(resolve(process.cwd(), fileName)); | ||
|
||
if (existsSync(filePath)) { | ||
console.log(cliColors.cyanAndBold, `> Loading config from ${fileName}`); | ||
return require(filePath); | ||
} | ||
|
||
if (throwError) { | ||
new Error(`${filePath} does not exist.`); | ||
} | ||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import { Options } from './interfaces/global.interface'; | ||
|
||
export const APP_NAME = 'svelte-sitemap'; | ||
|
||
export const DOMAIN = 'https://example.com'; | ||
|
||
export const OPTIONS: Options = { resetTime: false, debug: false, changeFreq: 'weekly' }; | ||
|
||
export const OUT_DIR = 'build'; | ||
|
||
export const CONFIG_FILE = 'svelte-sitemap.js'; | ||
|
||
// export const OPTIONS: Options = { | ||
// domain: DOMAIN, | ||
// resetTime: false, | ||
// debug: false, | ||
// changeFreq: 'weekly' | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
domain: 'https://www.example.com', | ||
debug: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters