Skip to content

Commit ee991c2

Browse files
committed
Prepare website for 2024
1 parent 785119d commit ee991c2

File tree

8 files changed

+91
-22
lines changed

8 files changed

+91
-22
lines changed

build.sbt

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,41 @@
11
import java.io.File
22

3-
ThisBuild / scalaVersion := "3.3.1"
3+
ThisBuild / scalaVersion := "3.5.2"
44

55
lazy val adventOfCode = project
66
.in(file("."))
77
.enablePlugins(ScalaJSPlugin)
88
.settings(
9-
(Compile / sourceGenerators) += taskPatchSolutions("2021", _ / "solutions" / "2021" / "src").taskValue,
10-
(Compile / sourceGenerators) += taskPatchSolutions("2022", _ / "solutions" / "2022" / "src").taskValue,
11-
(Compile / sourceGenerators) += taskPatchSolutions("2023", _ / "solutions" / "2023" / "src").taskValue,
9+
Seq("2021", "2022", "2023", "2024")
10+
.map(year => (Compile / sourceGenerators) += taskPatchSolutions(year).taskValue),
1211
Compile / managedSourceDirectories := Nil,
1312
run / fork := true,
1413
run / baseDirectory := (ThisBuild / baseDirectory).value / "solutions"
1514
)
1615

17-
def taskPatchSolutions(year: String, getSrcDir: File => File) = Def.task {
16+
def taskPatchSolutions(year: String) = Def.task {
1817
val s = streams.value
1918
val cacheDir = s.cacheDirectory
2019
val trgDir = (Compile / sourceManaged).value / s"solutions-$year-src"
21-
val srcDir = getSrcDir((ThisBuild / baseDirectory).value)
20+
val srcDir = (ThisBuild / baseDirectory).value / "solutions" / year / "src"
2221

23-
FileFunction.cached(cacheDir / s"fetch${year}Solutions",
24-
FilesInfo.lastModified, FilesInfo.exists) { dependencies =>
25-
s.log.info(s"Unpacking $year solutions sources to $trgDir...")
26-
if (trgDir.exists)
27-
IO.delete(trgDir)
28-
IO.createDirectory(trgDir)
29-
IO.copyDirectory(srcDir, trgDir)
30-
val sourceFiles = (trgDir ** "*.scala").get.toSet
31-
for (f <- sourceFiles)
32-
IO.writeLines(f, patchSolutions(f.getName, year, IO.readLines(f)))
33-
sourceFiles
34-
} (Set(srcDir)).toSeq
22+
FileFunction
23+
.cached(
24+
cacheDir / s"fetch${year}Solutions",
25+
FilesInfo.lastModified,
26+
FilesInfo.exists
27+
) { dependencies =>
28+
s.log.info(s"Unpacking $year solutions sources to $trgDir...")
29+
if (trgDir.exists)
30+
IO.delete(trgDir)
31+
IO.createDirectory(trgDir)
32+
IO.copyDirectory(srcDir, trgDir)
33+
val sourceFiles = (trgDir ** "*.scala").get.toSet
34+
for (f <- sourceFiles)
35+
IO.writeLines(f, patchSolutions(f.getName, year, IO.readLines(f)))
36+
sourceFiles
37+
} (Set(srcDir))
38+
.toSeq
3539
}
3640

3741
/** adds `package adventofcode${year}` to the file after the last using directive */
@@ -61,8 +65,8 @@ lazy val solver = project
6165
.enablePlugins(ScalaJSPlugin)
6266
.settings(
6367
libraryDependencies ++= Seq(
64-
"org.scala-js" %%% "scalajs-dom" % "2.3.0",
65-
"com.raquo" %%% "laminar" % "0.14.5"
68+
"org.scala-js" %%% "scalajs-dom" % "2.8.0",
69+
"com.raquo" %%% "laminar" % "17.1.0"
6670
),
6771
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.ESModule))
6872
)

docs/2024/puzzles/day0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Day 0
2+
3+
[Advent of Code 2024](https://adventofcode.com/) has not started yet.
4+
See you soon!

project/plugins.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.5.1")
2-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")
1+
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.6.1")
2+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.17.0")

solver/src/main/scala/adventofcode/Solver.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import scala.util.{Try, Failure, Success}
66
import scala.scalajs.js.annotation.JSExportTopLevel
77

88
object Solver:
9+
private val solutions2024: Map[String, String => Any] =
10+
// import adventofcode2024.*
11+
Map()
12+
913
private val solutions2023: Map[String, String => Any] =
1014
import adventofcode2023.*
1115
Map(
@@ -109,6 +113,7 @@ object Solver:
109113

110114
private val solutions: Map[String, Map[String, String => Any]] =
111115
Map(
116+
"2024" -> solutions2024,
112117
"2023" -> solutions2023,
113118
"2022" -> solutions2022,
114119
"2021" -> solutions2021,

website/docusaurus.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ const config = {
9595
position: 'left',
9696
label: 'Setup',
9797
},
98+
{
99+
type: 'dropdown',
100+
position: 'left',
101+
label: 'Puzzles 2024',
102+
items: buildDropdown('2024/puzzles')
103+
},
98104
{
99105
type: 'dropdown',
100106
position: 'left',

website/sidebars.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const sidebars = {
3838
adventOfCodeSidebar: [
3939
'introduction',
4040
'setup',
41+
{
42+
"2024 Puzzles": buildSidebar('2024/puzzles'),
43+
},
4144
{
4245
"2023 Puzzles": buildSidebar('2023/puzzles'),
4346
},

website/src/pages/2024/index.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
import Layout from '@theme/Layout';
4+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5+
import useBaseUrl from '@docusaurus/useBaseUrl';
6+
import styles from '../index.module.css';
7+
import HomepageFeatures from '../../components/HomepageFeatures';
8+
import DocsLinks from '../../components/DocsLinks';
9+
10+
function HomepageHeader() {
11+
const {siteConfig} = useDocusaurusContext();
12+
return (
13+
<header className={clsx('hero hero--primary', styles.heroBanner)}>
14+
<div className="container">
15+
<h1 className="hero__title" style={{ textShadow: "2px 2px 4px #000000"}}>
16+
Scala Advent of Code 2024 by
17+
<a href="https://scala.epfl.ch/">
18+
<img className={styles.scalacenter} alt="Scala Center" src={useBaseUrl('/img/scala-center.png')} title="Scala Center"/>
19+
</a>
20+
</h1>
21+
<p className="hero__subtitle">{siteConfig.tagline}</p>
22+
<div className={styles.buttons}>
23+
<DocsLinks dir="2024/puzzles" linkStyle={`${styles.button} button button--secondary button--lg`} />
24+
</div>
25+
</div>
26+
</header>
27+
);
28+
}
29+
30+
export default function Home() {
31+
const {siteConfig} = useDocusaurusContext();
32+
return (
33+
<Layout
34+
title={siteConfig.title}
35+
description="Scala advent of code by the scala center">
36+
<HomepageHeader />
37+
<main>
38+
<HomepageFeatures />
39+
</main>
40+
</Layout>
41+
);
42+
}

website/src/pages/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ function HomepageHeader() {
3535
to="/2023/">
3636
2023
3737
</Link>
38+
<Link
39+
className={`${styles.button} button button--secondary button--lg`}
40+
to="/2024/">
41+
2024
42+
</Link>
3843
</div>
3944
</div>
4045
</header>

0 commit comments

Comments
 (0)