chore: lint and format
222ed695
5 file(s) · +27 −11
| 241 | 241 | ||
| 242 | 242 | let postUrl = ""; |
|
| 243 | 243 | if (verbose) { |
|
| 244 | - | const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate); |
|
| 244 | + | const postPath = resolvePostPath( |
|
| 245 | + | post, |
|
| 246 | + | config.pathPrefix, |
|
| 247 | + | config.pathTemplate, |
|
| 248 | + | ); |
|
| 245 | 249 | postUrl = `\n ${config.siteUrl}${postPath}`; |
|
| 246 | 250 | } |
|
| 247 | 251 | log.message( |
| 151 | 151 | // Document path is like /posts/my-post-slug (or custom pathPrefix/pathTemplate) |
|
| 152 | 152 | const postsByPath = new Map<string, (typeof localPosts)[0]>(); |
|
| 153 | 153 | for (const post of localPosts) { |
|
| 154 | - | const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate); |
|
| 154 | + | const postPath = resolvePostPath( |
|
| 155 | + | post, |
|
| 156 | + | config.pathPrefix, |
|
| 157 | + | config.pathTemplate, |
|
| 158 | + | ); |
|
| 155 | 159 | postsByPath.set(postPath, post); |
|
| 156 | 160 | } |
|
| 157 | 161 |
| 588 | 588 | this.commentsContainer = container; |
|
| 589 | 589 | this.state = { type: "loading" }; |
|
| 590 | 590 | this.abortController = null; |
|
| 591 | - | ||
| 592 | 591 | } |
|
| 593 | 592 | ||
| 594 | 593 | static get observedAttributes() { |
|
| 701 | 700 | </div> |
|
| 702 | 701 | `; |
|
| 703 | 702 | if (this.hide) { |
|
| 704 | - | this.commentsContainer.style.display = 'none'; |
|
| 703 | + | this.commentsContainer.style.display = "none"; |
|
| 705 | 704 | } |
|
| 706 | 705 | break; |
|
| 707 | 706 | ||
| 245 | 245 | config: PublisherConfig, |
|
| 246 | 246 | coverImage?: BlobObject, |
|
| 247 | 247 | ): Promise<string> { |
|
| 248 | - | const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate); |
|
| 248 | + | const postPath = resolvePostPath( |
|
| 249 | + | post, |
|
| 250 | + | config.pathPrefix, |
|
| 251 | + | config.pathTemplate, |
|
| 252 | + | ); |
|
| 249 | 253 | const publishDate = new Date(post.frontmatter.publishDate); |
|
| 250 | 254 | ||
| 251 | 255 | // Determine textContent: use configured field from frontmatter, or fallback to markdown body |
|
| 306 | 310 | ||
| 307 | 311 | const [, , collection, rkey] = uriMatch; |
|
| 308 | 312 | ||
| 309 | - | const postPath = resolvePostPath(post, config.pathPrefix, config.pathTemplate); |
|
| 313 | + | const postPath = resolvePostPath( |
|
| 314 | + | post, |
|
| 315 | + | config.pathPrefix, |
|
| 316 | + | config.pathTemplate, |
|
| 317 | + | ); |
|
| 310 | 318 | const publishDate = new Date(post.frontmatter.publishDate); |
|
| 311 | 319 | ||
| 312 | 320 | // Determine textContent: use configured field from frontmatter, or fallback to markdown body |
|
| 231 | 231 | return slug; |
|
| 232 | 232 | } |
|
| 233 | 233 | ||
| 234 | - | export function resolvePathTemplate( |
|
| 235 | - | template: string, |
|
| 236 | - | post: BlogPost, |
|
| 237 | - | ): string { |
|
| 234 | + | export function resolvePathTemplate(template: string, post: BlogPost): string { |
|
| 238 | 235 | const publishDate = new Date(post.frontmatter.publishDate); |
|
| 239 | 236 | const year = String(publishDate.getFullYear()); |
|
| 240 | 237 | const month = String(publishDate.getMonth() + 1).padStart(2, "0"); |
|
| 270 | 267 | return result; |
|
| 271 | 268 | } |
|
| 272 | 269 | ||
| 273 | - | export function resolvePostPath(post: BlogPost, pathPrefix?: string, pathTemplate?: string): string { |
|
| 270 | + | export function resolvePostPath( |
|
| 271 | + | post: BlogPost, |
|
| 272 | + | pathPrefix?: string, |
|
| 273 | + | pathTemplate?: string, |
|
| 274 | + | ): string { |
|
| 274 | 275 | if (pathTemplate) { |
|
| 275 | 276 | return resolvePathTemplate(pathTemplate, post); |
|
| 276 | 277 | } |
|