From b73c5ae65f37d76b561638497e602c05b51da12b Mon Sep 17 00:00:00 2001 From: Luca Pipolo Date: Tue, 9 Apr 2024 14:49:08 +0200 Subject: [PATCH] feat: add typescript sample --- assets/scripts/.gitkeep | 0 assets/scripts/main.ts | 5 +++++ src/class-asset.php | 3 +++ 3 files changed, 8 insertions(+) delete mode 100644 assets/scripts/.gitkeep create mode 100644 assets/scripts/main.ts diff --git a/assets/scripts/.gitkeep b/assets/scripts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/assets/scripts/main.ts b/assets/scripts/main.ts new file mode 100644 index 0000000..68dbd0b --- /dev/null +++ b/assets/scripts/main.ts @@ -0,0 +1,5 @@ +function addNumber(a: number, b: number): number { + return a + b; +} + +console.log(addNumber(4, 5)); diff --git a/src/class-asset.php b/src/class-asset.php index dc1d157..50c1ec7 100644 --- a/src/class-asset.php +++ b/src/class-asset.php @@ -47,6 +47,9 @@ public function enqueue_assets(): void { // Theme Styles. wp_enqueue_style( $theme_prefix . '-main-styles', $this->get_base_url() . '/dist/styles/main.css', array( $theme_prefix . '-fonts-preload' ), $this->get_filemtime( 'styles/main.css' ) ); + + // Theme Script. + wp_enqueue_script( $theme_prefix, $this->get_base_url() . '/dist/scripts/main.js', array(), $this->get_filemtime( 'scripts/main.js' ), true ); } /**