-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,081 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { HtmlSsgContext } from "ssg-api/dist/src/HtmlSsgContext" | ||
import { ReferenceGenerator } from "./ReferenceGenerator" | ||
|
||
export abstract class PerFileCounter<C extends HtmlSsgContext> implements ReferenceGenerator<C> { | ||
/** | ||
* Source counter in the scope of the current page/context. | ||
*/ | ||
protected number = 1 | ||
|
||
/** | ||
* The current/previous page | ||
* | ||
* @protected | ||
*/ | ||
protected fileName: string | ||
|
||
get value(): string { | ||
return "" + this.number | ||
} | ||
|
||
next(context: C): string { | ||
const contextFilename = context.file.name | ||
if (contextFilename !== this.fileName) { | ||
this.fileName = contextFilename | ||
this.number = 1 | ||
} else { | ||
this.number++ | ||
} | ||
return this.value | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { HtmlSsgContext } from "ssg-api/dist/src/HtmlSsgContext" | ||
|
||
export interface ReferenceGenerator<C extends HtmlSsgContext> { | ||
|
||
readonly value: string | ||
|
||
next(context: C): string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.