diff --git a/apps/test/content/posts/link-test.md b/apps/test/content/posts/link-test.md index 0e10ca04..9b181bae 100644 --- a/apps/test/content/posts/link-test.md +++ b/apps/test/content/posts/link-test.md @@ -26,7 +26,7 @@ These links are rendered by `layouts/_markup/render-link.html` and should always - Internal anchor link: [Jump to Card Link section](#card-link-shortcode) - Absolute same-site link: [Test site home](http://demo.fixit.lruihao.cn/test/) - External HTTP link: [FixIt Repository](https://github.com/hugo-fixit/FixIt) -- Mail link: [Email test](mailto:test@example.com) +- Mail link: [Email test](mailto:test@gmail.com) - JavaScript link: [JavaScript test](javascript:void(0)) - Tel link: [Phone test](tel:+1234567890) - File link: [File test](file:///path/to/file.txt) @@ -34,7 +34,7 @@ These links are rendered by `layouts/_markup/render-link.html` and should always ### Title Attribute (Markdown) -[External link with title](https://example.com "Example Title") +[External link with title](https://google.com "Example Title") ## Link Shortcode (Regular) @@ -44,13 +44,13 @@ These links are rendered by `layouts/_markup/render-link.html` and should always {{< link href="/test/units/codeblock-test/" content="Internal shortcode link" class="shortcode-link-test" >}} -{{< link href="https://example.com" content="Custom rel + no noreferrer" rel="ugc" noreferrer=false >}} +{{< link href="https://google.com" content="Custom rel + no noreferrer" rel="ugc" noreferrer=false >}} {{< link href="/images/fixit.svg" content="Download local file" download="fixit.svg" >}} ### Positional parameters -{{< link "https://example.org" "Positional regular link" "Positional title" >}} +{{< link "https://mozilla.org" "Positional regular link" "Positional title" >}} ## Card Link Shortcode @@ -72,16 +72,16 @@ These links are rendered by `layouts/_markup/render-link.html` and should always ### Positional card parameters -{{< link "https://example.com" "Positional card link" "" true "fa-solid fa-link" >}} +{{< link "https://google.com" "Positional card link" "" true "fa-solid fa-link" >}} ## Edge Cases - URL with query string: - [Search query test](https://example.com/search?q=fixit&lang=en) + [Search query test](https://google.com/search?q=fixit&lang=en) - URL with fragment: - [Fragment test](https://example.com/docs#installation) + [Fragment test](https://google.com/docs#installation) - Long URL display (card meta should trim protocol automatically): - {{< link href="https://example.com/a/very/long/path/for/testing/card/url/display?foo=bar&baz=qux" content="Long URL card" card=true >}} + {{< link href="https://google.com/a/very/long/path/for/testing/card/url/display?foo=bar&baz=qux" content="Long URL card" card=true >}} ## Manual Verification Checklist diff --git a/assets/js/core/banner.ts b/assets/js/core/banner.ts new file mode 100644 index 00000000..518ca72e --- /dev/null +++ b/assets/js/core/banner.ts @@ -0,0 +1,13 @@ +/** + * Console banner — prints a styled FixIt version message in the browser console. + */ +export function printBanner(version: string) { + const color = '#FF735A' + // eslint-disable-next-line no-console + console.log( + `%c FixIt ${version} %c https://github.com/hugo-fixit %c`, + `background: ${color}; border: 1px solid ${color}; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;`, + `border: 1px solid ${color}; padding: 1px; border-radius: 0 2px 2px 0; color: ${color};`, + 'background: transparent;', + ) +} diff --git a/assets/js/main.ts b/assets/js/main.ts index 5012b25a..435483a6 100644 --- a/assets/js/main.ts +++ b/assets/js/main.ts @@ -1,3 +1,4 @@ +import { printBanner } from './core/banner' import { eventBus } from './core/event-bus' import { CodeModule } from './modules/code' import { ContentModule } from './modules/content' @@ -33,6 +34,7 @@ function bootstrap(): void { // Build window.fixit facade window.fixit = { get config() { return core.config }, + get version() { return core.version }, get themeMode() { return core.themeMode }, get isDark() { return core.isDark }, get newScrollTop() { return core.newScrollTop }, @@ -69,14 +71,7 @@ function bootstrap(): void { catch (err) { console.error(err) } - const fixitColor = '#FF735A' - // eslint-disable-next-line no-console - console.log( - `%c FixIt ${core.config.version} %c https://github.com/hugo-fixit %c`, - `background: ${fixitColor};border:1px solid ${fixitColor}; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;`, - `border:1px solid ${fixitColor}; padding: 1px; border-radius: 0 2px 2px 0; color: ${fixitColor};`, - 'background:transparent;', - ) + printBanner(core.version) } document.addEventListener('DOMContentLoaded', init, false) diff --git a/assets/js/modules/core.ts b/assets/js/modules/core.ts index 36ac735e..4d4b2333 100644 --- a/assets/js/modules/core.ts +++ b/assets/js/modules/core.ts @@ -12,6 +12,7 @@ import { getScrollTop, getThemeMode, isDarkMode } from '../utils' */ export class CoreModule implements CoreService { readonly config: FixItConfig + readonly version: string themeMode: string isDark: boolean newScrollTop: number @@ -23,6 +24,7 @@ export class CoreModule implements CoreService { constructor() { this.config = window.config + this.version = this.config.version this.themeMode = getThemeMode() this.isDark = isDarkMode() this.newScrollTop = getScrollTop() diff --git a/assets/js/types/config.ts b/assets/js/types/config.ts index 37bdd949..2fa479c2 100644 --- a/assets/js/types/config.ts +++ b/assets/js/types/config.ts @@ -9,8 +9,7 @@ export interface MaskOverlayHandler { /** FixIt theme configuration (typed version of window.config) */ export interface FixItConfig { - version?: string - themeMode?: string + version: string twemoji?: boolean search?: SearchConfig cse?: CSEConfig diff --git a/assets/js/types/ui.ts b/assets/js/types/ui.ts index 2e564495..15548db7 100644 --- a/assets/js/types/ui.ts +++ b/assets/js/types/ui.ts @@ -17,6 +17,7 @@ type FixItDocumentEventMap = { /** Public API exposed on window.fixit. */ export interface FixItPublicAPI { readonly config: FixItConfig + readonly version: string readonly themeMode: string readonly isDark: boolean readonly newScrollTop: number