astro-pure 1.3.9 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,22 +27,19 @@ const { selector = config.integ.mediumZoom.selector, background = 'hsl(var(--bac
27
27
  will-change: opacity;
28
28
  }
29
29
  .medium-zoom--opened .medium-zoom-overlay {
30
- cursor: pointer;
31
30
  cursor: zoom-out;
32
31
  opacity: 1;
33
32
  z-index: 999;
34
33
  }
35
34
  .medium-zoom-image {
36
- cursor: pointer;
37
35
  cursor: zoom-in;
38
- transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) !important;
36
+ transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
39
37
  }
40
38
  .medium-zoom-image--hidden {
41
39
  visibility: hidden;
42
40
  }
43
41
  .medium-zoom-image--opened {
44
42
  position: relative;
45
- cursor: pointer;
46
43
  cursor: zoom-out;
47
44
  will-change: transform;
48
45
  z-index: 999;
@@ -22,10 +22,6 @@ const { class: className } = Astro.props
22
22
  const { quote } = config.integ
23
23
 
24
24
  class Quote extends HTMLElement {
25
- constructor() {
26
- super()
27
- }
28
-
29
25
  render(sentence: string) {
30
26
  const quoteEl = this.querySelector('#quote-sentence') as HTMLElement
31
27
  if (!quoteEl) return
@@ -34,7 +30,7 @@ const { class: className } = Astro.props
34
30
 
35
31
  connectedCallback() {
36
32
  // Because virtual:config can only be accessed using json string, function cannot work, so we need to use new Function
37
- const targetFunction = new Function('data', 'return (' + quote.target + ')(data)')
33
+ const targetFunction = new Function('data', `return (${quote.target})(data)`)
38
34
  fetch(quote.server)
39
35
  .then((response) => response.json())
40
36
  .then((data) => this.render(targetFunction(data)))
@@ -7,10 +7,11 @@ const footerConf = config.footer
7
7
  let social = footerConf.social || {}
8
8
 
9
9
  // If the list does not contain rss, add it
10
- social.rss = {
11
- label: 'RSS',
12
- url: '/rss.xml'
13
- }
10
+ if (!social.rss)
11
+ social.rss = {
12
+ label: 'RSS',
13
+ url: '/rss.xml'
14
+ }
14
15
 
15
16
  const footerLink1 = footerConf.links?.filter(({ pos }) => pos === 1) || []
16
17
  ---
@@ -18,20 +19,16 @@ const footerLink1 = footerConf.links?.filter(({ pos }) => pos === 1) || []
18
19
  <footer class='mx-auto mb-5 mt-16 w-full'>
19
20
  <div class='border-t pt-5'>
20
21
  <div class='flex items-center gap-y-3 max-sm:flex-col sm:justify-between sm:gap-y-0'>
21
- <div
22
- class='flex items-center gap-x-4 gap-y-2 text-muted-foreground max-sm:flex-col [&_a]:text-foreground'
23
- >
24
- {/* Position 1 */}
25
- {
22
+ <div class='flex items-center gap-x-4 gap-y-2 text-muted-foreground max-sm:flex-col'>
23
+ { /* Position 1 */
26
24
  footerLink1.length > 0 && (
27
25
  <div>
28
26
  {footerLink1.map(({ title, link, style }, index) => (
29
- <span>
30
- <a href={link} target='_blank' class={style}>
31
- {title}
32
- </a>
33
- {index < footerLink1.length - 1 && ' • '}
34
- </span>
27
+ <>
28
+ <!- prettier-ignore -->
29
+ <a href={link} target='_blank' class={style}>{title}</a>
30
+ {index < footerLink1.length - 1 && <span class='mx-1'>•</span>}
31
+ </>
35
32
  ))}
36
33
  </div>
37
34
  )
@@ -49,9 +46,7 @@ const footerLink1 = footerConf.links?.filter(({ pos }) => pos === 1) || []
49
46
  .filter(({ pos }) => pos === 2)
50
47
  .map(({ title, link, style }) => (
51
48
  <span>
52
- <a href={link} target='_blank' class={style}>
53
- {title}
54
- </a>
49
+ <a href={link} target='_blank' class={style}>{title}</a>
55
50
  </span>
56
51
  ))}
57
52
  </span>
@@ -62,13 +57,9 @@ const footerLink1 = footerConf.links?.filter(({ pos }) => pos === 1) || []
62
57
  {
63
58
  footerConf.credits && (
64
59
  <span>
65
- <a href='https://github.com/withastro/astro' target='_blank'>
66
- Astro
67
- </a>
60
+ <a href='https://github.com/withastro/astro' target='_blank'>Astro</a>
68
61
  &
69
- <a href='https://github.com/cworld1/astro-theme-pure' target='_blank'>
70
- Pure
71
- </a>
62
+ <a href='https://github.com/cworld1/astro-theme-pure' target='_blank'>Pure</a>
72
63
  theme powered
73
64
  </span>
74
65
  )
@@ -80,11 +71,7 @@ const footerLink1 = footerConf.links?.filter(({ pos }) => pos === 1) || []
80
71
  {
81
72
  footerConf.social &&
82
73
  Object.entries(footerConf.social).map(([platform, { label, url }]) => (
83
- <a
84
- class='inline-block text-muted-foreground transition-all hover:text-muted-foreground/75'
85
- href={url}
86
- aria-label={label}
87
- >
74
+ <a href={url} aria-label={label}>
88
75
  <Icon name={platform as keyof typeof footerConf.social} />
89
76
  </a>
90
77
  ))
@@ -93,3 +80,11 @@ const footerLink1 = footerConf.links?.filter(({ pos }) => pos === 1) || []
93
80
  </div>
94
81
  </div>
95
82
  </footer>
83
+
84
+ <style>
85
+ footer a {
86
+ color: hsl(var(--foreground) / var(--un-text-opacity, 1));
87
+ text-decoration: underline;
88
+ font-weight: 500;
89
+ }
90
+ </style>
@@ -74,10 +74,6 @@ import { Icon } from '../user'
74
74
  import { setTheme, showToast } from '../../utils'
75
75
 
76
76
  class HeaderComponent extends HTMLElement {
77
- constructor() {
78
- super()
79
- }
80
-
81
77
  connectedCallback() {
82
78
  // Header
83
79
  let preScrollY = window.scrollY
@@ -39,10 +39,6 @@ const { header: headerName, content: contentName, needPercent = true } = Astro.p
39
39
  ticking = false
40
40
  needPercent = true
41
41
 
42
- constructor() {
43
- super()
44
- }
45
-
46
42
  calculateScrollPercent() {
47
43
  const scrollTop = Math.max(0, window.scrollY || document.documentElement.scrollTop)
48
44
  // Before article
@@ -1,5 +1,6 @@
1
1
  ---
2
2
  import type { CollectionKey, InferEntrySchema } from 'astro:content'
3
+
3
4
  import config from 'virtual:config'
4
5
 
5
6
  import { cn, getFormattedDate } from '../../utils'
@@ -34,7 +34,7 @@ import '@pagefind/default-ui/css/ui.css'
34
34
  new PagefindUI({
35
35
  element: '#site-search',
36
36
  baseUrl: import.meta.env.BASE_URL,
37
- bundlePath: import.meta.env.BASE_URL.replace(/\/$/, '') + '/pagefind/',
37
+ bundlePath: `${import.meta.env.BASE_URL.replace(/\/$/, '')}/pagefind/`,
38
38
  showImages: false,
39
39
  showSubResults: true,
40
40
  processResult: (result: { url: string; sub_results: Array<{ url: string }> }) => {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  import { Image } from 'astro:assets'
3
- import { render, type CollectionEntry, type CollectionKey } from 'astro:content'
3
+ import { type CollectionEntry, type CollectionKey, render } from 'astro:content'
4
4
 
5
5
  import { cn } from '../../utils'
6
6
  import { Button, FormattedDate, Icon } from '../user'
@@ -104,7 +104,7 @@ const postDate = data.updatedDate ?? data.publishDate
104
104
  )}
105
105
  </div>
106
106
  {data.tags.length > 0 && (
107
- <object>
107
+ <object title='Tags' aria-label='Tags' aria-labelledby='Tags'>
108
108
  <ul class='tag-list mt-1 flex gap-2'>
109
109
  {data.tags.map((tag: string) => (
110
110
  <li>
@@ -122,18 +122,13 @@ const postDate = data.updatedDate ?? data.publishDate
122
122
 
123
123
  <style>
124
124
  .post-preview {
125
- --preview-highlight-final: var(
126
- --preview-highlight,
127
- hsl(var(--primary) / var(--un-text-opacity, 1))
125
+ --preview-highlight-final: var( --preview-highlight, hsl(var(--primary) / var(--un-text-opacity, 1))
128
126
  );
129
127
  }
130
128
  .post-preview:hover {
131
129
  & > a,
132
130
  & .tag-list a {
133
- background-color: var(
134
- --preview-highlight-bg,
135
- hsl(var(--muted) / var(--un-bg-opacity, 1))
136
- ) !important;
131
+ background-color: var( --preview-highlight-bg, hsl(var(--muted) / var(--un-bg-opacity, 1))) !important;
137
132
  }
138
133
  & > a,
139
134
  & .tag-list a:hover {
@@ -145,23 +140,11 @@ const postDate = data.updatedDate ?? data.publishDate
145
140
  }
146
141
  .cover-image {
147
142
  mask-image: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%);
148
- -ms-mask-image: -ms-linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%);
149
- -webkit-mask-image: -webkit-linear-gradient(
150
- to right,
151
- rgba(0, 0, 0, 0) 0%,
152
- rgba(0, 0, 0, 1) 100%
153
- );
154
143
  }
155
144
 
156
145
  @media (max-width: 768px) {
157
146
  .cover-image {
158
147
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%);
159
- -ms-mask-image: -ms-linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%);
160
- -webkit-mask-image: -webkit-linear-gradient(
161
- to top,
162
- rgba(0, 0, 0, 0) 0%,
163
- rgba(0, 0, 0, 1) 100%
164
- );
165
148
  }
166
149
  }
167
150
  </style>
@@ -83,15 +83,15 @@ const toc = generateToc(headings)
83
83
  el.classList.toggle('highlight-bg-translucent', inView)
84
84
  el.classList.toggle(
85
85
  'rounded-t-2xl',
86
- inView && (i == 0 || !this.headingProgress[this.tocLinks[i - 1]?.slug].inView)
86
+ inView && (i === 0 || !this.headingProgress[this.tocLinks[i - 1]?.slug].inView)
87
87
  )
88
88
  el.classList.toggle(
89
89
  'rounded-b-2xl',
90
90
  inView &&
91
- (i == this.tocLinks.length - 1 ||
91
+ (i === this.tocLinks.length - 1 ||
92
92
  !this.headingProgress[this.tocLinks[i + 1]?.slug].inView)
93
93
  )
94
- bar.classList.toggle('is-read', !inView && progress == 1)
94
+ bar.classList.toggle('is-read', !inView && progress === 1)
95
95
  bar.classList.toggle('highlight-bg', inView)
96
96
  bar.style.setProperty('height', `${progress * 90}%`)
97
97
  }
@@ -32,8 +32,9 @@ const isSynced = syncKey !== undefined
32
32
  const didRenderSyncedTabsRestoreScriptSymbol = Symbol.for(
33
33
  'starlight:did-render-synced-tabs-restore-script'
34
34
  )
35
- // @ts-expect-error - See bove
36
- const shouldRenderSyncedTabsRestoreScript = isSynced && Astro.locals[didRenderSyncedTabsRestoreScriptSymbol] !== true
35
+ const shouldRenderSyncedTabsRestoreScript =
36
+ // @ts-expect-error - See above
37
+ isSynced && Astro.locals[didRenderSyncedTabsRestoreScriptSymbol] !== true
37
38
 
38
39
  if (isSynced) {
39
40
  // @ts-expect-error - See above
@@ -41,8 +42,8 @@ if (isSynced) {
41
42
  }
42
43
  ---
43
44
 
44
- {/* Inlined to avoid a flash of invalid active tab. */}
45
- {shouldRenderSyncedTabsRestoreScript && (
45
+ { /* Inlined to avoid a flash of invalid active tab. */
46
+ shouldRenderSyncedTabsRestoreScript && (
46
47
  <script is:inline>
47
48
  class StarlightTabsRestore extends HTMLElement {
48
49
  connectedCallback() {
@@ -81,6 +82,7 @@ if (isSynced) {
81
82
  <li role='presentation' class='tab'>
82
83
  <a
83
84
  role='tab'
85
+ draggable="false"
84
86
  href={'#' + panelId}
85
87
  id={tabId}
86
88
  aria-selected={idx === 0 ? 'true' : 'false'}
@@ -127,6 +129,7 @@ if (isSynced) {
127
129
  color: hsl(var(--foreground) / var(--un-text-opacity, 1));
128
130
  outline-offset: -0.1875rem;
129
131
  overflow-wrap: initial;
132
+ white-space: nowrap;
130
133
  }
131
134
  .tab [role='tab'][aria-selected='true'] {
132
135
  color: hsl(var(--primary) / var(--un-text-opacity, 1));
package/index.ts CHANGED
@@ -3,6 +3,7 @@ import { dirname, relative } from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
4
  // Astro
5
5
  import type { AstroIntegration, RehypePlugins, RemarkPlugins } from 'astro'
6
+ import { AstroError } from 'astro/errors'
6
7
  // Integrations
7
8
  import mdx from '@astrojs/mdx'
8
9
  import sitemap from '@astrojs/sitemap'
@@ -16,15 +17,20 @@ import { UserConfigSchema, type UserInputConfig } from './types/user-config'
16
17
  import { parseWithFriendlyErrors } from './utils/error-map'
17
18
 
18
19
  export default function AstroPureIntegration(opts: UserInputConfig): AstroIntegration {
19
- let integrations: AstroIntegration[] = []
20
- let remarkPlugins: RemarkPlugins = []
21
- let rehypePlugins: RehypePlugins = []
20
+ if (typeof opts !== 'object' || opts === null || Array.isArray(opts))
21
+ throw new AstroError(
22
+ 'Invalid config passed to astro-pure integration',
23
+ 'The astro-pure integration expects a right configuration object with at least a `title` property.\n\n'
24
+ )
25
+ const integrations: AstroIntegration[] = []
26
+ const remarkPlugins: RemarkPlugins = []
27
+ const rehypePlugins: RehypePlugins = []
28
+
22
29
  return {
23
30
  name: 'astro-pure',
24
31
  hooks: {
25
32
  'astro:config:setup': async ({ config, updateConfig }) => {
26
- let userConfig = parseWithFriendlyErrors(
27
- // @ts-ignore
33
+ const userConfig = parseWithFriendlyErrors(
28
34
  UserConfigSchema,
29
35
  opts,
30
36
  'Invalid config passed to astro-pure integration'
@@ -52,14 +58,13 @@ export default function AstroPureIntegration(opts: UserInputConfig): AstroIntegr
52
58
  rehypePlugins.push([
53
59
  rehypeExternalLinks,
54
60
  {
55
- content: {
56
- type: 'text',
57
- value: userConfig.content.externalLinks.content
58
- },
61
+ content: { type: 'text', value: userConfig.content.externalLinks.content },
59
62
  contentProperties: userConfig.content.externalLinks.properties
60
63
  }
61
64
  ])
65
+ // Make table scrollable on overflow
62
66
  rehypePlugins.push(rehypeTable)
67
+
63
68
  // Add Starlight directives restoration integration at the end of the list so that remark
64
69
  // plugins injected by Starlight plugins through Astro integrations can handle text and
65
70
  // leaf directives before they are transformed back to their original form.
@@ -72,6 +77,7 @@ export default function AstroPureIntegration(opts: UserInputConfig): AstroIntegr
72
77
 
73
78
  updateConfig({
74
79
  vite: {
80
+ // biome-ignore lint/suspicious/noTsIgnore: expects error for local, but expects no error when build
75
81
  // @ts-ignore
76
82
  plugins: [vitePluginUserConfig(userConfig, config)]
77
83
  },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "astro-pure",
3
3
  "type": "module",
4
4
  "description": "A simple, clean but powerful blog theme build by astro.",
5
- "version": "1.3.9",
5
+ "version": "1.4.1",
6
6
  "homepage": "https://astro-pure.js.org/",
7
7
  "author": "CWorld",
8
8
  "license": "Apache-2.0",
@@ -37,11 +37,11 @@
37
37
  "./libs": "./libs/index.ts"
38
38
  },
39
39
  "dependencies": {
40
- "@astrojs/mdx": "^4.3.12",
40
+ "@astrojs/mdx": "^4.3.13",
41
41
  "@astrojs/sitemap": "^3.6.0",
42
42
  "@pagefind/default-ui": "^1.4.0",
43
43
  "@unocss/reset": "^66.5.10",
44
- "astro": "^5.16.3",
44
+ "astro": "^5.16.6",
45
45
  "hast-util-select": "^6.0.4",
46
46
  "node-html-parser": "^7.0.1",
47
47
  "pagefind": "^1.4.0",
@@ -1,6 +1,6 @@
1
1
  /// <reference types="astro/astro-jsx" />
2
2
 
3
- import { parse, render, type DocumentNode, type Node } from 'ultrahtml'
3
+ import { type DocumentNode, type Node, parse, render } from 'ultrahtml'
4
4
 
5
5
  export type SVGAttributes = Omit<
6
6
  astroHTML.JSX.SVGAttributes,
@@ -41,15 +41,10 @@ const stepsProcessor = rehype()
41
41
  }
42
42
 
43
43
  // Ensure `role="list"` is set on the ordered list.
44
-
45
44
  // We use `list-style: none` in the styles for this component and need to ensure the list
46
-
47
45
  // retains its semantics in Safari, which will remove them otherwise.
48
-
49
46
  rootElement.properties.role = 'list'
50
-
51
47
  // Add the required CSS class name, preserving existing classes if present.
52
-
53
48
  if (!Array.isArray(rootElement.properties.className)) {
54
49
  rootElement.properties.className = ['sl-steps']
55
50
  } else {
@@ -57,30 +52,21 @@ const stepsProcessor = rehype()
57
52
  }
58
53
 
59
54
  // Add the `start` attribute as a CSS custom property so we can use it as the starting index
60
-
61
55
  // of the steps custom counter.
62
-
63
56
  if (typeof rootElement.properties.start === 'number') {
64
57
  const styles = [`--sl-steps-start: ${rootElement.properties.start - 1}`]
65
-
66
58
  if (rootElement.properties.style) styles.push(String(rootElement.properties.style))
67
-
68
59
  rootElement.properties.style = styles.join(';')
69
60
  }
70
61
  }
71
62
  })
72
63
 
73
64
  /**
74
-
75
65
  * Process steps children: validates the HTML and adds `role="list"` to the ordered list.
76
-
77
66
  * @param html Inner HTML passed to the `<Steps>` component.
78
-
79
67
  */
80
-
81
68
  export const processSteps = (html: string | undefined) => {
82
69
  const file = stepsProcessor.processSync({ value: html })
83
-
84
70
  return { html: file.toString() }
85
71
  }
86
72
 
@@ -88,11 +74,9 @@ class StepsError extends AstroError {
88
74
  constructor(message: string, html?: string) {
89
75
  let hint =
90
76
  'To learn more about the `<Steps>` component, see https://starlight.astro.build/components/steps/'
91
-
92
77
  if (html) {
93
- hint += '\n\nFull HTML passed to `<Steps>`:\n' + prettyPrintHtml(html)
78
+ hint += `\n\nFull HTML passed to \`<Steps>\`:\n${prettyPrintHtml(html)}`
94
79
  }
95
-
96
80
  super(message, hint)
97
81
  }
98
82
  }
@@ -40,7 +40,7 @@ const focusableElementSelectors = [
40
40
  let count = 0
41
41
  const getIDs = () => {
42
42
  const id = count++
43
- return { panelId: 'tab-panel-' + id, tabId: 'tab-' + id }
43
+ return { panelId: `tab-panel-${id}`, tabId: `tab-${id}` }
44
44
  }
45
45
 
46
46
  /**
@@ -6,25 +6,23 @@ import { visit } from 'unist-util-visit'
6
6
  import mdastToString from '../utils/mdast-util-to-string'
7
7
  import getReadingTime from '../utils/reading-time'
8
8
 
9
- export const remarkAddZoomable: Plugin<[{ className?: string }], Root> = function ({
10
- className = 'zoomable'
11
- }) {
12
- return function (tree) {
9
+ export const remarkAddZoomable: Plugin<[{ className?: string }], Root> =
10
+ ({ className = 'zoomable' }) =>
11
+ (tree) => {
13
12
  visit(tree, 'image', (node: Node) => {
14
13
  node.data = { hProperties: { class: className } }
15
14
  })
16
15
  }
17
- }
18
16
 
19
- export const remarkReadingTime: Plugin<[], Root> = function () {
20
- return function (tree, { data }) {
17
+ export const remarkReadingTime: Plugin<[], Root> =
18
+ () =>
19
+ (tree, { data }) => {
21
20
  const textOnPage = mdastToString(tree)
22
21
  const readingTime = getReadingTime(textOnPage)
23
22
  // readingTime.text will give us minutes read as a friendly string,
24
23
  // i.e. "3 min"
25
- if (data.astro && data.astro.frontmatter) {
24
+ if (data.astro?.frontmatter) {
26
25
  data.astro.frontmatter.minutesRead = readingTime.text
27
26
  data.astro.frontmatter.words = readingTime.words
28
27
  }
29
28
  }
30
- }
@@ -88,10 +88,10 @@ export function vitePluginUserConfig(
88
88
 
89
89
  return {
90
90
  name: 'vite-plugin-starlight-user-config',
91
- resolveId(id): string | void {
91
+ resolveId(id): string | undefined {
92
92
  if (id in modules) return resolveVirtualModuleId(id)
93
93
  },
94
- load(id): string | void {
94
+ load(id): string | undefined {
95
95
  const resolution = resolutionMap[id]
96
96
  if (resolution) return modules[resolution]
97
97
  }
package/schemas/social.ts CHANGED
@@ -7,7 +7,9 @@ export const SocialLinksSchema = () =>
7
7
  .record(
8
8
  z.enum(socialLinks),
9
9
  // Link to the respective social profile for this site
10
- z.string().url()
10
+ z
11
+ .string()
12
+ .url()
11
13
  )
12
14
  .transform((links) => {
13
15
  const labelledLinks: Partial<Record<keyof typeof links, { label: string; url: string }>> = {}
package/scripts/check.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { exec } from 'child_process'
1
+ import { exec } from 'node:child_process'
2
2
 
3
3
  const runCommand = (command, cwd, timeout = 5000) => {
4
4
  return new Promise((resolve, reject) => {
package/scripts/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env node
2
- 'use strict'
3
-
4
- import { readFileSync } from 'fs'
5
- import { dirname, join } from 'path'
6
- import { fileURLToPath } from 'url'
2
+ import { readFileSync } from 'node:fs'
3
+ import { dirname, join } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
7
5
 
8
6
  import checkFunc from './check.mjs'
9
7
  import minimist from './libs/minimist.cjs'
@@ -15,11 +13,12 @@ switch (args._[0]) {
15
13
  case 'check':
16
14
  await checkFunc()
17
15
  break
18
- case 'new':
16
+ case 'new': {
19
17
  const newArgs = process.argv.slice(3)
20
18
  newFunc(newArgs)
21
19
  break
22
- case 'info':
20
+ }
21
+ case 'info': {
23
22
  const __dirname = dirname(fileURLToPath(import.meta.url))
24
23
  const packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf8'))
25
24
  console.log()
@@ -29,14 +28,17 @@ switch (args._[0]) {
29
28
  console.log(`- Node.js:\t${process.version}`)
30
29
  console.log(`- Platform:\t${process.platform}`)
31
30
  break
32
- case 'help':
31
+ }
32
+ case 'help': {
33
33
  console.log('Usage:')
34
34
  console.log(' check - Check envirionment and run corresponding adaption code')
35
35
  console.log(' new [args] - Create new post on blog collection')
36
36
  console.log(' info - Show this info message')
37
37
  console.log(' help - Show this help message')
38
38
  break
39
- default:
39
+ }
40
+ default: {
40
41
  console.log('Unknown command. Use "help" to see the available commands.')
41
42
  break
43
+ }
42
44
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  function hasKey(obj, keys) {
4
4
  var o = obj
5
- keys.slice(0, -1).forEach(function (key) {
5
+ keys.slice(0, -1).forEach((key) => {
6
6
  o = o[key] || {}
7
7
  })
8
8
 
@@ -24,7 +24,7 @@ function isConstructorOrProto(obj, key) {
24
24
  return (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__'
25
25
  }
26
26
 
27
- module.exports = function (args, opts) {
27
+ module.exports = (args, opts) => {
28
28
  if (!opts) {
29
29
  opts = {}
30
30
  }
@@ -45,7 +45,7 @@ module.exports = function (args, opts) {
45
45
  ;[]
46
46
  .concat(opts.boolean)
47
47
  .filter(Boolean)
48
- .forEach(function (key) {
48
+ .forEach((key) => {
49
49
  flags.bools[key] = true
50
50
  })
51
51
  }
@@ -53,29 +53,23 @@ module.exports = function (args, opts) {
53
53
  var aliases = {}
54
54
 
55
55
  function aliasIsBoolean(key) {
56
- return aliases[key].some(function (x) {
57
- return flags.bools[x]
58
- })
56
+ return aliases[key].some((x) => flags.bools[x])
59
57
  }
60
58
 
61
- Object.keys(opts.alias || {}).forEach(function (key) {
59
+ Object.keys(opts.alias || {}).forEach((key) => {
62
60
  aliases[key] = [].concat(opts.alias[key])
63
- aliases[key].forEach(function (x) {
64
- aliases[x] = [key].concat(
65
- aliases[key].filter(function (y) {
66
- return x !== y
67
- })
68
- )
61
+ aliases[key].forEach((x) => {
62
+ aliases[x] = [key].concat(aliases[key].filter((y) => x !== y))
69
63
  })
70
64
  })
71
65
 
72
66
  ;[]
73
67
  .concat(opts.string)
74
68
  .filter(Boolean)
75
- .forEach(function (key) {
69
+ .forEach((key) => {
76
70
  flags.strings[key] = true
77
71
  if (aliases[key]) {
78
- ;[].concat(aliases[key]).forEach(function (k) {
72
+ ;[].concat(aliases[key]).forEach((k) => {
79
73
  flags.strings[k] = true
80
74
  })
81
75
  }
@@ -95,9 +89,11 @@ module.exports = function (args, opts) {
95
89
  }
96
90
 
97
91
  function setKey(obj, keys, value) {
98
- var o = obj
99
- for (var i = 0; i < keys.length - 1; i++) {
100
- var key = keys[i]
92
+ var o = obj,
93
+ i,
94
+ key
95
+ for (i = 0; i < keys.length - 1; i++) {
96
+ key = keys[i]
101
97
  if (isConstructorOrProto(o, key)) {
102
98
  return
103
99
  }
@@ -144,14 +140,17 @@ module.exports = function (args, opts) {
144
140
  }
145
141
 
146
142
  var value = !flags.strings[key] && isNumber(val) ? Number(val) : val
147
- setKey(argv, key.split('.'), value)
148
-
149
- ;(aliases[key] || []).forEach(function (x) {
143
+ setKey(
144
+ argv,
145
+ key.split('.'),
146
+ value
147
+ )
148
+ ;(aliases[key] || []).forEach((x) => {
150
149
  setKey(argv, x.split('.'), value)
151
150
  })
152
151
  }
153
152
 
154
- Object.keys(flags.bools).forEach(function (key) {
153
+ Object.keys(flags.bools).forEach((key) => {
155
154
  setArg(key, defaults[key] === undefined ? false : defaults[key])
156
155
  })
157
156
 
@@ -162,18 +161,19 @@ module.exports = function (args, opts) {
162
161
  args = args.slice(0, args.indexOf('--'))
163
162
  }
164
163
 
165
- for (var i = 0; i < args.length; i++) {
166
- var arg = args[i]
167
- var key
168
- var next
164
+ var i, arg, key, next, m, value, letters, broken, j
165
+ for (i = 0; i < args.length; i++) {
166
+ arg = args[i]
167
+ key
168
+ next
169
169
 
170
170
  if (/^--.+=/.test(arg)) {
171
171
  // Using [\s\S] instead of . because js doesn't support the
172
172
  // 'dotall' regex modifier. See:
173
173
  // http://stackoverflow.com/a/1068308/13216
174
- var m = arg.match(/^--([^=]+)=([\s\S]*)$/)
174
+ m = arg.match(/^--([^=]+)=([\s\S]*)$/)
175
175
  key = m[1]
176
- var value = m[2]
176
+ value = m[2]
177
177
  if (flags.bools[key]) {
178
178
  value = value !== 'false'
179
179
  }
@@ -200,10 +200,10 @@ module.exports = function (args, opts) {
200
200
  setArg(key, flags.strings[key] ? '' : true, arg)
201
201
  }
202
202
  } else if (/^-[^-]+/.test(arg)) {
203
- var letters = arg.slice(1, -1).split('')
203
+ letters = arg.slice(1, -1).split('')
204
204
 
205
- var broken = false
206
- for (var j = 0; j < letters.length; j++) {
205
+ broken = false
206
+ for (j = 0; j < letters.length; j++) {
207
207
  next = arg.slice(j + 2)
208
208
 
209
209
  if (next === '-') {
@@ -260,11 +260,11 @@ module.exports = function (args, opts) {
260
260
  }
261
261
  }
262
262
 
263
- Object.keys(defaults).forEach(function (k) {
263
+ Object.keys(defaults).forEach((k) => {
264
264
  if (!hasKey(argv, k.split('.'))) {
265
265
  setKey(argv, k.split('.'), defaults[k])
266
266
 
267
- ;(aliases[k] || []).forEach(function (x) {
267
+ ;(aliases[k] || []).forEach((x) => {
268
268
  setKey(argv, x.split('.'), defaults[k])
269
269
  })
270
270
  }
@@ -273,7 +273,7 @@ module.exports = function (args, opts) {
273
273
  if (opts['--']) {
274
274
  argv['--'] = notFlags.slice()
275
275
  } else {
276
- notFlags.forEach(function (k) {
276
+ notFlags.forEach((k) => {
277
277
  argv._.push(k)
278
278
  })
279
279
  }
@@ -1,16 +1,16 @@
1
- ;(function (name, root, factory) {
1
+ ;((name, root, factory) => {
2
2
  if (typeof exports === 'object') {
3
3
  module.exports = factory()
4
- module.exports['default'] = factory()
4
+ module.exports.default = factory()
5
5
  } else if (typeof define === 'function' && define.amd) {
6
- /* istanbul ignore next */
6
+ /* istanbul ignore next */
7
7
  define(factory)
8
8
  } else {
9
9
  root[name] = factory()
10
10
  }
11
- })('slugify', this, function () {
11
+ })('slugify', this, () => {
12
12
  var charMap = JSON.parse(
13
- '{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ō":"O","ō":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","Ə":"E","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","ə":"e","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","ѝ":"u","џ":"dz","Ґ":"G","ґ":"g","Ғ":"GH","ғ":"gh","Қ":"KH","қ":"kh","Ң":"NG","ң":"ng","Ү":"UE","ү":"ue","Ұ":"U","ұ":"u","Һ":"H","һ":"h","Ә":"AE","ә":"ae","Ө":"OE","ө":"oe","Ա":"A","Բ":"B","Գ":"G","Դ":"D","Ե":"E","Զ":"Z","Է":"E\'","Ը":"Y\'","Թ":"T\'","Ժ":"JH","Ի":"I","Լ":"L","Խ":"X","Ծ":"C\'","Կ":"K","Հ":"H","Ձ":"D\'","Ղ":"GH","Ճ":"TW","Մ":"M","Յ":"Y","Ն":"N","Շ":"SH","Չ":"CH","Պ":"P","Ջ":"J","Ռ":"R\'","Ս":"S","Վ":"V","Տ":"T","Ր":"R","Ց":"C","Փ":"P\'","Ք":"Q\'","Օ":"O\'\'","Ֆ":"F","և":"EV","ء":"a","آ":"aa","أ":"a","ؤ":"u","إ":"i","ئ":"e","ا":"a","ب":"b","ة":"h","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ى":"a","ي":"y","ً":"an","ٌ":"on","ٍ":"en","َ":"a","ُ":"u","ِ":"e","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","پ":"p","چ":"ch","ژ":"zh","ک":"k","گ":"g","ی":"y","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","Ṣ":"S","ṣ":"s","Ẁ":"W","ẁ":"w","Ẃ":"W","ẃ":"w","Ẅ":"W","ẅ":"w","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","–":"-","‘":"\'","’":"\'","“":"\\\"","”":"\\\"","„":"\\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₸":"kazakhstani tenge","₹":"indian rupee","₺":"turkish lira","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial","ﻵ":"laa","ﻷ":"laa","ﻹ":"lai","ﻻ":"la"}'
13
+ '{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ō":"O","ō":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","Ə":"E","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","ə":"e","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","ѝ":"u","џ":"dz","Ґ":"G","ґ":"g","Ғ":"GH","ғ":"gh","Қ":"KH","қ":"kh","Ң":"NG","ң":"ng","Ү":"UE","ү":"ue","Ұ":"U","ұ":"u","Һ":"H","һ":"h","Ә":"AE","ә":"ae","Ө":"OE","ө":"oe","Ա":"A","Բ":"B","Գ":"G","Դ":"D","Ե":"E","Զ":"Z","Է":"E\'","Ը":"Y\'","Թ":"T\'","Ժ":"JH","Ի":"I","Լ":"L","Խ":"X","Ծ":"C\'","Կ":"K","Հ":"H","Ձ":"D\'","Ղ":"GH","Ճ":"TW","Մ":"M","Յ":"Y","Ն":"N","Շ":"SH","Չ":"CH","Պ":"P","Ջ":"J","Ռ":"R\'","Ս":"S","Վ":"V","Տ":"T","Ր":"R","Ց":"C","Փ":"P\'","Ք":"Q\'","Օ":"O\'\'","Ֆ":"F","և":"EV","ء":"a","آ":"aa","أ":"a","ؤ":"u","إ":"i","ئ":"e","ا":"a","ب":"b","ة":"h","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ى":"a","ي":"y","ً":"an","ٌ":"on","ٍ":"en","َ":"a","ُ":"u","ِ":"e","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","پ":"p","چ":"ch","ژ":"zh","ک":"k","گ":"g","ی":"y","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","Ṣ":"S","ṣ":"s","Ẁ":"W","ẁ":"w","Ẃ":"W","ẃ":"w","Ẅ":"W","ẅ":"w","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","–":"-","‘":"\'","’":"\'","“":"\\"","”":"\\"","„":"\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₸":"kazakhstani tenge","₹":"indian rupee","₺":"turkish lira","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial","ﻵ":"laa","ﻷ":"laa","ﻹ":"lai","ﻻ":"la"}'
14
14
  )
15
15
  var locales = JSON.parse(
16
16
  '{"bg":{"Й":"Y","Ц":"Ts","Щ":"Sht","Ъ":"A","Ь":"Y","й":"y","ц":"ts","щ":"sht","ъ":"a","ь":"y"},"de":{"Ä":"AE","ä":"ae","Ö":"OE","ö":"oe","Ü":"UE","ü":"ue","ß":"ss","%":"prozent","&":"und","|":"oder","∑":"summe","∞":"unendlich","♥":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","¢":"centavos","£":"libras","¤":"moneda","₣":"francos","∑":"suma","∞":"infinito","♥":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","¢":"centime","£":"livre","¤":"devise","₣":"franc","∑":"somme","∞":"infini","♥":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","¢":"centavo","∑":"soma","£":"libra","∞":"infinito","♥":"amor"},"uk":{"И":"Y","и":"y","Й":"Y","й":"y","Ц":"Ts","ц":"ts","Х":"Kh","х":"kh","Щ":"Shch","щ":"shch","Г":"H","г":"h"},"vi":{"Đ":"D","đ":"d"},"da":{"Ø":"OE","ø":"oe","Å":"AA","å":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"større end"},"nb":{"&":"og","Å":"AA","Æ":"AE","Ø":"OE","å":"aa","æ":"ae","ø":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","Å":"AA","Ä":"AE","Ö":"OE","å":"aa","ä":"ae","ö":"oe"}}'
@@ -33,7 +33,7 @@
33
33
  .normalize()
34
34
  .split('')
35
35
  // replace characters based on charMap
36
- .reduce(function (result, ch) {
36
+ .reduce((result, ch) => {
37
37
  var appendChar = locale[ch]
38
38
  if (appendChar === undefined) appendChar = charMap[ch]
39
39
  if (appendChar === undefined) appendChar = ch
@@ -65,7 +65,7 @@
65
65
  return slug
66
66
  }
67
67
 
68
- replace.extend = function (customMap) {
68
+ replace.extend = (customMap) => {
69
69
  Object.assign(charMap, customMap)
70
70
  }
71
71
 
package/scripts/new.mjs CHANGED
@@ -89,20 +89,19 @@ export default function main(args) {
89
89
 
90
90
  const fileExtension = parsedArgs.mdx ? '.mdx' : '.md'
91
91
  const fileName = getPostSlug(postTitle) + fileExtension
92
-
92
+
93
93
  let fullPath
94
94
  if (parsedArgs.folder) {
95
- const folderName = getPostSlug(postTitle);
96
- const folderPath = path.join(TARGET_DIR, folderName);
95
+ const folderName = getPostSlug(postTitle)
96
+ const folderPath = path.join(TARGET_DIR, folderName)
97
97
  if (!fs.existsSync(folderPath)) {
98
- fs.mkdirSync(folderPath, { recursive: true });
98
+ fs.mkdirSync(folderPath, { recursive: true })
99
99
  }
100
- const fileName = 'index' + fileExtension;
101
- fullPath = path.join(folderPath, fileName);
100
+ const fileName = `index${fileExtension}`
101
+ fullPath = path.join(folderPath, fileName)
102
102
  } else {
103
- fullPath = path.join(TARGET_DIR, fileName);
103
+ fullPath = path.join(TARGET_DIR, fileName)
104
104
  }
105
-
106
105
 
107
106
  console.log('Full path:', fullPath)
108
107
 
@@ -112,9 +111,9 @@ export default function main(args) {
112
111
  }
113
112
 
114
113
  let content = `---
115
- title: ${postTitle}
114
+ title: '${postTitle}'
116
115
  description: 'Write your description here.'
117
- publishDate: ${getDate()}
116
+ publishDate: '${getDate()}'
118
117
  `
119
118
  content += parsedArgs.draft ? 'draft: true\n' : ''
120
119
  content += parsedArgs.lang ? `lang: ${parsedArgs.lang}\n` : ''
package/types/index.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { Icons } from '../libs/icons'
1
+ import type { Icons } from '../libs/icons'
2
2
 
3
3
  export type { IntegrationUserConfig } from './integrations-config'
4
4
  export type { ThemeUserConfig } from './theme-config'
5
- export type { UserInputConfig as Config, UserConfig as ConfigOutput } from './user-config'
5
+ export type { UserConfig as ConfigOutput, UserInputConfig as Config } from './user-config'
6
6
 
7
7
  export interface SiteMeta {
8
8
  title: string
@@ -52,6 +52,8 @@ export const IntegrationConfigSchema = () =>
52
52
  enable: z.boolean().default(false),
53
53
  /** The server to use for the Waline comment system. */
54
54
  server: z.string().optional(),
55
+ /** Show meta info for comments */
56
+ showMeta: z.boolean().default(true),
55
57
  /** The emoji to use for the Waline comment system. */
56
58
  emoji: z.array(z.string()).optional(),
57
59
  /** Additional configurations for the Waline comment system. */
@@ -1,11 +1,13 @@
1
- import { clsx, type ClassValue } from './clsx'
1
+ import { type ClassValue, clsx } from './clsx'
2
2
 
3
3
  export function simpleMerge(...classes: string[]): string {
4
4
  const uniqueClasses = new Set<string>()
5
5
 
6
6
  classes.forEach((cls) => {
7
7
  if (cls) {
8
- cls.split(' ').forEach((c) => uniqueClasses.add(c))
8
+ cls.split(' ').forEach((c) => {
9
+ uniqueClasses.add(c)
10
+ })
9
11
  }
10
12
  })
11
13
 
@@ -3,8 +3,8 @@
3
3
  * source: https://github.com/withastro/astro/blob/main/packages/astro/src/content/error-map.ts
4
4
  */
5
5
 
6
- import type { z } from 'astro:content'
7
6
  import { AstroError } from 'astro/errors'
7
+ import type { z } from 'astro:content'
8
8
 
9
9
  type TypeOrLiteralErrByPathEntry = {
10
10
  code: 'invalid_type' | 'invalid_literal'
@@ -45,7 +45,10 @@ export async function parseAsyncWithFriendlyErrors<T extends z.Schema>(
45
45
  return processParsedData(await schema.safeParseAsync(input, { errorMap }), message)
46
46
  }
47
47
 
48
- function processParsedData(parsedData: z.SafeParseReturnType<any, any>, message: string) {
48
+ function processParsedData<TSchema extends z.Schema>(
49
+ parsedData: z.SafeParseReturnType<z.output<TSchema>, z.input<TSchema>>,
50
+ message: string
51
+ ): z.output<TSchema> {
49
52
  if (!parsedData.success) {
50
53
  throw new AstroError(message, parsedData.error.issues.map((i) => i.message).join('\n'))
51
54
  }
@@ -60,17 +63,20 @@ const errorMap: z.ZodErrorMap = (baseError, ctx) => {
60
63
  // raise a single error when `key` does not match:
61
64
  // > Did not match union.
62
65
  // > key: Expected `'tutorial' | 'blog'`, received 'foo'
63
- let typeOrLiteralErrByPath: Map<string, TypeOrLiteralErrByPathEntry> = new Map()
64
- for (const unionError of baseError.unionErrors.map((e) => e.errors).flat()) {
66
+ const typeOrLiteralErrByPath: Map<string, TypeOrLiteralErrByPathEntry> = new Map()
67
+ for (const unionError of baseError.unionErrors.flatMap((e) => e.errors)) {
65
68
  if (unionError.code === 'invalid_type' || unionError.code === 'invalid_literal') {
66
69
  const flattenedErrorPath = flattenErrorPath(unionError.path)
67
70
  if (typeOrLiteralErrByPath.has(flattenedErrorPath)) {
68
- typeOrLiteralErrByPath.get(flattenedErrorPath)!.expected.push(unionError.expected)
71
+ typeOrLiteralErrByPath
72
+ .get(flattenedErrorPath)
73
+ ?.expected.push((unionError as { expected: unknown }).expected)
69
74
  } else {
70
75
  typeOrLiteralErrByPath.set(flattenedErrorPath, {
71
76
  code: unionError.code,
72
- received: (unionError as any).received,
73
- expected: [unionError.expected]
77
+ received:
78
+ 'received' in unionError ? (unionError as { received: unknown }).received : undefined,
79
+ expected: [(unionError as { expected: unknown }).expected]
74
80
  })
75
81
  }
76
82
  }
@@ -114,8 +120,8 @@ const errorMap: z.ZodErrorMap = (baseError, ctx) => {
114
120
  }
115
121
  }
116
122
  if (expectedShapes.length) {
117
- details.push('> Expected type `' + expectedShapes.join(' | ') + '`')
118
- details.push('> Received `' + stringify(ctx.data) + '`')
123
+ details.push(`> Expected type \`${expectedShapes.join(' | ')}\``)
124
+ details.push(`> Received \`${stringify(ctx.data)}\``)
119
125
  }
120
126
  }
121
127
 
@@ -128,8 +134,9 @@ const errorMap: z.ZodErrorMap = (baseError, ctx) => {
128
134
  baseErrorPath,
129
135
  getTypeOrLiteralMsg({
130
136
  code: baseError.code,
131
- received: (baseError as any).received,
132
- expected: [baseError.expected]
137
+ received:
138
+ 'received' in baseError ? (baseError as { received: unknown }).received : undefined,
139
+ expected: [(baseError as { expected: unknown }).expected]
133
140
  })
134
141
  )
135
142
  }
@@ -16,6 +16,8 @@ type Options = {
16
16
  * @returns {string}
17
17
  * Serialized `value`.
18
18
  */
19
+
20
+ // biome-ignore lint/suspicious/noShadowRestrictedNames: this is the original package expression
19
21
  export default function toString(value: unknown, options?: Options): string {
20
22
  const { includeImageAlt = true, includeHtml = true } = options || {}
21
23
  return serialize(value, includeImageAlt, includeHtml)
@@ -1,5 +1,3 @@
1
- 'use strict'
2
-
3
1
  // Tks for issue https://github.com/cworld1/astro-theme-pure/issues/36
4
2
  // CJK character ranges
5
3
  const CJK_RANGES = [
@@ -67,7 +65,7 @@ export function getReadingTime(text: string, wordsPerMinute: number = 200): Read
67
65
  const displayed = Math.ceil(minutes)
68
66
 
69
67
  return {
70
- text: displayed + ' min',
68
+ text: `${displayed} min`,
71
69
  minutes,
72
70
  time,
73
71
  words
package/utils/server.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getCollection, type CollectionEntry, type CollectionKey } from 'astro:content'
1
+ import { type CollectionEntry, type CollectionKey, getCollection } from 'astro:content'
2
2
 
3
3
  type Collections = CollectionEntry<CollectionKey>[]
4
4
 
@@ -27,7 +27,7 @@ export function groupCollectionsByYear<T extends CollectionKey>(
27
27
  if (!acc.has(year)) {
28
28
  acc.set(year, [])
29
29
  }
30
- acc.get(year)!.push(collection)
30
+ acc.get(year)?.push(collection)
31
31
  }
32
32
  return acc
33
33
  }, new Map<number, Collections>())
package/utils/theme.ts CHANGED
@@ -3,7 +3,8 @@ export function getTheme() {
3
3
  }
4
4
 
5
5
  export function listenThemeChange(theme?: string) {
6
- if (theme && theme !== 'system') return // if theme is specified, no need to listen window theme change
6
+ // If theme is specified, no need to listen window theme change
7
+ if (theme && theme !== 'system') return
7
8
  window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
8
9
  setTheme(e.matches ? 'dark' : 'light')
9
10
  })