Compare commits
No commits in common. "master" and "main" have entirely different histories.
3588 changed files with 69 additions and 533185 deletions
136
LICENSE
136
LICENSE
|
|
@ -1,155 +1,155 @@
|
|||
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International
|
||||
|
||||
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
||||
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
|
||||
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
|
||||
|
||||
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
|
||||
|
||||
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License
|
||||
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
|
||||
|
||||
Section 1 – Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
|
||||
|
||||
b. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
b. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
|
||||
|
||||
c. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
c. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
|
||||
|
||||
d. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
d. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
|
||||
|
||||
e. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
e. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
|
||||
|
||||
f. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
f. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
g. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
g. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
|
||||
|
||||
h. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||
h. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
|
||||
|
||||
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
|
||||
|
||||
Section 2 – Scope.
|
||||
|
||||
a. License grant.
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
||||
A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
|
||||
|
||||
B. produce and reproduce, but not Share, Adapted Material for NonCommercial purposes only.
|
||||
B. produce and reproduce, but not Share, Adapted Material for NonCommercial purposes only.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section 6(a).
|
||||
3. Term. The term of this Public License is specified in Section 6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
5. Downstream recipients.
|
||||
A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
|
||||
|
||||
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this Public License.
|
||||
2. Patent and trademark rights are not licensed under this Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
|
||||
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
|
||||
|
||||
Section 3 – License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
|
||||
|
||||
a. Attribution.
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material, You must:
|
||||
1. If You Share the Licensed Material, You must:
|
||||
|
||||
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
A. retain the following if it is supplied by the Licensor with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of warranties;
|
||||
iv. a notice that refers to the disclaimer of warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
|
||||
|
||||
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
|
||||
|
||||
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
|
||||
|
||||
For the avoidance of doubt, You do not have permission under this Public License to Share Adapted Material.
|
||||
For the avoidance of doubt, You do not have permission under this Public License to Share Adapted Material.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
|
||||
|
||||
Section 4 – Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only and provided You do not Share Adapted Material;
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only and provided You do not Share Adapted Material;
|
||||
|
||||
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
|
||||
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
|
||||
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
|
||||
|
||||
Section 5 – Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
|
||||
|
||||
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
|
||||
|
||||
Section 6 – Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
|
||||
|
||||
Section 7 – Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
|
||||
|
||||
Section 8 – Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
|
||||
|
||||
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
|
|
|
|||
116
README.md
116
README.md
|
|
@ -1,116 +1,2 @@
|
|||
# eleventy-base-blog v9
|
||||
# web-blog
|
||||
|
||||
A starter repository showing how to build a blog with the [Eleventy](https://www.11ty.dev/) site generator (using the [v3.0 release](https://github.com/11ty/eleventy/releases/tag/v3.0.0)).
|
||||
|
||||
## Getting Started
|
||||
|
||||
* [Want a more generic/detailed getting started guide?](https://www.11ty.dev/docs/getting-started/)
|
||||
|
||||
1. Make a directory and navigate to it:
|
||||
|
||||
```
|
||||
mkdir my-blog-name
|
||||
cd my-blog-name
|
||||
```
|
||||
|
||||
2. Clone this Repository
|
||||
|
||||
```
|
||||
git clone https://github.com/11ty/eleventy-base-blog.git .
|
||||
```
|
||||
|
||||
_Optional:_ Review `eleventy.config.js` and `_data/metadata.js` to configure the site’s options and data.
|
||||
|
||||
3. Install dependencies
|
||||
|
||||
```
|
||||
npm install
|
||||
```
|
||||
|
||||
4. Run Eleventy
|
||||
|
||||
Generate a production-ready build to the `_site` folder:
|
||||
|
||||
```
|
||||
npx @11ty/eleventy
|
||||
```
|
||||
|
||||
Or build and host on a local development server:
|
||||
|
||||
```
|
||||
npx @11ty/eleventy --serve
|
||||
```
|
||||
|
||||
Or you can run [debug mode](https://www.11ty.dev/docs/debugging/) to see all the internals.
|
||||
|
||||
## Features
|
||||
|
||||
- Using [Eleventy v3](https://github.com/11ty/eleventy/releases/tag/v3.0.0) with zero-JavaScript output.
|
||||
- Content is exclusively pre-rendered (this is a static site).
|
||||
- Can easily [deploy to a subfolder without changing any content](https://www.11ty.dev/docs/plugins/html-base/)
|
||||
- All URLs are decoupled from the content’s location on the file system.
|
||||
- Configure templates via the [Eleventy Data Cascade](https://www.11ty.dev/docs/data-cascade/)
|
||||
- **Performance focused**: four-hundos Lighthouse score out of the box!
|
||||
- _0 Cumulative Layout Shift_
|
||||
- _0ms Total Blocking Time_
|
||||
- Local development live reload provided by [Eleventy Dev Server](https://www.11ty.dev/docs/dev-server/).
|
||||
- Content-driven [navigation menu](https://www.11ty.dev/docs/plugins/navigation/)
|
||||
- Fully automated [Image optimization](https://www.11ty.dev/docs/plugins/image/)
|
||||
- Zero-JavaScript output.
|
||||
- Support for modern image formats automatically (e.g. AVIF and WebP)
|
||||
- Processes images on-request during `--serve` for speedy local builds.
|
||||
- Prefers `<img>` markup if possible (single image format) but switches automatically to `<picture>` for multiple image formats.
|
||||
- Automated `<picture>` syntax markup with `srcset` and optional `sizes`
|
||||
- Includes `width`/`height` attributes to avoid [content layout shift](https://web.dev/cls/).
|
||||
- Includes `loading="lazy"` for native lazy loading without JavaScript.
|
||||
- Includes [`decoding="async"`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/decoding)
|
||||
- Images can be co-located with blog post files.
|
||||
- Per page CSS bundles [via `eleventy-plugin-bundle`](https://github.com/11ty/eleventy-plugin-bundle).
|
||||
- Built-in [syntax highlighter](https://www.11ty.dev/docs/plugins/syntaxhighlight/) (zero-JavaScript output).
|
||||
- Draft content: use `draft: true` to mark any template as a draft. Drafts are **only** included during `--serve`/`--watch` and are excluded from full builds. This is driven by the `addPreprocessor` configuration API in `eleventy.config.js`. Schema validator will show an error if non-boolean value is set in data cascade.
|
||||
- Blog Posts
|
||||
- Automated next/previous links
|
||||
- Accessible deep links to headings
|
||||
- Generated Pages
|
||||
- Home, Archive, and About pages.
|
||||
- [Atom feed included (with easy one-line swap to use RSS or JSON)](https://www.11ty.dev/docs/plugins/rss/)
|
||||
- `sitemap.xml`
|
||||
- Zero-maintenance tag pages ([View on the Demo](https://eleventy-base-blog.netlify.app/tags/))
|
||||
- Content not found (404) page
|
||||
|
||||
## Demos
|
||||
|
||||
- [Netlify](https://eleventy-base-blog.netlify.app/)
|
||||
- [Vercel](https://demo-base-blog.11ty.dev/)
|
||||
- [Cloudflare Pages](https://eleventy-base-blog-d2a.pages.dev/)
|
||||
- [GitHub Pages](https://11ty.github.io/eleventy-base-blog/)
|
||||
|
||||
## Deploy this to your own site
|
||||
|
||||
Deploy this Eleventy site in just a few clicks on these services:
|
||||
|
||||
- Read more about [Deploying an Eleventy project](https://www.11ty.dev/docs/deployment/) to the web.
|
||||
- [Deploy this to **Netlify**](https://app.netlify.com/start/deploy?repository=https://github.com/11ty/eleventy-base-blog)
|
||||
- [Deploy this to **Vercel**](https://vercel.com/import/project?template=11ty%2Feleventy-base-blog)
|
||||
- Look in `.github/workflows/gh-pages.yml.sample` for information on [Deploying to **GitHub Pages**](https://www.11ty.dev/docs/deployment/#deploy-an-eleventy-project-to-git-hub-pages).
|
||||
- [Try it out on **Stackblitz**](https://stackblitz.com/github/11ty/eleventy-base-blog)
|
||||
|
||||
### Implementation Notes
|
||||
|
||||
- `content/about/index.md` is an example of a content page.
|
||||
- `content/blog/` has the blog posts but really they can live in any directory. They need only the `posts` tag to be included in the blog posts [collection](https://www.11ty.dev/docs/collections/).
|
||||
- Use the `eleventyNavigation` key (via the [Eleventy Navigation plugin](https://www.11ty.dev/docs/plugins/navigation/)) in your front matter to add a template to the top level site navigation. This is in use on `content/index.njk` and `content/about/index.md`.
|
||||
- Content can be in _any template format_ (blog posts needn’t exclusively be markdown, for example). Configure your project’s supported templates in `eleventy.config.js` -> `templateFormats`.
|
||||
- The `public` folder in your input directory will be copied to the output folder (via `addPassthroughCopy` in the `eleventy.config.js` file). This means `./public/css/*` will live at `./_site/css/*` after your build completes.
|
||||
- This project uses three [Eleventy Layouts](https://www.11ty.dev/docs/layouts/):
|
||||
- `_includes/layouts/base.njk`: the top level HTML structure
|
||||
- `_includes/layouts/home.njk`: the home page template (wrapped into `base.njk`)
|
||||
- `_includes/layouts/post.njk`: the blog post template (wrapped into `base.njk`)
|
||||
- `_includes/postslist.njk` is a Nunjucks include and is a reusable component used to display a list of all the posts. `content/index.njk` has an example of how to use it.
|
||||
|
||||
#### Content Security Policy
|
||||
|
||||
If your site enforces a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) (as public-facing sites should), you have a few choices (pick one):
|
||||
|
||||
1. In `base.njk`, remove `<style>{% getBundle "css" %}</style>` and uncomment `<link rel="stylesheet" href="{% getBundleFileUrl "css" %}">`
|
||||
2. Configure the server with the CSP directive `style-src: 'unsafe-inline'` (less secure).
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
import { DateTime } from "luxon";
|
||||
|
||||
export default function(eleventyConfig) {
|
||||
eleventyConfig.addFilter("readableDate", (dateObj, format, zone) => {
|
||||
// Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
|
||||
return DateTime.fromJSDate(dateObj, { zone: zone || "utc" }).toFormat(format || "dd LLLL yyyy");
|
||||
});
|
||||
|
||||
eleventyConfig.addFilter("htmlDateString", (dateObj) => {
|
||||
// dateObj input: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
|
||||
return DateTime.fromJSDate(dateObj, { zone: "utc" }).toFormat('yyyy-LL-dd');
|
||||
});
|
||||
|
||||
// Get the first `n` elements of a collection.
|
||||
eleventyConfig.addFilter("head", (array, n) => {
|
||||
if(!Array.isArray(array) || array.length === 0) {
|
||||
return [];
|
||||
}
|
||||
if( n < 0 ) {
|
||||
return array.slice(n);
|
||||
}
|
||||
|
||||
return array.slice(0, n);
|
||||
});
|
||||
|
||||
// Return the smallest number argument
|
||||
eleventyConfig.addFilter("min", (...numbers) => {
|
||||
return Math.min.apply(null, numbers);
|
||||
});
|
||||
|
||||
// Return the keys used in an object
|
||||
eleventyConfig.addFilter("getKeys", target => {
|
||||
return Object.keys(target);
|
||||
});
|
||||
|
||||
eleventyConfig.addFilter("filterTagList", function filterTagList(tags) {
|
||||
return (tags || []).filter(tag => ["all", "posts"].indexOf(tag) === -1);
|
||||
});
|
||||
|
||||
eleventyConfig.addFilter("sortAlphabetically", strings =>
|
||||
(strings || []).sort((b, a) => b.localeCompare(a))
|
||||
);
|
||||
};
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import { z } from "zod";
|
||||
import { fromZodError } from 'zod-validation-error';
|
||||
|
||||
// Draft content, validate `draft` front matter
|
||||
export default function() {
|
||||
return function(data) {
|
||||
// Note that drafts may be skipped in a preprocessor (see eleventy.config.js)
|
||||
// when doing a standard build (not --serve or --watch)
|
||||
let result = z.object({
|
||||
draft: z.boolean().or(z.undefined()),
|
||||
}).safeParse(data);
|
||||
|
||||
if(result.error) {
|
||||
throw fromZodError(result.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
export default {
|
||||
title: "Web Blog",
|
||||
url: "https://webblog.anthonyhughes.art",
|
||||
language: "en",
|
||||
description: "Musings of a neurodivergent cynic.",
|
||||
author: {
|
||||
name: "Anthony Hughes",
|
||||
email: "anthony@anthonyhughes.art",
|
||||
url: "https://anthonyhughes.art/about-me/"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
<!doctype html>
|
||||
<html lang="{{ metadata.language }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ title or metadata.title }} ➟ Anthony Hughes . art</title>
|
||||
<meta name="description" content="{{ description or metadata.description }}">
|
||||
<link rel="alternate" href="/feed/feed.xml" type="application/atom+xml" title="{{ metadata.title }}">
|
||||
|
||||
<!-- Favicons -->
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
|
||||
{#- Uncomment this if you’d like folks to know that you used Eleventy to build your site! #}
|
||||
{#- <meta name="generator" content="{{ eleventy.generator }}"> #}
|
||||
|
||||
{#-
|
||||
Plain-text bundles are provided via the `eleventy-plugin-bundle` plugin:
|
||||
1. CSS:
|
||||
* Add to a per-page bundle using `{% css %}{% endcss %}`
|
||||
* Retrieve bundle content using `{% getBundle "css" %}` or `{% getBundleFileUrl "css" %}`
|
||||
2. Or for JavaScript:
|
||||
* Add to a per-page bundle using `{% js %}{% endjs %}`
|
||||
* Retrieve via `{% getBundle "js" %}` or `{% getBundleFileUrl "js" %}`
|
||||
3. Learn more: https://github.com/11ty/eleventy-plugin-bundle
|
||||
#}
|
||||
|
||||
{#- Add CSS to the bundle #}
|
||||
<style>/* This is an arbitrary CSS string added to the bundle */</style>
|
||||
|
||||
{#- Add the contents of a file to the bundle #}
|
||||
<style>{% include "css/index.css" %}</style>
|
||||
|
||||
{#- Or you can add from node_modules #}
|
||||
{# <style>{% include "node_modules/something.css" %}</style> #}
|
||||
|
||||
{#- Render the CSS bundle using inlined CSS (for the fastest site performance in production) #}
|
||||
<style>{% getBundle "css" %}</style>
|
||||
|
||||
{#- Renders the CSS bundle using a separate file, if you can't set CSP directive style-src: 'unsafe-inline' #}
|
||||
{#- <link rel="stylesheet" href="{% getBundleFileUrl "css" %}"> #}
|
||||
|
||||
{#- Add the heading-anchors web component to the JavaScript bundle #}
|
||||
<script type="module">{% include "node_modules/@zachleat/heading-anchors/heading-anchors.js" %}</script>
|
||||
</head>
|
||||
<body>
|
||||
<a href="#main" id="skip-link" class="visually-hidden">Skip to main content</a>
|
||||
|
||||
<header>
|
||||
<div style="text-align:center;">
|
||||
<img src="/images/anthonyhughesdotart-hero.svg" alt="Anthony Hughes dot Art Hero Image" style="max-width:50%;" eleventy:ignore />
|
||||
</div>
|
||||
|
||||
<h2><a href="/" class="home-link">{{ metadata.title }}</a></h2>
|
||||
|
||||
|
||||
{#- Read more about `eleventy-navigation` at https://www.11ty.dev/docs/plugins/navigation/ #}
|
||||
<nav>
|
||||
<h2 class="visually-hidden">Top level navigation menu</h2>
|
||||
<ul class="nav">
|
||||
{%- for entry in collections.all | eleventyNavigation %}
|
||||
<li class="nav-item"><a href="{{ entry.url }}"{% if entry.url == page.url %} aria-current="page"{% endif %}>{{ entry.title }}</a></li>
|
||||
{%- endfor %}
|
||||
<li class="nav-item"><a href="" aria="">Subscribe</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main id="main">
|
||||
<heading-anchors>
|
||||
{{ content | safe }}
|
||||
</heading-anchors>
|
||||
</main>
|
||||
|
||||
<footer style="margin-top:8rem;">
|
||||
<div style="text-align:center">
|
||||
<img src="/images/footer.svg" alt="Anthony Hughes dot Art Footer Image" style="max-width:50%;" eleventy:ignore />
|
||||
|
||||
<p style="text-align:center; font-size:small;"> Made in 🏴 <br />All content licensed <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons BY-NC-ND 4.0</a> unless otherwise indicated.</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- This page `{{ page.url }}` was built on {% currentBuildDate %} -->
|
||||
<script type="module" src="{% getBundleFileUrl "js" %}"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
layout: layouts/base.njk
|
||||
---
|
||||
<!--
|
||||
Delete this block, which will also remove the component CSS from the bundle
|
||||
<style>{% include "css/message-box.css" %}</style>
|
||||
<div class="message-box">
|
||||
<ol>
|
||||
<li>Edit <code>_data/metadata.js</code> with your blog’s information.</li>
|
||||
<li>(Optional) Edit <code>eleventy.config.js</code> with your <a href="https://www.11ty.dev/docs/config/">configuration preferences</a>.</li>
|
||||
<li>Delete this message from <code>_includes/layouts/home.njk</code>.</li>
|
||||
</ol>
|
||||
<p><em>This is an <a href="https://www.11ty.dev/">Eleventy project</a> created from the <a href="https://github.com/11ty/eleventy-base-blog"><code>eleventy-base-blog</code> repo</a>.</em></p>
|
||||
</div>
|
||||
-->
|
||||
|
||||
{{ content | safe }}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
layout: layouts/base.njk
|
||||
---
|
||||
{# Only include the syntax highlighter CSS on blog posts, included with the CSS per-page bundle #}
|
||||
<style>{% include "node_modules/prismjs/themes/prism-okaidia.css" %}</style>
|
||||
<style>{% include "css/prism-diff.css" %}</style>
|
||||
<h1>{{ title }}</h1>
|
||||
|
||||
<ul class="post-metadata">
|
||||
<li><time datetime="{{ page.date | htmlDateString }}">{{ page.date | readableDate }}</time></li>
|
||||
{%- for tag in tags | filterTagList %}
|
||||
{%- set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
|
||||
<li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a>{%- if not loop.last %}, {% endif %}</li>
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
|
||||
{{ content | safe }}
|
||||
|
||||
{%- if collections.posts %}
|
||||
{%- set previousPost = collections.posts | getPreviousCollectionItem %}
|
||||
{%- set nextPost = collections.posts | getNextCollectionItem %}
|
||||
{%- if nextPost or previousPost %}
|
||||
<ul class="links-nextprev">
|
||||
{%- if previousPost %}<li class="links-nextprev-prev">← Previous<br> <a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a></li>{% endif %}
|
||||
{%- if nextPost %}<li class="links-nextprev-next">Next →<br><a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a></li>{% endif %}
|
||||
</ul>
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<ol reversed class="postlist" style="--postlist-index: {{ (postslistCounter or postslist.length) + 1 }}">
|
||||
{%- for post in postslist | reverse %}
|
||||
<li class="postlist-item{% if post.url == url %} postlist-item-active{% endif %}">
|
||||
<a href="{{ post.url }}" class="postlist-link">{% if post.data.title %}{{ post.data.title }}{% else %}<code>{{ post.url }}</code>{% endif %}</a>
|
||||
<time class="postlist-date" datetime="{{ post.date | htmlDateString }}">{{ post.date | readableDate("LLLL yyyy") }}</time>
|
||||
</li>
|
||||
{%- endfor %}
|
||||
</ol>
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
permalink: 404.html
|
||||
eleventyExcludeFromCollections: true
|
||||
---
|
||||
# Content not found.
|
||||
|
||||
Go <a href="index.njk">home</a>.
|
||||
|
||||
<!--
|
||||
|
||||
Read more: https://www.11ty.dev/docs/quicktips/not-found/
|
||||
|
||||
This is compatible with:
|
||||
|
||||
- GitHub Pages: https://help.github.com/articles/creating-a-custom-404-page-for-your-github-pages-site/
|
||||
- GitLab Pages: https://docs.gitlab.com/ee/user/project/pages/introduction.html#custom-error-codes-pages
|
||||
- Netlify: https://www.netlify.com/docs/redirects/#custom-404
|
||||
- Cloudflare Pages: https://developers.cloudflare.com/pages/platform/serving-pages/#not-found-behavior
|
||||
- Vercel: https://vercel.com/guides/custom-404-page#static-site-generator-ssg
|
||||
-->
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
---js
|
||||
const eleventyNavigation = {
|
||||
key: "About",
|
||||
order: 2
|
||||
};
|
||||
---
|
||||
# About
|
||||
|
||||
I am a person that writes stuff.
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
---js
|
||||
const eleventyNavigation = {
|
||||
key: "Archive",
|
||||
order: 2
|
||||
};
|
||||
---
|
||||
<h1>Archive</h1>
|
||||
|
||||
{% set postslist = collections.posts %}
|
||||
{% include "postslist.njk" %}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
export default {
|
||||
tags: [
|
||||
"posts"
|
||||
],
|
||||
"layout": "layouts/post.njk",
|
||||
};
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
---js
|
||||
const title = "This is a fifth post";
|
||||
const date = "2023-01-23";
|
||||
const draft = true;
|
||||
---
|
||||
This is a draft post
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
---
|
||||
title: This is my first post.
|
||||
description: This is a post on My Blog about agile frameworks.
|
||||
date: 2018-05-01
|
||||
tags: another tag
|
||||
---
|
||||
Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
|
||||
|
||||
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
|
||||
|
||||
## Section Header
|
||||
|
||||
Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
|
||||
|
||||
```diff-js
|
||||
// this is a command
|
||||
function myCommand() {
|
||||
+ let counter = 0;
|
||||
- let counter = 1;
|
||||
counter++;
|
||||
}
|
||||
|
||||
// Test with a line break above this line.
|
||||
console.log('Test');
|
||||
```
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
title: This is my fourth post
|
||||
description: This is a post on My Blog about touchpoints and circling wagons.
|
||||
date: 2018-09-30
|
||||
tags: second tag
|
||||
draft: true
|
||||
---
|
||||
Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
|
||||
|
||||
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
|
||||
|
||||
<img src="./possum.png" alt="A possum parent and two possum kids hanging from the iconic red balloon">
|
||||
|
||||
## Section Header
|
||||
|
||||
Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 127 KiB |
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
title: This is my second post with a much longer title.
|
||||
description: This is a post on My Blog about leveraging agile frameworks.
|
||||
date: 2018-07-04
|
||||
tags: number 2
|
||||
draft: true
|
||||
---
|
||||
Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
|
||||
|
||||
## Section Header
|
||||
|
||||
<a href="/blog/firstpost.md">First post</a>
|
||||
<a href="blog/thirdpost.md">Third post</a>
|
||||
|
||||
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
|
||||
|
||||
Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
---
|
||||
title: This is my third post.
|
||||
description: This is a post on My Blog about win-win survival strategies.
|
||||
date: 2018-08-24
|
||||
tags: ["second tag", "posts with two tags"]
|
||||
draft: true
|
||||
---
|
||||
Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.
|
||||
|
||||
## Code
|
||||
|
||||
### This is a very long heading that I want to wrap This is a very long heading that I want to wrap This is a very long heading that I want to wrap This is a very long heading that I want to wrap
|
||||
|
||||
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
|
||||
|
||||
```js
|
||||
// this is a command
|
||||
function myCommand() {
|
||||
let counter = 0;
|
||||
counter++;
|
||||
}
|
||||
|
||||
// Test with a line break above this line.
|
||||
console.log('Test');
|
||||
```
|
||||
|
||||
### Heading with a [link](#code)
|
||||
|
||||
Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.
|
||||
|
||||
```
|
||||
// this is a command
|
||||
function myCommand() {
|
||||
let counter = 0;
|
||||
counter++;
|
||||
}
|
||||
|
||||
// Test with a line break above this line.
|
||||
console.log('Test');
|
||||
```
|
||||
|
||||
## Section Header
|
||||
|
||||
Capitalize on low hanging fruit to identify a ballpark value added activity to beta test. Override the digital divide with additional clickthroughs from DevOps. Nanotechnology immersion along the information highway will close the loop on focusing solely on the bottom line.
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export default {
|
||||
layout: "layouts/home.njk",
|
||||
};
|
||||
|
|
@ -1 +0,0 @@
|
|||
For RSS feed, Atom Feed, and JSON feed templates, see the plugin in eleventy.config.js
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,29 +0,0 @@
|
|||
---js
|
||||
const eleventyNavigation = {
|
||||
key: "Home",
|
||||
order: 1
|
||||
};
|
||||
|
||||
const numberOfLatestPostsToShow = 3;
|
||||
---
|
||||
{% set postsCount = collections.posts | length %}
|
||||
{% set latestPostsCount = postsCount | min(numberOfLatestPostsToShow) %}
|
||||
<h1>Latest {{ latestPostsCount }} Post{% if latestPostsCount != 1 %}s{% endif %}</h1>
|
||||
|
||||
{% set postslist = collections.posts | head(-1 * numberOfLatestPostsToShow) %}
|
||||
{% set postslistCounter = postsCount %}
|
||||
{% include "postslist.njk" %}
|
||||
|
||||
{% set morePosts = postsCount - numberOfLatestPostsToShow %}
|
||||
{% if morePosts > 0 %}
|
||||
<p>{{ morePosts }} more post{% if morePosts != 1 %}s{% endif %} can be found in <a href="blog.njk">the archive</a>.</p>
|
||||
{% endif %}
|
||||
|
||||
{# List every content page in the project #}
|
||||
{#
|
||||
<ul>
|
||||
{%- for entry in collections.all %}
|
||||
<li><a href="{{ entry.url }}"><code>{{ entry.url }}</code></a></li>
|
||||
{%- endfor %}
|
||||
</ul>
|
||||
#}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
---
|
||||
permalink: /sitemap.xml
|
||||
layout: false
|
||||
eleventyExcludeFromCollections: true
|
||||
---
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
||||
{%- for page in collections.all %}
|
||||
{% if page.data.permalink != false %}
|
||||
{% set absoluteUrl %}{{ page.url | htmlBaseUrl(metadata.url) }}{% endset %}
|
||||
<url>
|
||||
<loc>{{ absoluteUrl }}</loc>
|
||||
<lastmod>{{ page.date | htmlDateString }}</lastmod>
|
||||
</url>
|
||||
{% endif %}
|
||||
{%- endfor %}
|
||||
</urlset>
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
---js
|
||||
// <script>
|
||||
const pagination = {
|
||||
data: "collections",
|
||||
size: 1,
|
||||
alias: "tag",
|
||||
filter: ["all", "posts"],
|
||||
// addAllPagesToCollections: true,
|
||||
};
|
||||
|
||||
const eleventyExcludeFromCollections = true;
|
||||
|
||||
const eleventyComputed = {
|
||||
title: "Tagged '{{ tag }}'",
|
||||
permalink: function(data) {
|
||||
// If DuplicatePermalinkOutputError occurs, check that no tag occurs
|
||||
// with differing case, e.g. "RSS" and "rss".
|
||||
return `/tags/${this.slugify(data.tag)}/`;
|
||||
}
|
||||
};
|
||||
---
|
||||
<h1>Tagged “{{ tag }}”</h1>
|
||||
|
||||
{% set postslist = collections[ tag ] %}
|
||||
{% include "postslist.njk" %}
|
||||
|
||||
<p>See <a href="tags.njk">all tags</a>.</p>
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<h1>Tags</h1>
|
||||
|
||||
<ul>
|
||||
{% for tag in collections | getKeys | filterTagList | sortAlphabetically %}
|
||||
{% set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
|
||||
<li><a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
528
css/index.css
528
css/index.css
|
|
@ -1,528 +0,0 @@
|
|||
/* Fonts */
|
||||
|
||||
/* ===== Atkinson Hyperlegible Next ===== */
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-ExtraLight.woff2') format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-ExtraLightItalic.woff2') format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-Light.woff2') format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-LightItalic.woff2') format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-Regular.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-RegularItalic.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-Medium.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-MediumItalic.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-SemiBold.woff2') format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-SemiBoldItalic.woff2') format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-Bold.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-BoldItalic.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-ExtraBold.woff2') format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Next';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Next/AtkinsonHyperlegibleNext-ExtraBoldItalic.woff2') format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
|
||||
/* ===== Atkinson Hyperlegible Mono ===== */
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-ExtraLight.woff2') format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-ExtraLightItalic.woff2') format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-Light.woff2') format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-LightItalic.woff2') format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-Regular.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-RegularItalic.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-Medium.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-MediumItalic.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-SemiBold.woff2') format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-SemiBoldItalic.woff2') format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-Bold.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-BoldItalic.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-ExtraBold.woff2') format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Atkinson Hyperlegible Mono';
|
||||
src: url('/fonts/Atkinson/Hyperlegible/Mono/AtkinsonHyperlegibleMono-ExtraBoldItalic.woff2') format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
/* Defaults */
|
||||
:root {
|
||||
--font-family: Atkinson Hyperlegible Next, -apple-system, system-ui, sans-serif;
|
||||
--font-family-monospace: Atkinson Hyperlegible Mono, Consolas, Menlo, Monaco, Andale Mono WT, Andale Mono, Lucida Console, Lucida Sans Typewriter, DejaVu Sans Mono, Bitstream Vera Sans Mono, Liberation Mono, Nimbus Mono L, Courier New, Courier, monospace;
|
||||
}
|
||||
|
||||
/* Theme colors */
|
||||
:root {
|
||||
--color-gray-20: #e0e0e0;
|
||||
--color-gray-50: #C0C0C0;
|
||||
--color-gray-90: #333;
|
||||
--color-aha-text: #29294f;
|
||||
|
||||
--background-color: #fff8ef;
|
||||
|
||||
--text-color: var(--color-aha-text);
|
||||
--text-color-link: #29294f;
|
||||
--text-color-link-active: #29294f;
|
||||
--text-color-link-visited: #17050F;
|
||||
|
||||
--syntax-tab-size: 2;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--color-gray-20: #e0e0e0;
|
||||
--color-gray-50: #C0C0C0;
|
||||
--color-gray-90: #dad8d8;
|
||||
|
||||
/* --text-color is assigned to --color-gray-_ above */
|
||||
--text-color-link: #1493fb;
|
||||
--text-color-link-active: #6969f7;
|
||||
--text-color-link-visited: #a6a6f8;
|
||||
|
||||
--background-color: #15202b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Global stylesheet */
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@view-transition {
|
||||
navigation: auto;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0 auto;
|
||||
font-family: var(--font-family);
|
||||
color: var(--text-color);
|
||||
background-color: var(--background-color);
|
||||
}
|
||||
html {
|
||||
overflow-y: scroll;
|
||||
}
|
||||
body {
|
||||
max-width: 40em;
|
||||
}
|
||||
|
||||
/* https://www.a11yproject.com/posts/how-to-hide-content/ */
|
||||
.visually-hidden:not(:focus):not(:active) {
|
||||
clip: rect(0 0 0 0);
|
||||
clip-path: inset(50%);
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
/* Fluid images via https://www.zachleat.com/web/fluid-images/ */
|
||||
img{
|
||||
max-width: 100%;
|
||||
}
|
||||
img[width][height] {
|
||||
height: auto;
|
||||
}
|
||||
img[src$=".svg"] {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-width: none;
|
||||
}
|
||||
video,
|
||||
iframe {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
iframe {
|
||||
aspect-ratio: 16/9;
|
||||
}
|
||||
|
||||
p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
p {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
li {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
a[href] {
|
||||
color: var(--text-color-link);
|
||||
}
|
||||
a[href]:visited {
|
||||
color: var(--text-color-link-visited);
|
||||
}
|
||||
a[href]:hover,
|
||||
a[href]:active {
|
||||
color: var(--text-color-link-active);
|
||||
}
|
||||
|
||||
main,
|
||||
footer {
|
||||
padding: 1rem;
|
||||
}
|
||||
main :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
header {
|
||||
border-bottom: 1px dashed var(--color-gray-20);
|
||||
}
|
||||
|
||||
#skip-link {
|
||||
text-decoration: none;
|
||||
background: var(--background-color);
|
||||
color: var(--text-color);
|
||||
padding: 0.5rem 1rem;
|
||||
border: 1px solid var(--color-gray-90);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* Prevent visually-hidden skip link fom pushing content around when focused */
|
||||
#skip-link.visually-hidden:focus {
|
||||
position: absolute;
|
||||
top: 1rem;
|
||||
left: 1rem;
|
||||
/* Ensure it is positioned on top of everything else when it is shown */
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.links-nextprev {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: .5em 1em;
|
||||
list-style: "";
|
||||
border-top: 1px dashed var(--color-gray-20);
|
||||
padding: 1em 0;
|
||||
}
|
||||
.links-nextprev > * {
|
||||
flex-grow: 1;
|
||||
}
|
||||
.links-nextprev-next {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
table {
|
||||
margin: 1em 0;
|
||||
}
|
||||
table td,
|
||||
table th {
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
pre,
|
||||
code {
|
||||
font-family: var(--font-family-monospace);
|
||||
}
|
||||
pre:not([class*="language-"]) {
|
||||
margin: .5em 0;
|
||||
line-height: 1.375; /* 22px /16 */
|
||||
-moz-tab-size: var(--syntax-tab-size);
|
||||
-o-tab-size: var(--syntax-tab-size);
|
||||
tab-size: var(--syntax-tab-size);
|
||||
-webkit-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
overflow-x: auto;
|
||||
}
|
||||
code {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
header {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1em;
|
||||
}
|
||||
.home-link {
|
||||
flex-grow: 1;
|
||||
font-size: 1em; /* 16px /16 */
|
||||
font-weight: 700;
|
||||
}
|
||||
.home-link:link:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Nav */
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: .5em 1em;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.nav-item {
|
||||
display: inline-block;
|
||||
}
|
||||
.nav-item a[href]:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
.nav a[href][aria-current="page"] {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* Posts list */
|
||||
.postlist {
|
||||
counter-reset: start-from var(--postlist-index);
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
.postlist-item {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
counter-increment: start-from -1;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.postlist-item:before {
|
||||
display: inline-block;
|
||||
pointer-events: none;
|
||||
content: "" counter(start-from, decimal-leading-zero) ". ";
|
||||
line-height: 100%;
|
||||
text-align: right;
|
||||
margin-left: -1.5rem;
|
||||
}
|
||||
.postlist-date,
|
||||
.postlist-item:before {
|
||||
font-size: 0.8125em; /* 13px /16 */
|
||||
color: var(--color-gray-90);
|
||||
}
|
||||
.postlist-date {
|
||||
word-spacing: -0.5px;
|
||||
}
|
||||
.postlist-link {
|
||||
font-size: 1.1875em; /* 19px /16 */
|
||||
font-weight: 700;
|
||||
flex-basis: calc(100% - 1.5rem);
|
||||
padding-left: .25em;
|
||||
padding-right: .5em;
|
||||
text-underline-position: from-font;
|
||||
text-underline-offset: 0;
|
||||
text-decoration-thickness: 1px;
|
||||
}
|
||||
.postlist-item-active .postlist-link {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Tags */
|
||||
.post-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-transform: capitalize;
|
||||
font-style: italic;
|
||||
}
|
||||
.postlist-item > .post-tag {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
/* Tags list */
|
||||
.post-metadata {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .5em;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.post-metadata time {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* Message Box */
|
||||
.message-box {
|
||||
--color-message-box: #ffc;
|
||||
|
||||
display: block;
|
||||
background-color: var(--color-message-box);
|
||||
color: var(--color-gray-90);
|
||||
padding: 1em 0.625em; /* 16px 10px /16 */
|
||||
}
|
||||
.message-box ol {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.message-box {
|
||||
--color-message-box: #082840;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* New diff- syntax
|
||||
*/
|
||||
|
||||
pre[class*="language-diff-"] {
|
||||
--eleventy-code-padding: 1.25em;
|
||||
padding-left: var(--eleventy-code-padding);
|
||||
padding-right: var(--eleventy-code-padding);
|
||||
}
|
||||
.token.deleted {
|
||||
background-color: hsl(0, 51%, 37%);
|
||||
color: inherit;
|
||||
}
|
||||
.token.inserted {
|
||||
background-color: hsl(126, 31%, 39%);
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* Make the + and - characters unselectable for copy/paste */
|
||||
.token.prefix.unchanged,
|
||||
.token.prefix.inserted,
|
||||
.token.prefix.deleted {
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
.token.prefix.inserted,
|
||||
.token.prefix.deleted {
|
||||
width: var(--eleventy-code-padding);
|
||||
background-color: rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
/* Optional: full-width background color */
|
||||
.token.inserted:not(.prefix),
|
||||
.token.deleted:not(.prefix) {
|
||||
display: block;
|
||||
margin-left: calc(-1 * var(--eleventy-code-padding));
|
||||
margin-right: calc(-1 * var(--eleventy-code-padding));
|
||||
text-decoration: none; /* override del, ins, mark defaults */
|
||||
color: inherit; /* override del, ins, mark defaults */
|
||||
}
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
import { IdAttributePlugin, InputPathToUrlTransformPlugin, HtmlBasePlugin } from "@11ty/eleventy";
|
||||
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
|
||||
import pluginSyntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
|
||||
import pluginNavigation from "@11ty/eleventy-navigation";
|
||||
import { eleventyImageTransformPlugin } from "@11ty/eleventy-img";
|
||||
|
||||
import pluginFilters from "./_config/filters.js";
|
||||
|
||||
/** @param {import("@11ty/eleventy").UserConfig} eleventyConfig */
|
||||
export default async function(eleventyConfig) {
|
||||
// Drafts, see also _data/eleventyDataSchema.js
|
||||
eleventyConfig.addPreprocessor("drafts", "*", (data, content) => {
|
||||
if (data.draft) {
|
||||
data.title = `${data.title} (draft)`;
|
||||
}
|
||||
|
||||
if(data.draft && process.env.ELEVENTY_RUN_MODE === "build") {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Copy the contents of the `public` folder to the output folder
|
||||
// For example, `./public/css/` ends up in `_site/css/`
|
||||
eleventyConfig
|
||||
.addPassthroughCopy({
|
||||
"./public/": "/"
|
||||
})
|
||||
.addPassthroughCopy("./content/feed/pretty-atom-feed.xsl");
|
||||
|
||||
// FONTS
|
||||
eleventyConfig
|
||||
.addPassthroughCopy({
|
||||
"./fonts/": "/fonts"
|
||||
});
|
||||
|
||||
|
||||
// Run Eleventy when these files change:
|
||||
// https://www.11ty.dev/docs/watch-serve/#add-your-own-watch-targets
|
||||
|
||||
// Watch CSS files
|
||||
eleventyConfig.addWatchTarget("css/**/*.css");
|
||||
// Watch images for the image pipeline.
|
||||
eleventyConfig.addWatchTarget("content/**/*.{svg,webp,png,jpg,jpeg,gif}");
|
||||
|
||||
// Per-page bundles, see https://github.com/11ty/eleventy-plugin-bundle
|
||||
// Bundle <style> content and adds a {% css %} paired shortcode
|
||||
eleventyConfig.addBundle("css", {
|
||||
toFileDirectory: "dist",
|
||||
// Add all <style> content to `css` bundle (use <style eleventy:ignore> to opt-out)
|
||||
// Supported selectors: https://www.npmjs.com/package/posthtml-match-helper
|
||||
bundleHtmlContentFromSelector: "style",
|
||||
});
|
||||
|
||||
// Bundle <script> content and adds a {% js %} paired shortcode
|
||||
eleventyConfig.addBundle("js", {
|
||||
toFileDirectory: "dist",
|
||||
// Add all <script> content to the `js` bundle (use <script eleventy:ignore> to opt-out)
|
||||
// Supported selectors: https://www.npmjs.com/package/posthtml-match-helper
|
||||
bundleHtmlContentFromSelector: "script",
|
||||
});
|
||||
|
||||
// Official plugins
|
||||
eleventyConfig.addPlugin(pluginSyntaxHighlight, {
|
||||
preAttributes: { tabindex: 0 }
|
||||
});
|
||||
eleventyConfig.addPlugin(pluginNavigation);
|
||||
eleventyConfig.addPlugin(HtmlBasePlugin);
|
||||
eleventyConfig.addPlugin(InputPathToUrlTransformPlugin);
|
||||
|
||||
eleventyConfig.addPlugin(feedPlugin, {
|
||||
type: "atom", // or "rss", "json"
|
||||
outputPath: "/feed/feed.xml",
|
||||
stylesheet: "pretty-atom-feed.xsl",
|
||||
templateData: {
|
||||
eleventyNavigation: {
|
||||
key: "Feed",
|
||||
order: 4
|
||||
}
|
||||
},
|
||||
collection: {
|
||||
name: "posts",
|
||||
limit: 10,
|
||||
},
|
||||
metadata: {
|
||||
language: "en",
|
||||
title: "Web Blog",
|
||||
subtitle: "Musings of a neurodivergent cynic.",
|
||||
base: "https://webblog.anthonyhughes.art",
|
||||
author: {
|
||||
name: "Anthony Hughes"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Image optimization: https://www.11ty.dev/docs/plugins/image/#eleventy-transform
|
||||
eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
|
||||
// Output formats for each image.
|
||||
formats: ["avif", "webp", "auto"],
|
||||
|
||||
// widths: ["auto"],
|
||||
|
||||
failOnError: false,
|
||||
htmlOptions: {
|
||||
imgAttributes: {
|
||||
// e.g. <img loading decoding> assigned on the HTML tag will override these values.
|
||||
loading: "lazy",
|
||||
decoding: "async",
|
||||
}
|
||||
},
|
||||
|
||||
sharpOptions: {
|
||||
animated: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Filters
|
||||
eleventyConfig.addPlugin(pluginFilters);
|
||||
|
||||
eleventyConfig.addPlugin(IdAttributePlugin, {
|
||||
// by default we use Eleventy’s built-in `slugify` filter:
|
||||
// slugify: eleventyConfig.getFilter("slugify"),
|
||||
// selector: "h1,h2,h3,h4,h5,h6", // default
|
||||
});
|
||||
|
||||
eleventyConfig.addShortcode("currentBuildDate", () => {
|
||||
return (new Date()).toISOString();
|
||||
});
|
||||
|
||||
// Features to make your build faster (when you need them)
|
||||
|
||||
// If your passthrough copy gets heavy and cumbersome, add this line
|
||||
// to emulate the file copy on the dev server. Learn more:
|
||||
// https://www.11ty.dev/docs/copy/#emulate-passthrough-copy-during-serve
|
||||
|
||||
// eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
|
||||
};
|
||||
|
||||
export const config = {
|
||||
// Control which files Eleventy will process
|
||||
// e.g.: *.md, *.njk, *.html, *.liquid
|
||||
templateFormats: [
|
||||
"md",
|
||||
"njk",
|
||||
"html",
|
||||
"liquid",
|
||||
"11ty.js",
|
||||
],
|
||||
|
||||
// Pre-process *.md files with: (default: `liquid`)
|
||||
markdownTemplateEngine: "njk",
|
||||
|
||||
// Pre-process *.html files with: (default: `liquid`)
|
||||
htmlTemplateEngine: "njk",
|
||||
|
||||
// These are all optional:
|
||||
dir: {
|
||||
input: "content", // default: "."
|
||||
includes: "../_includes", // default: "_includes" (`input` relative)
|
||||
data: "../_data", // default: "_data" (`input` relative)
|
||||
output: "_site"
|
||||
},
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Optional items:
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
// If your site deploys to a subdirectory, change `pathPrefix`.
|
||||
// Read more: https://www.11ty.dev/docs/config/#deploy-to-a-subdirectory-with-a-path-prefix
|
||||
|
||||
// When paired with the HTML <base> plugin https://www.11ty.dev/docs/plugins/html-base/
|
||||
// it will transform any absolute URLs in your HTML to include this
|
||||
// folder name and does **not** affect where things go in the output folder.
|
||||
|
||||
// pathPrefix: "/",
|
||||
};
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,3 +0,0 @@
|
|||
[build]
|
||||
publish = "_site"
|
||||
command = "npm run build"
|
||||
1
node_modules/.bin/acorn
generated
vendored
1
node_modules/.bin/acorn
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../acorn/bin/acorn
|
||||
1
node_modules/.bin/cross-env
generated
vendored
1
node_modules/.bin/cross-env
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../cross-env/dist/bin/cross-env.js
|
||||
1
node_modules/.bin/cross-env-shell
generated
vendored
1
node_modules/.bin/cross-env-shell
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../cross-env/dist/bin/cross-env-shell.js
|
||||
1
node_modules/.bin/eleventy
generated
vendored
1
node_modules/.bin/eleventy
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../@11ty/eleventy/cmd.cjs
|
||||
1
node_modules/.bin/eleventy-dev-server
generated
vendored
1
node_modules/.bin/eleventy-dev-server
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../@11ty/eleventy-dev-server/cmd.js
|
||||
1
node_modules/.bin/errno
generated
vendored
1
node_modules/.bin/errno
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../errno/cli.js
|
||||
1
node_modules/.bin/esparse
generated
vendored
1
node_modules/.bin/esparse
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../esprima/bin/esparse.js
|
||||
1
node_modules/.bin/esvalidate
generated
vendored
1
node_modules/.bin/esvalidate
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../esprima/bin/esvalidate.js
|
||||
1
node_modules/.bin/image-size
generated
vendored
1
node_modules/.bin/image-size
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../image-size/bin/image-size.js
|
||||
1
node_modules/.bin/js-yaml
generated
vendored
1
node_modules/.bin/js-yaml
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../js-yaml/bin/js-yaml.js
|
||||
1
node_modules/.bin/liquid
generated
vendored
1
node_modules/.bin/liquid
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../liquidjs/bin/liquid.js
|
||||
1
node_modules/.bin/liquidjs
generated
vendored
1
node_modules/.bin/liquidjs
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../liquidjs/bin/liquid.js
|
||||
1
node_modules/.bin/markdown-it
generated
vendored
1
node_modules/.bin/markdown-it
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../markdown-it/bin/markdown-it.mjs
|
||||
1
node_modules/.bin/mime
generated
vendored
1
node_modules/.bin/mime
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../mime/cli.js
|
||||
1
node_modules/.bin/node-which
generated
vendored
1
node_modules/.bin/node-which
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../which/bin/node-which
|
||||
1
node_modules/.bin/nunjucks-precompile
generated
vendored
1
node_modules/.bin/nunjucks-precompile
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../nunjucks/bin/precompile
|
||||
1
node_modules/.bin/semver
generated
vendored
1
node_modules/.bin/semver
generated
vendored
|
|
@ -1 +0,0 @@
|
|||
../semver/bin/semver.js
|
||||
2176
node_modules/.package-lock.json
generated
vendored
2176
node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load diff
21
node_modules/@11ty/dependency-tree-esm/LICENSE
generated
vendored
21
node_modules/@11ty/dependency-tree-esm/LICENSE
generated
vendored
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Zach Leatherman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
53
node_modules/@11ty/dependency-tree-esm/README.md
generated
vendored
53
node_modules/@11ty/dependency-tree-esm/README.md
generated
vendored
|
|
@ -1,53 +0,0 @@
|
|||
# `dependency-tree-esm`
|
||||
|
||||
Returns an unordered array of local paths to dependencies of a Node ES module JavaScript file.
|
||||
|
||||
* See also: [`dependency-tree`](https://github.com/11ty/eleventy-dependency-tree) for the CommonJS version.
|
||||
|
||||
This is used by Eleventy to find dependencies of a JavaScript file to watch for changes to re-run Eleventy’s build.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install --save-dev @11ty/dependency-tree-esm
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
* Ignores bare specifiers (e.g. `import "my-package"`)
|
||||
* Ignores Node’s built-ins (e.g. `import "path"`)
|
||||
* Handles circular dependencies
|
||||
* Returns an empty set if the file does not exist.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// my-file.js
|
||||
|
||||
// if my-local-dependency.js has dependencies, it will include those too
|
||||
import "./my-local-dependency.js";
|
||||
|
||||
|
||||
// ignored, is a built-in
|
||||
import path from "path";
|
||||
```
|
||||
|
||||
```js
|
||||
import { find } from "@11ty/dependency-tree-esm";
|
||||
// CommonJS is fine too
|
||||
// const { find } = require("@11ty/dependency-tree-esm");
|
||||
|
||||
await find("./my-file.js");
|
||||
// returns ["./my-local-dependency.js"]
|
||||
```
|
||||
|
||||
Return a [dependency-graph](https://github.com/jriecken/dependency-graph) instance:
|
||||
|
||||
```js
|
||||
import { findGraph } from "@11ty/dependency-tree-esm";
|
||||
// CommonJS is fine too
|
||||
// const { find } = require("@11ty/dependency-tree-esm");
|
||||
|
||||
(await findGraph("./my-file.js")).overallOrder();
|
||||
// returns ["./my-local-dependency.js", "./my-file.js"]
|
||||
```
|
||||
173
node_modules/@11ty/dependency-tree-esm/main.js
generated
vendored
173
node_modules/@11ty/dependency-tree-esm/main.js
generated
vendored
|
|
@ -1,173 +0,0 @@
|
|||
const path = require("node:path");
|
||||
const { readFileSync, existsSync } = require("node:fs");
|
||||
|
||||
const acorn = require("acorn");
|
||||
const normalizePath = require("normalize-path");
|
||||
const { TemplatePath } = require("@11ty/eleventy-utils");
|
||||
const { DepGraph } = require("dependency-graph");
|
||||
|
||||
// Is *not* a bare specifier (e.g. 'some-package')
|
||||
// https://nodejs.org/dist/latest-v18.x/docs/api/esm.html#terminology
|
||||
function isNonBareSpecifier(importSource) {
|
||||
// Change \\ to / on Windows
|
||||
let normalized = normalizePath(importSource);
|
||||
// Relative specifier (e.g. './startup.js')
|
||||
if(normalized.startsWith("./") || normalized.startsWith("../")) {
|
||||
return true;
|
||||
}
|
||||
// Absolute specifier (e.g. 'file:///opt/nodejs/config.js')
|
||||
if(normalized.startsWith("file:")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function normalizeFilePath(filePath) {
|
||||
return TemplatePath.standardizeFilePath(path.relative(".", filePath));
|
||||
}
|
||||
|
||||
function normalizeImportSourceToFilePath(filePath, source) {
|
||||
let { dir } = path.parse(filePath);
|
||||
let normalized = path.join(dir, source);
|
||||
return normalizeFilePath(normalized);
|
||||
}
|
||||
|
||||
function getImportAttributeType(attributes = []) {
|
||||
for(let node of attributes) {
|
||||
if(node.type === "ImportAttribute" && node.key.type === "Identifier" && node.key.name === "type") {
|
||||
return node.value.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getSources(filePath, contents, options = {}) {
|
||||
let { parserOverride } = Object.assign({}, options);
|
||||
let sources = new Set();
|
||||
let sourcesToRecurse = new Set();
|
||||
|
||||
let ast = (parserOverride || acorn).parse(contents, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
});
|
||||
|
||||
for(let node of ast.body) {
|
||||
if(node.type === "ImportDeclaration" && isNonBareSpecifier(node.source.value)) {
|
||||
let importAttributeType = getImportAttributeType(node?.attributes);
|
||||
let normalized = normalizeImportSourceToFilePath(filePath, node.source.value);
|
||||
if(normalized !== filePath) {
|
||||
sources.add(normalized);
|
||||
|
||||
// Recurse typeless (JavaScript) import types only
|
||||
// Right now only `css` and `json` are valid but others might come later
|
||||
if(!importAttributeType) {
|
||||
sourcesToRecurse.add(normalized);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
sources,
|
||||
sourcesToRecurse,
|
||||
}
|
||||
}
|
||||
|
||||
// second argument used to be `alreadyParsedSet = new Set()`, keep that backwards compat
|
||||
async function find(filePath, options = {}) {
|
||||
if(options instanceof Set) {
|
||||
options = {
|
||||
alreadyParsedSet: options
|
||||
};
|
||||
}
|
||||
|
||||
if(!options.alreadyParsedSet) {
|
||||
options.alreadyParsedSet = new Set();
|
||||
}
|
||||
|
||||
// TODO add a cache here
|
||||
// Unfortunately we need to read the entire file, imports need to be at the top level but they can be anywhere 🫠
|
||||
let normalized = normalizeFilePath(filePath);
|
||||
if(options.alreadyParsedSet.has(normalized) || !existsSync(filePath)) {
|
||||
return [];
|
||||
}
|
||||
options.alreadyParsedSet.add(normalized);
|
||||
|
||||
let contents = readFileSync(normalized, { encoding: 'utf8' });
|
||||
let { sources, sourcesToRecurse } = await getSources(filePath, contents, options);
|
||||
|
||||
// Recurse for nested deps
|
||||
for(let source of sourcesToRecurse) {
|
||||
let s = await find(source, options);
|
||||
for(let p of s) {
|
||||
if(sources.has(p) || p === filePath) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sources.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(sources);
|
||||
}
|
||||
|
||||
function mergeGraphs(rootGraph, ...graphs) {
|
||||
if(!(rootGraph instanceof DepGraph)) {
|
||||
throw new Error("Incorrect type passed to mergeGraphs, expected DepGraph");
|
||||
}
|
||||
for(let g of graphs) {
|
||||
for(let node of g.overallOrder()) {
|
||||
if(!rootGraph.hasNode(node)) {
|
||||
rootGraph.addNode(node);
|
||||
}
|
||||
for(let dep of g.directDependenciesOf(node)) {
|
||||
rootGraph.addDependency(node, dep);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// second argument used to be `alreadyParsedSet = new Set()`, keep that backwards compat
|
||||
async function findGraph(filePath, options = {}) {
|
||||
if(options instanceof Set) {
|
||||
options = {
|
||||
alreadyParsedSet: options
|
||||
};
|
||||
}
|
||||
if(!options.alreadyParsedSet) {
|
||||
options.alreadyParsedSet = new Set();
|
||||
}
|
||||
|
||||
let graph = new DepGraph();
|
||||
let normalized = normalizeFilePath(filePath);
|
||||
graph.addNode(filePath);
|
||||
|
||||
if(options.alreadyParsedSet.has(normalized) || !existsSync(filePath)) {
|
||||
return graph;
|
||||
}
|
||||
options.alreadyParsedSet.add(normalized);
|
||||
|
||||
let contents = readFileSync(normalized, "utf8");
|
||||
let { sources, sourcesToRecurse } = await getSources(filePath, contents, options);
|
||||
for(let source of sources) {
|
||||
if(!graph.hasNode(source)) {
|
||||
graph.addNode(source);
|
||||
}
|
||||
graph.addDependency(normalized, source);
|
||||
}
|
||||
|
||||
// Recurse for nested deps
|
||||
for(let source of sourcesToRecurse) {
|
||||
let recursedGraph = await findGraph(source, options);
|
||||
mergeGraphs(graph, recursedGraph);
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
find,
|
||||
findGraph,
|
||||
mergeGraphs,
|
||||
};
|
||||
26
node_modules/@11ty/dependency-tree-esm/package.json
generated
vendored
26
node_modules/@11ty/dependency-tree-esm/package.json
generated
vendored
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"name": "@11ty/dependency-tree-esm",
|
||||
"version": "2.0.4",
|
||||
"description": "Finds all JavaScript ES Module dependencies from a filename.",
|
||||
"main": "main.js",
|
||||
"type": "commonjs",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: run tests from root directory\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/11ty/eleventy-utils.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Zach Leatherman",
|
||||
"email": "zach@zachleat.com",
|
||||
"url": "https://zachleat.com/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@11ty/eleventy-utils": "^2.0.7",
|
||||
"acorn": "^8.15.0",
|
||||
"dependency-graph": "^1.0.0",
|
||||
"normalize-path": "^3.0.0"
|
||||
}
|
||||
}
|
||||
21
node_modules/@11ty/dependency-tree/LICENSE
generated
vendored
21
node_modules/@11ty/dependency-tree/LICENSE
generated
vendored
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Zach Leatherman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
109
node_modules/@11ty/dependency-tree/README.md
generated
vendored
109
node_modules/@11ty/dependency-tree/README.md
generated
vendored
|
|
@ -1,109 +0,0 @@
|
|||
# `@11ty/dependency-tree`
|
||||
|
||||
Returns an unordered array of local paths to dependencies of a CommonJS node JavaScript file (everything it or any of its dependencies `require`s).
|
||||
|
||||
* See also: [`@11ty/dependency-tree-esm`](https://github.com/11ty/eleventy-utils/tree/main/parse-deps-esm) for the ESM version.
|
||||
* See also: [`@11ty/dependency-tree-typescript`](https://github.com/11ty/eleventy-utils/tree/main/parse-deps-typescript) for the TypeScript version.
|
||||
|
||||
Reduced feature (faster) alternative to the [`dependency-tree` package](https://www.npmjs.com/package/dependency-tree). This is used by Eleventy to find dependencies of a JavaScript file to watch for changes to re-run Eleventy’s build.
|
||||
|
||||
## Big Huge Caveat
|
||||
|
||||
⚠ A big caveat to this plugin is that it will require the file in order to build a dependency tree. So if your module has side effects and you don’t want it to execute—do not use this!
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install --save-dev @11ty/dependency-tree
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
* Ignores `node_modules`
|
||||
* Or, use `nodeModuleNames` to control whether or not `node_modules` package names are included (added in v2.0.1)
|
||||
* Ignores Node’s built-ins (e.g. `path`)
|
||||
* Handles circular dependencies (Node does this too)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// my-file.js
|
||||
|
||||
// if my-local-dependency.js has dependencies, it will include those too
|
||||
const test = require("./my-local-dependency.js");
|
||||
|
||||
// ignored, is a built-in
|
||||
const path = require("path");
|
||||
```
|
||||
|
||||
```js
|
||||
const DependencyTree = require("@11ty/dependency-tree");
|
||||
|
||||
DependencyTree("./my-file.js");
|
||||
// returns ["./my-local-dependency.js"]
|
||||
```
|
||||
|
||||
### `allowNotFound`
|
||||
|
||||
```js
|
||||
const DependencyTree = require("@11ty/dependency-tree");
|
||||
|
||||
DependencyTree("./this-does-not-exist.js"); // throws an error
|
||||
|
||||
DependencyTree("./this-does-not-exist.js", { allowNotFound: true });
|
||||
// returns []
|
||||
```
|
||||
|
||||
### `nodeModuleNames`
|
||||
|
||||
(Added in v2.0.1) Controls whether or not node package names are included in the list of dependencies.
|
||||
|
||||
* `nodeModuleNames: "include"`: included alongside the local JS files.
|
||||
* `nodeModuleNames: "exclude"` (default): node module package names are excluded.
|
||||
* `nodeModuleNames: "only"`: only node module package names are returned.
|
||||
|
||||
```js
|
||||
// my-file.js:
|
||||
|
||||
require("./my-local-dependency.js");
|
||||
require("@11ty/eleventy");
|
||||
```
|
||||
|
||||
```js
|
||||
const DependencyTree = require("@11ty/dependency-tree");
|
||||
|
||||
DependencyTree("./my-file.js");
|
||||
// returns ["./my-local-dependency.js"]
|
||||
|
||||
DependencyTree("./my-file.js", { nodeModuleNames: "exclude" });
|
||||
// returns ["./my-local-dependency.js"]
|
||||
|
||||
DependencyTree("./my-file.js", { nodeModuleNames: "include" });
|
||||
// returns ["./my-local-dependency.js", "@11ty/eleventy"]
|
||||
|
||||
DependencyTree("./my-file.js", { nodeModuleNames: "only" });
|
||||
// returns ["@11ty/eleventy"]
|
||||
```
|
||||
|
||||
#### (Deprecated) `nodeModuleNamesOnly`
|
||||
|
||||
(Added in v2.0.0) Changed to use `nodeModuleNames` option instead. Backwards compatibility is maintained automatically.
|
||||
|
||||
* `nodeModuleNamesOnly: false` is mapped to `nodeModuleNames: "exclude"`
|
||||
* `nodeModuleNamesOnly: true` is mapped to `nodeModuleNames: "only"`
|
||||
|
||||
If both `nodeModuleNamesOnly` and `nodeModuleNames` are included in options, `nodeModuleNames` takes precedence.
|
||||
|
||||
### `getPackagesByType` method
|
||||
|
||||
_Added in v4.0.2._
|
||||
|
||||
```js
|
||||
const DependencyTree = require("@11ty/dependency-tree");
|
||||
const {getPackagesByType} = DependencyTree;
|
||||
|
||||
// With `require(esm)` support, some targets may be modules!
|
||||
// Return separate lists for commonjs and esm lists
|
||||
getPackagesByType("./my-file.js");
|
||||
// returns { commonjs: ["./my-file.js"], esm: [] }
|
||||
```
|
||||
157
node_modules/@11ty/dependency-tree/main.js
generated
vendored
157
node_modules/@11ty/dependency-tree/main.js
generated
vendored
|
|
@ -1,157 +0,0 @@
|
|||
const path = require("node:path");
|
||||
const { TemplatePath } = require("@11ty/eleventy-utils");
|
||||
|
||||
function getAbsolutePath(filename) {
|
||||
let normalizedFilename = path.normalize(filename); // removes dot slash
|
||||
let hasDotSlash = filename.startsWith("./");
|
||||
return hasDotSlash ? path.join(path.resolve("."), normalizedFilename) : normalizedFilename;
|
||||
}
|
||||
|
||||
function getRelativePath(filename) {
|
||||
let normalizedFilename = path.normalize(filename); // removes dot slash
|
||||
let workingDirectory = path.resolve(".");
|
||||
let result = "./" + (normalizedFilename.startsWith(workingDirectory) ? normalizedFilename.substr(workingDirectory.length + 1) : normalizedFilename);
|
||||
return result;
|
||||
}
|
||||
|
||||
function getNodeModuleName(filename) {
|
||||
let foundNodeModules = false;
|
||||
let moduleName = [];
|
||||
|
||||
let s = filename.split(path.sep);
|
||||
for(let entry of s) {
|
||||
if(entry === '.pnpm') {
|
||||
foundNodeModules = false;
|
||||
}
|
||||
|
||||
if(foundNodeModules) {
|
||||
moduleName.push(entry);
|
||||
if(!entry.startsWith("@")) {
|
||||
return moduleName.join("/");
|
||||
}
|
||||
}
|
||||
|
||||
if(entry === "node_modules") {
|
||||
foundNodeModules = true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* unordered */
|
||||
function getDependenciesFor(filename, avoidCircular, optionsArg = {}) {
|
||||
// backwards compatibility with `nodeModuleNamesOnly` boolean option
|
||||
// Using `nodeModuleNames` property moving forward
|
||||
if(("nodeModuleNamesOnly" in optionsArg) && !("nodeModuleNames" in optionsArg)) {
|
||||
if(optionsArg.nodeModuleNamesOnly === true) {
|
||||
optionsArg.nodeModuleNames = "only";
|
||||
}
|
||||
if(optionsArg.nodeModuleNamesOnly === false) {
|
||||
optionsArg.nodeModuleNames = "exclude";
|
||||
}
|
||||
}
|
||||
|
||||
let options = Object.assign({
|
||||
allowNotFound: false,
|
||||
nodeModuleNames: "exclude", // also "include" or "only"
|
||||
}, optionsArg);
|
||||
let absoluteFilename = getAbsolutePath(filename);
|
||||
let modules = new Set();
|
||||
|
||||
try {
|
||||
let res = require(absoluteFilename);
|
||||
if(res[Symbol.toStringTag] === "Module" || res.__esModule) {
|
||||
modules.add(filename);
|
||||
}
|
||||
} catch(e) {
|
||||
if(e.code === "MODULE_NOT_FOUND" && options.allowNotFound) {
|
||||
// do nothing
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let mod;
|
||||
for(let entry in require.cache) {
|
||||
if(entry === absoluteFilename) {
|
||||
mod = require.cache[entry];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let dependencies = new Set();
|
||||
|
||||
if(!mod) {
|
||||
if(!options.allowNotFound) {
|
||||
throw new Error(`Could not find ${filename} in @11ty/dependency-tree`);
|
||||
}
|
||||
} else {
|
||||
let relativeFilename = getRelativePath(mod.filename);
|
||||
if(!avoidCircular) {
|
||||
avoidCircular = {};
|
||||
} else if(options.nodeModuleNames !== "only") {
|
||||
dependencies.add(relativeFilename);
|
||||
}
|
||||
|
||||
avoidCircular[relativeFilename] = true;
|
||||
|
||||
if(Array.isArray(mod.children) && mod.children.length > 0) {
|
||||
for(let child of mod.children) {
|
||||
let relativeChildFilename = getRelativePath(child.filename);
|
||||
let nodeModuleName = getNodeModuleName(child.filename);
|
||||
|
||||
if(options.nodeModuleNames !== "exclude" && nodeModuleName) {
|
||||
dependencies.add(nodeModuleName);
|
||||
}
|
||||
// Add dependencies of this dependency (not top level node_modules)
|
||||
if(nodeModuleName === false) {
|
||||
if(!dependencies.has(relativeChildFilename) && // avoid infinite looping with circular deps
|
||||
!avoidCircular[relativeChildFilename] ) {
|
||||
let { commonjs, esm } = getDependenciesFor(relativeChildFilename, avoidCircular, options);
|
||||
for(let dependency of commonjs) {
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
for(let dependency of esm) {
|
||||
modules.add(dependency);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
esm: modules,
|
||||
commonjs: dependencies,
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeList(packageSet) {
|
||||
return Array.from( packageSet ).map(filePath => {
|
||||
if(filePath.startsWith("./")) {
|
||||
return TemplatePath.standardizeFilePath(filePath);
|
||||
}
|
||||
return filePath; // node_module name
|
||||
})
|
||||
}
|
||||
|
||||
function getCleanDependencyListFor(filename, options = {}) {
|
||||
let { commonjs } = getDependenciesFor(filename, null, options);
|
||||
|
||||
return normalizeList(commonjs);
|
||||
}
|
||||
|
||||
function getCleanDependencyListByTypeFor(filename, options = {}) {
|
||||
let { commonjs, esm } = getDependenciesFor(filename, null, options);
|
||||
|
||||
return {
|
||||
commonjs: normalizeList(commonjs),
|
||||
esm: normalizeList(esm),
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = getCleanDependencyListFor;
|
||||
module.exports.getPackagesByType = getCleanDependencyListByTypeFor;
|
||||
module.exports.getNodeModuleName = getNodeModuleName;
|
||||
42
node_modules/@11ty/dependency-tree/package.json
generated
vendored
42
node_modules/@11ty/dependency-tree/package.json
generated
vendored
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
"name": "@11ty/dependency-tree",
|
||||
"version": "4.0.2",
|
||||
"description": "Finds all JavaScript CommmonJS require() dependencies from a filename.",
|
||||
"main": "main.js",
|
||||
"files": [
|
||||
"main.js",
|
||||
"!test",
|
||||
"!test/**"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "npx ava"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/11ty/eleventy-dependency-tree.git"
|
||||
},
|
||||
"author": {
|
||||
"name": "Zach Leatherman",
|
||||
"email": "zach@zachleat.com",
|
||||
"url": "https://zachleat.com/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"ava": {
|
||||
"files": [
|
||||
"./test/*.js"
|
||||
],
|
||||
"watchMode": {
|
||||
"ignoreChanged": [
|
||||
"./test/stubs/**"
|
||||
]
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sindresorhus/is": "^4.6.0",
|
||||
"ava": "^6.4.1",
|
||||
"semver": "^7.7.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@11ty/eleventy-utils": "^2.0.1"
|
||||
}
|
||||
}
|
||||
60
node_modules/@11ty/eleventy-dev-server/README.md
generated
vendored
60
node_modules/@11ty/eleventy-dev-server/README.md
generated
vendored
|
|
@ -1,60 +0,0 @@
|
|||
<p align="center"><img src="https://www.11ty.dev/img/logo-github.svg" width="200" height="200" alt="11ty Logo"></p>
|
||||
|
||||
# eleventy-dev-server 🕚⚡️🎈🐀
|
||||
|
||||
A minimal, modern, generic, hot-reloading local web server to help web developers.
|
||||
|
||||
## ➡ [Documentation](https://www.11ty.dev/docs/watch-serve/#eleventy-dev-server)
|
||||
|
||||
- Please star [Eleventy on GitHub](https://github.com/11ty/eleventy/)!
|
||||
- Follow us on Twitter [@eleven_ty](https://twitter.com/eleven_ty)
|
||||
- Support [11ty on Open Collective](https://opencollective.com/11ty)
|
||||
- [11ty on npm](https://www.npmjs.com/org/11ty)
|
||||
- [11ty on GitHub](https://github.com/11ty)
|
||||
|
||||
[](https://www.npmjs.com/package/@11ty/eleventy-dev-server)
|
||||
|
||||
## Installation
|
||||
|
||||
This is bundled with `@11ty/eleventy` (and you do not need to install it separately) in Eleventy v2.0.
|
||||
|
||||
## CLI
|
||||
|
||||
Eleventy Dev Server now also includes a CLI. The CLI is for **standalone** (non-Eleventy) use only: separate installation is unnecessary if you’re using this server with `@11ty/eleventy`.
|
||||
|
||||
```sh
|
||||
npm install -g @11ty/eleventy-dev-server
|
||||
|
||||
# Alternatively, install locally into your project
|
||||
npm install @11ty/eleventy-dev-server
|
||||
```
|
||||
|
||||
This package requires Node 18 or newer.
|
||||
|
||||
### CLI Usage
|
||||
|
||||
```sh
|
||||
# Serve the current directory
|
||||
npx @11ty/eleventy-dev-server
|
||||
|
||||
# Serve a different subdirectory (also aliased as --input)
|
||||
npx @11ty/eleventy-dev-server --dir=_site
|
||||
|
||||
# Disable the `domdiff` feature
|
||||
npx @11ty/eleventy-dev-server --domdiff=false
|
||||
|
||||
# Full command list in the Help
|
||||
npx @11ty/eleventy-dev-server --help
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
```
|
||||
npm run test
|
||||
```
|
||||
|
||||
- We use the [ava JavaScript test runner](https://github.com/avajs/ava) ([Assertions documentation](https://github.com/avajs/ava/blob/master/docs/03-assertions.md))
|
||||
|
||||
## Changelog
|
||||
|
||||
* `v2.0.0` bumps Node.js minimum to 18.
|
||||
89
node_modules/@11ty/eleventy-dev-server/cli.js
generated
vendored
89
node_modules/@11ty/eleventy-dev-server/cli.js
generated
vendored
|
|
@ -1,89 +0,0 @@
|
|||
const pkg = require("./package.json");
|
||||
const EleventyDevServer = require("./server.js");
|
||||
|
||||
const Logger = {
|
||||
info: function(...args) {
|
||||
console.log( "[11ty/eleventy-dev-server]", ...args );
|
||||
},
|
||||
error: function(...args) {
|
||||
console.error( "[11ty/eleventy-dev-server]", ...args );
|
||||
},
|
||||
fatal: function(...args) {
|
||||
Logger.error(...args);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
};
|
||||
|
||||
Logger.log = Logger.info;
|
||||
|
||||
class Cli {
|
||||
static getVersion() {
|
||||
return pkg.version;
|
||||
}
|
||||
|
||||
static getHelp() {
|
||||
return `Usage:
|
||||
|
||||
eleventy-dev-server
|
||||
eleventy-dev-server --dir=_site
|
||||
eleventy-dev-server --port=3000
|
||||
|
||||
Arguments:
|
||||
|
||||
--version
|
||||
|
||||
--dir=.
|
||||
Directory to serve (default: \`.\`)
|
||||
|
||||
--input (alias for --dir)
|
||||
|
||||
--port=8080
|
||||
Run the web server on this port (default: \`8080\`)
|
||||
Will autoincrement if already in use.
|
||||
|
||||
--domdiff (enabled, default)
|
||||
--domdiff=false (disabled)
|
||||
Apply HTML changes without a full page reload.
|
||||
|
||||
--help`;
|
||||
}
|
||||
|
||||
static getDefaultOptions() {
|
||||
return {
|
||||
port: "8080",
|
||||
input: ".",
|
||||
domDiff: true,
|
||||
}
|
||||
}
|
||||
|
||||
async serve(options = {}) {
|
||||
this.options = Object.assign(Cli.getDefaultOptions(), options);
|
||||
|
||||
this.server = EleventyDevServer.getServer("eleventy-dev-server-cli", this.options.input, {
|
||||
// TODO allow server configuration extensions
|
||||
showVersion: true,
|
||||
logger: Logger,
|
||||
domDiff: this.options.domDiff,
|
||||
|
||||
// CLI watches all files in the folder by default
|
||||
// this is different from Eleventy usage!
|
||||
watch: [ this.options.input ],
|
||||
});
|
||||
|
||||
this.server.serve(this.options.port);
|
||||
|
||||
// TODO? send any errors here to the server too
|
||||
// with server.sendError({ error });
|
||||
}
|
||||
|
||||
close() {
|
||||
if(this.server) {
|
||||
return this.server.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
Logger,
|
||||
Cli
|
||||
}
|
||||
336
node_modules/@11ty/eleventy-dev-server/client/reload-client.js
generated
vendored
336
node_modules/@11ty/eleventy-dev-server/client/reload-client.js
generated
vendored
|
|
@ -1,336 +0,0 @@
|
|||
class Util {
|
||||
static pad(num, digits = 2) {
|
||||
let zeroes = new Array(digits + 1).join(0);
|
||||
return `${zeroes}${num}`.slice(-1 * digits);
|
||||
}
|
||||
|
||||
static log(message) {
|
||||
Util.output("log", message);
|
||||
}
|
||||
static error(message, error) {
|
||||
Util.output("error", message, error);
|
||||
}
|
||||
static output(type, ...messages) {
|
||||
let now = new Date();
|
||||
let date = `${Util.pad(now.getUTCHours())}:${Util.pad(
|
||||
now.getUTCMinutes()
|
||||
)}:${Util.pad(now.getUTCSeconds())}.${Util.pad(
|
||||
now.getUTCMilliseconds(),
|
||||
3
|
||||
)}`;
|
||||
console[type](`[11ty][${date} UTC]`, ...messages);
|
||||
}
|
||||
|
||||
static capitalize(word) {
|
||||
return word.substr(0, 1).toUpperCase() + word.substr(1);
|
||||
}
|
||||
|
||||
static matchRootAttributes(htmlContent) {
|
||||
// Workaround for morphdom bug with attributes on <html> https://github.com/11ty/eleventy-dev-server/issues/6
|
||||
// Note also `childrenOnly: true` above
|
||||
const parser = new DOMParser();
|
||||
let parsed = parser.parseFromString(htmlContent, "text/html");
|
||||
let parsedDoc = parsed.documentElement;
|
||||
let newAttrs = parsedDoc.getAttributeNames();
|
||||
|
||||
let docEl = document.documentElement;
|
||||
// Remove old
|
||||
let removedAttrs = docEl.getAttributeNames().filter(name => !newAttrs.includes(name));
|
||||
for(let attr of removedAttrs) {
|
||||
docEl.removeAttribute(attr);
|
||||
}
|
||||
|
||||
// Add new
|
||||
for(let attr of newAttrs) {
|
||||
docEl.setAttribute(attr, parsedDoc.getAttribute(attr));
|
||||
}
|
||||
}
|
||||
|
||||
static isEleventyLinkNodeMatch(from, to) {
|
||||
// Issue #18 https://github.com/11ty/eleventy-dev-server/issues/18
|
||||
// Don’t update a <link> if the _11ty searchParam is the only thing that’s different
|
||||
if(from.tagName !== "LINK" || to.tagName !== "LINK") {
|
||||
return false;
|
||||
}
|
||||
|
||||
let oldWithoutHref = from.cloneNode();
|
||||
let newWithoutHref = to.cloneNode();
|
||||
|
||||
oldWithoutHref.removeAttribute("href");
|
||||
newWithoutHref.removeAttribute("href");
|
||||
|
||||
// if all other attributes besides href match
|
||||
if(!oldWithoutHref.isEqualNode(newWithoutHref)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let oldUrl = new URL(from.href);
|
||||
let newUrl = new URL(to.href);
|
||||
|
||||
// morphdom wants to force href="style.css?_11ty" => href="style.css"
|
||||
let paramName = EleventyReload.QUERY_PARAM;
|
||||
let isErasing = oldUrl.searchParams.has(paramName) && !newUrl.searchParams.has(paramName);
|
||||
if(!isErasing) {
|
||||
// not a match if _11ty has a new value (not being erased)
|
||||
return false;
|
||||
}
|
||||
|
||||
oldUrl.searchParams.set(paramName, "");
|
||||
newUrl.searchParams.set(paramName, "");
|
||||
|
||||
// is a match if erasing and the rest of the href matches too
|
||||
return oldUrl.toString() === newUrl.toString();
|
||||
}
|
||||
|
||||
// https://github.com/patrick-steele-idem/morphdom/issues/178#issuecomment-652562769
|
||||
static runScript(source, target) {
|
||||
let script = document.createElement('script');
|
||||
|
||||
// copy over the attributes
|
||||
for(let attr of [...source.attributes]) {
|
||||
script.setAttribute(attr.nodeName ,attr.nodeValue);
|
||||
}
|
||||
|
||||
script.innerHTML = source.innerHTML;
|
||||
(target || source).replaceWith(script);
|
||||
}
|
||||
|
||||
static fullPageReload() {
|
||||
Util.log(`Page reload initiated.`);
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
class EleventyReload {
|
||||
static QUERY_PARAM = "_11ty";
|
||||
|
||||
static reloadTypes = {
|
||||
css: (files, build = {}) => {
|
||||
// Initiate a full page refresh if a CSS change is made but does match any stylesheet url
|
||||
// `build.stylesheets` available in Eleventy v3.0.1-alpha.5+
|
||||
if(Array.isArray(build.stylesheets)) {
|
||||
let match = false;
|
||||
for (let link of document.querySelectorAll(`link[rel="stylesheet"]`)) {
|
||||
if (link.href) {
|
||||
let url = new URL(link.href);
|
||||
if(build.stylesheets.includes(url.pathname)) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!match) {
|
||||
Util.fullPageReload();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (let link of document.querySelectorAll(`link[rel="stylesheet"]`)) {
|
||||
if (link.href) {
|
||||
let url = new URL(link.href);
|
||||
url.searchParams.set(this.QUERY_PARAM, Date.now());
|
||||
link.href = url.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Util.log(`CSS updated without page reload.`);
|
||||
},
|
||||
default: async (files, build = {}) => {
|
||||
let morphed = false;
|
||||
let domdiffTemplates = (build?.templates || []).filter(({url, inputPath}) => {
|
||||
return url === document.location.pathname && (files || []).includes(inputPath);
|
||||
});
|
||||
|
||||
if(domdiffTemplates.length === 0) {
|
||||
Util.fullPageReload();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Important: using `./` allows the `.11ty` folder name to be changed
|
||||
const { default: morphdom } = await import(`./morphdom.js`);
|
||||
|
||||
for (let {url, inputPath, content} of domdiffTemplates) {
|
||||
// Notable limitation: this won’t re-run script elements or JavaScript page lifecycle events (load/DOMContentLoaded)
|
||||
morphed = true;
|
||||
|
||||
morphdom(document.documentElement, content, {
|
||||
childrenOnly: true,
|
||||
onBeforeElUpdated: function (fromEl, toEl) {
|
||||
if (fromEl.nodeName === "SCRIPT" && toEl.nodeName === "SCRIPT") {
|
||||
if(toEl.innerHTML !== fromEl.innerHTML) {
|
||||
Util.log(`JavaScript modified, reload initiated.`);
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Speed-up trick from morphdom docs
|
||||
// https://dom.spec.whatwg.org/#concept-node-equals
|
||||
if (fromEl.isEqualNode(toEl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Util.isEleventyLinkNodeMatch(fromEl, toEl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
addChild: function(parent, child) {
|
||||
// Declarative Shadow DOM https://github.com/11ty/eleventy-dev-server/issues/90
|
||||
if(child.nodeName === "TEMPLATE" && child.hasAttribute("shadowrootmode")) {
|
||||
let root = parent.shadowRoot;
|
||||
if(root) {
|
||||
// remove all shadow root children
|
||||
while(root.firstChild) {
|
||||
root.removeChild(root.firstChild);
|
||||
}
|
||||
}
|
||||
for(let newChild of child.content.childNodes) {
|
||||
root.appendChild(newChild);
|
||||
}
|
||||
} else {
|
||||
parent.appendChild(child);
|
||||
}
|
||||
},
|
||||
onNodeAdded: function (node) {
|
||||
if (node.nodeName === 'SCRIPT') {
|
||||
Util.log(`JavaScript added, reload initiated.`);
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
onElUpdated: function(node) {
|
||||
// Re-attach custom elements
|
||||
if(customElements.get(node.tagName.toLowerCase())) {
|
||||
let placeholder = document.createElement("div");
|
||||
node.replaceWith(placeholder);
|
||||
requestAnimationFrame(() => {
|
||||
placeholder.replaceWith(node);
|
||||
placeholder = undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Util.matchRootAttributes(content);
|
||||
Util.log(`HTML delta applied without page reload.`);
|
||||
}
|
||||
} catch(e) {
|
||||
Util.error( "Morphdom error", e );
|
||||
}
|
||||
|
||||
if (!morphed) {
|
||||
Util.fullPageReload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.connectionMessageShown = false;
|
||||
this.reconnectEventCallback = this.reconnect.bind(this);
|
||||
}
|
||||
|
||||
init(options = {}) {
|
||||
if (!("WebSocket" in window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let documentUrl = new URL(document.location.href);
|
||||
|
||||
let reloadPort = new URL(import.meta.url).searchParams.get("reloadPort");
|
||||
if(reloadPort) {
|
||||
documentUrl.port = reloadPort;
|
||||
}
|
||||
|
||||
let { protocol, host } = documentUrl;
|
||||
|
||||
// works with http (ws) and https (wss)
|
||||
let websocketProtocol = protocol.replace("http", "ws");
|
||||
|
||||
let socket = new WebSocket(`${websocketProtocol}//${host}`);
|
||||
|
||||
socket.addEventListener("message", async (event) => {
|
||||
try {
|
||||
let data = JSON.parse(event.data);
|
||||
// Util.log( JSON.stringify(data, null, 2) );
|
||||
|
||||
let { type } = data;
|
||||
|
||||
if (type === "eleventy.reload") {
|
||||
await this.onreload(data);
|
||||
} else if (type === "eleventy.msg") {
|
||||
Util.log(`${data.message}`);
|
||||
} else if (type === "eleventy.error") {
|
||||
// Log Eleventy build errors
|
||||
// Extra parsing for Node Error objects
|
||||
let e = JSON.parse(data.error);
|
||||
Util.error(`Build error: ${e.message}`, e);
|
||||
} else if (type === "eleventy.status") {
|
||||
// Full page reload on initial reconnect
|
||||
if (data.status === "connected" && options.mode === "reconnect") {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
if(data.status === "connected") {
|
||||
// With multiple windows, only show one connection message
|
||||
if(!this.isConnected) {
|
||||
Util.log(Util.capitalize(data.status));
|
||||
}
|
||||
|
||||
this.connectionMessageShown = true;
|
||||
} else {
|
||||
if(data.status === "disconnected") {
|
||||
this.addReconnectListeners();
|
||||
}
|
||||
|
||||
Util.log(Util.capitalize(data.status));
|
||||
}
|
||||
} else {
|
||||
Util.log("Unknown event type", data);
|
||||
}
|
||||
} catch (e) {
|
||||
Util.error(`Error parsing ${event.data}: ${e.message}`, e);
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener("open", () => {
|
||||
// no reconnection when the connect is already open
|
||||
this.removeReconnectListeners();
|
||||
});
|
||||
|
||||
socket.addEventListener("close", () => {
|
||||
this.connectionMessageShown = false;
|
||||
this.addReconnectListeners();
|
||||
});
|
||||
}
|
||||
|
||||
reconnect() {
|
||||
Util.log( "Reconnecting…" );
|
||||
this.init({ mode: "reconnect" });
|
||||
}
|
||||
|
||||
async onreload({ subtype, files, build }) {
|
||||
if(!EleventyReload.reloadTypes[subtype]) {
|
||||
subtype = "default";
|
||||
}
|
||||
|
||||
await EleventyReload.reloadTypes[subtype](files, build);
|
||||
}
|
||||
|
||||
addReconnectListeners() {
|
||||
this.removeReconnectListeners();
|
||||
|
||||
window.addEventListener("focus", this.reconnectEventCallback);
|
||||
window.addEventListener("visibilitychange", this.reconnectEventCallback);
|
||||
}
|
||||
|
||||
removeReconnectListeners() {
|
||||
window.removeEventListener("focus", this.reconnectEventCallback);
|
||||
window.removeEventListener("visibilitychange", this.reconnectEventCallback);
|
||||
}
|
||||
}
|
||||
|
||||
let reloader = new EleventyReload();
|
||||
reloader.init();
|
||||
77
node_modules/@11ty/eleventy-dev-server/cmd.js
generated
vendored
77
node_modules/@11ty/eleventy-dev-server/cmd.js
generated
vendored
|
|
@ -1,77 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const pkg = require("./package.json");
|
||||
|
||||
// Node check
|
||||
require("please-upgrade-node")(pkg, {
|
||||
message: function (requiredVersion) {
|
||||
return (
|
||||
"eleventy-dev-server requires Node " +
|
||||
requiredVersion +
|
||||
". You will need to upgrade Node!"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
const { Logger, Cli } = require("./cli.js");
|
||||
|
||||
const debug = require("debug")("Eleventy:DevServer");
|
||||
|
||||
try {
|
||||
const defaults = Cli.getDefaultOptions();
|
||||
for(let key in defaults) {
|
||||
if(key.toLowerCase() !== key) {
|
||||
defaults[key.toLowerCase()] = defaults[key];
|
||||
delete defaults[key];
|
||||
}
|
||||
}
|
||||
|
||||
const argv = require("minimist")(process.argv.slice(2), {
|
||||
string: [
|
||||
"dir",
|
||||
"input", // alias for dir
|
||||
"port",
|
||||
],
|
||||
boolean: [
|
||||
"version",
|
||||
"help",
|
||||
"domdiff",
|
||||
],
|
||||
default: defaults,
|
||||
unknown: function (unknownArgument) {
|
||||
throw new Error(
|
||||
`We don’t know what '${unknownArgument}' is. Use --help to see the list of supported commands.`
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
debug("command: eleventy-dev-server %o", argv);
|
||||
|
||||
process.on("unhandledRejection", (error, promise) => {
|
||||
Logger.fatal("Unhandled rejection in promise:", promise, error);
|
||||
});
|
||||
process.on("uncaughtException", (error) => {
|
||||
Logger.fatal("Uncaught exception:", error);
|
||||
});
|
||||
|
||||
if (argv.version) {
|
||||
console.log(Cli.getVersion());
|
||||
} else if (argv.help) {
|
||||
console.log(Cli.getHelp());
|
||||
} else {
|
||||
let cli = new Cli();
|
||||
|
||||
cli.serve({
|
||||
input: argv.dir || argv.input,
|
||||
port: argv.port,
|
||||
domDiff: argv.domdiff,
|
||||
});
|
||||
|
||||
process.on("SIGINT", async () => {
|
||||
await cli.close();
|
||||
process.exitCode = 0;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.fatal("Fatal Error:", e)
|
||||
}
|
||||
57
node_modules/@11ty/eleventy-dev-server/package.json
generated
vendored
57
node_modules/@11ty/eleventy-dev-server/package.json
generated
vendored
|
|
@ -1,57 +0,0 @@
|
|||
{
|
||||
"name": "@11ty/eleventy-dev-server",
|
||||
"version": "2.0.8",
|
||||
"description": "A minimal, modern, generic, hot-reloading local web server to help web developers.",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "npx ava --verbose",
|
||||
"sample": "node cmd.js --input=test/stubs"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/11ty"
|
||||
},
|
||||
"bin": {
|
||||
"eleventy-dev-server": "./cmd.js"
|
||||
},
|
||||
"keywords": [
|
||||
"eleventy",
|
||||
"server",
|
||||
"cli"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"author": {
|
||||
"name": "Zach Leatherman",
|
||||
"email": "zachleatherman@gmail.com",
|
||||
"url": "https://zachleat.com/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/11ty/eleventy-dev-server.git"
|
||||
},
|
||||
"bugs": "https://github.com/11ty/eleventy-dev-server/issues",
|
||||
"homepage": "https://github.com/11ty/eleventy-dev-server/",
|
||||
"dependencies": {
|
||||
"@11ty/eleventy-utils": "^2.0.1",
|
||||
"chokidar": "^3.6.0",
|
||||
"debug": "^4.4.0",
|
||||
"finalhandler": "^1.3.1",
|
||||
"mime": "^3.0.0",
|
||||
"minimist": "^1.2.8",
|
||||
"morphdom": "^2.7.4",
|
||||
"please-upgrade-node": "^3.2.0",
|
||||
"send": "^1.1.0",
|
||||
"ssri": "^11.0.0",
|
||||
"urlpattern-polyfill": "^10.0.0",
|
||||
"ws": "^8.18.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^6.2.0"
|
||||
}
|
||||
}
|
||||
1024
node_modules/@11ty/eleventy-dev-server/server.js
generated
vendored
1024
node_modules/@11ty/eleventy-dev-server/server.js
generated
vendored
File diff suppressed because it is too large
Load diff
9
node_modules/@11ty/eleventy-dev-server/server/ipAddress.js
generated
vendored
9
node_modules/@11ty/eleventy-dev-server/server/ipAddress.js
generated
vendored
|
|
@ -1,9 +0,0 @@
|
|||
const os = require("node:os");
|
||||
|
||||
const INTERFACE_FAMILIES = ["IPv4"];
|
||||
|
||||
module.exports = function() {
|
||||
return Object.values(os.networkInterfaces()).flat().filter(interface => {
|
||||
return interface.internal === false && INTERFACE_FAMILIES.includes(interface.family);
|
||||
}).map(interface => interface.address);
|
||||
};
|
||||
130
node_modules/@11ty/eleventy-dev-server/server/wrapResponse.js
generated
vendored
130
node_modules/@11ty/eleventy-dev-server/server/wrapResponse.js
generated
vendored
|
|
@ -1,130 +0,0 @@
|
|||
function getContentType(headers) {
|
||||
if(!headers) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(let key in headers) {
|
||||
if(key.toLowerCase() === "content-type") {
|
||||
return headers[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inspired by `resp-modifier` https://github.com/shakyShane/resp-modifier/blob/4a000203c9db630bcfc3b6bb8ea2abc090ae0139/index.js
|
||||
function wrapResponse(resp, transformHtml) {
|
||||
resp._wrappedOriginalWrite = resp.write;
|
||||
resp._wrappedOriginalWriteHead = resp.writeHead;
|
||||
resp._wrappedOriginalEnd = resp.end;
|
||||
|
||||
resp._wrappedHeaders = [];
|
||||
resp._wrappedTransformHtml = transformHtml;
|
||||
resp._hasEnded = false;
|
||||
resp._shouldForceEnd = false;
|
||||
|
||||
// Compatibility with web standards Response()
|
||||
Object.defineProperty(resp, "body", {
|
||||
// Returns write cache
|
||||
get: function() {
|
||||
if(typeof this._writeCache === "string") {
|
||||
return this._writeCache;
|
||||
}
|
||||
},
|
||||
// Usage:
|
||||
// res.body = ""; // overwrite existing content
|
||||
// res.body += ""; // append to existing content, can also res.write("") to append
|
||||
set: function(data) {
|
||||
if(typeof data === "string") {
|
||||
this._writeCache = data;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Compatibility with web standards Response()
|
||||
Object.defineProperty(resp, "bodyUsed", {
|
||||
get: function() {
|
||||
return this._hasEnded;
|
||||
}
|
||||
})
|
||||
|
||||
// Original signature writeHead(statusCode[, statusMessage][, headers])
|
||||
resp.writeHead = function(statusCode, ...args) {
|
||||
let headers = args[args.length - 1];
|
||||
// statusMessage is a string
|
||||
if(typeof headers !== "string") {
|
||||
this._contentType = getContentType(headers);
|
||||
}
|
||||
|
||||
if((this._contentType || "").startsWith("text/html")) {
|
||||
this._wrappedHeaders.push([statusCode, ...args]);
|
||||
} else {
|
||||
return this._wrappedOriginalWriteHead(statusCode, ...args);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// data can be a String or Buffer
|
||||
resp.write = function(data, ...args) {
|
||||
if(typeof data === "string") {
|
||||
if(!this._writeCache) {
|
||||
this._writeCache = "";
|
||||
}
|
||||
|
||||
// TODO encoding and callback args
|
||||
this._writeCache += data;
|
||||
} else {
|
||||
// Buffers
|
||||
return this._wrappedOriginalWrite(data, ...args);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// data can be a String or Buffer
|
||||
resp.end = function(data, encoding, callback) {
|
||||
resp._hasEnded = true;
|
||||
|
||||
if(typeof this._writeCache === "string" || typeof data === "string") {
|
||||
// Strings
|
||||
if(!this._writeCache) {
|
||||
this._writeCache = "";
|
||||
}
|
||||
if(typeof data === "string") {
|
||||
this._writeCache += data;
|
||||
}
|
||||
|
||||
let result = this._writeCache;
|
||||
|
||||
// Only transform HTML
|
||||
// Note the “setHeader versus writeHead” note on https://nodejs.org/api/http.html#responsewriteheadstatuscode-statusmessage-headers
|
||||
let contentType = this._contentType || getContentType(this.getHeaders());
|
||||
if(contentType?.startsWith("text/html")) {
|
||||
if(this._wrappedTransformHtml && typeof this._wrappedTransformHtml === "function") {
|
||||
result = this._wrappedTransformHtml(result);
|
||||
// uncompressed size: https://github.com/w3c/ServiceWorker/issues/339
|
||||
this.setHeader("Content-Length", Buffer.byteLength(result));
|
||||
}
|
||||
}
|
||||
|
||||
for(let headers of this._wrappedHeaders) {
|
||||
this._wrappedOriginalWriteHead(...headers);
|
||||
}
|
||||
|
||||
this._writeCache = [];
|
||||
this._wrappedOriginalWrite(result, encoding)
|
||||
return this._wrappedOriginalEnd(callback);
|
||||
} else {
|
||||
// Buffer or Uint8Array
|
||||
for(let headers of this._wrappedHeaders) {
|
||||
this._wrappedOriginalWriteHead(...headers);
|
||||
}
|
||||
|
||||
if(data) {
|
||||
this._wrappedOriginalWrite(data, encoding);
|
||||
}
|
||||
return this._wrappedOriginalEnd(callback);
|
||||
}
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
module.exports = wrapResponse;
|
||||
55
node_modules/@11ty/eleventy-fetch/README.md
generated
vendored
55
node_modules/@11ty/eleventy-fetch/README.md
generated
vendored
|
|
@ -1,55 +0,0 @@
|
|||
<p align="center"><img src="https://www.11ty.dev/img/logo-github.svg" width="200" height="200" alt="eleventy Logo"></p>
|
||||
|
||||
# eleventy-fetch
|
||||
|
||||
_Requires Node 18+_
|
||||
|
||||
Formerly known as [`@11ty/eleventy-cache-assets`](https://www.npmjs.com/package/@11ty/eleventy-cache-assets).
|
||||
|
||||
Fetch network resources and cache them so you don’t bombard your API (or other resources). Do this at configurable intervals—not with every build! Once per minute, or once per hour, once per day, or however often you like!
|
||||
|
||||
With the added benefit that if one successful request completes, you can now work offline!
|
||||
|
||||
This plugin can save any kind of asset—JSON, HTML, images, videos, etc.
|
||||
|
||||
## [The full `eleventy-fetch` documentation is on 11ty.dev](https://www.11ty.dev/docs/plugins/cache/).
|
||||
|
||||
- _This is a plugin for the [Eleventy static site generator](https://www.11ty.dev/)._
|
||||
- Find more [Eleventy plugins](https://www.11ty.dev/docs/plugins/).
|
||||
- Please star [Eleventy on GitHub](https://github.com/11ty/eleventy/), follow [@eleven_ty](https://twitter.com/eleven_ty) on Twitter, and support [11ty on Open Collective](https://opencollective.com/11ty)
|
||||
|
||||
[](https://www.npmjs.com/package/@11ty/eleventy-fetch) [](https://github.com/11ty/eleventy/issues)
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install @11ty/eleventy-fetch
|
||||
```
|
||||
|
||||
_[The full `eleventy-fetch` documentation is on 11ty.dev](https://www.11ty.dev/docs/plugins/cache/)._
|
||||
|
||||
## Tests
|
||||
|
||||
```
|
||||
npm run test
|
||||
```
|
||||
|
||||
- We use the [ava JavaScript test runner](https://github.com/avajs/ava) ([Assertions documentation](https://github.com/avajs/ava/blob/master/docs/03-assertions.md))
|
||||
- ℹ️ To keep tests fast, thou shalt try to avoid writing files in tests.
|
||||
|
||||
<!--
|
||||
## Roadmap
|
||||
|
||||
* Add support for tiered asset requests, e.g. CSS requests background-images and web fonts, for example.
|
||||
|
||||
## Open Questions
|
||||
|
||||
* `flat-cache` save method seems to be synchronous, is there a better async one?
|
||||
* Our cache stores raw buffers internally, which are pretty bloated compared to the original. Surely there is a more efficient way to do this. Maybe store the files in their original format.
|
||||
-->
|
||||
|
||||
## Community Roadmap
|
||||
|
||||
- [Top Feature Requests](https://github.com/11ty/eleventy-fetch/issues?q=label%3Aneeds-votes+sort%3Areactions-%2B1-desc+label%3Aenhancement) (Add your own votes using the 👍 reaction)
|
||||
- [Top Bugs 😱](https://github.com/11ty/eleventy-fetch/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc) (Add your own votes using the 👍 reaction)
|
||||
- [Newest Bugs 🙀](https://github.com/11ty/eleventy-fetch/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
|
||||
94
node_modules/@11ty/eleventy-fetch/eleventy-fetch.js
generated
vendored
94
node_modules/@11ty/eleventy-fetch/eleventy-fetch.js
generated
vendored
|
|
@ -1,94 +0,0 @@
|
|||
const { default: PQueue } = require("p-queue");
|
||||
const debug = require("debug")("Eleventy:Fetch");
|
||||
|
||||
const Sources = require("./src/Sources.js");
|
||||
const RemoteAssetCache = require("./src/RemoteAssetCache.js");
|
||||
const AssetCache = require("./src/AssetCache.js");
|
||||
const DirectoryManager = require("./src/DirectoryManager.js");
|
||||
|
||||
const globalOptions = {
|
||||
type: "buffer",
|
||||
directory: ".cache",
|
||||
concurrency: 10,
|
||||
fetchOptions: {},
|
||||
dryRun: false, // don’t write anything to the file system
|
||||
|
||||
// *does* affect cache key hash
|
||||
removeUrlQueryParams: false,
|
||||
|
||||
// runs after removeUrlQueryParams, does not affect cache key hash
|
||||
// formatUrlForDisplay: function(url) {
|
||||
// return url;
|
||||
// },
|
||||
|
||||
verbose: false, // Changed in 3.0+
|
||||
|
||||
hashLength: 30,
|
||||
};
|
||||
|
||||
/* Queue */
|
||||
let queue = new PQueue({
|
||||
concurrency: globalOptions.concurrency,
|
||||
});
|
||||
|
||||
queue.on("active", () => {
|
||||
debug(`Concurrency: ${queue.concurrency}, Size: ${queue.size}, Pending: ${queue.pending}`);
|
||||
});
|
||||
|
||||
let instCache = {};
|
||||
|
||||
let directoryManager = new DirectoryManager();
|
||||
|
||||
function createRemoteAssetCache(source, rawOptions = {}) {
|
||||
if (!Sources.isFullUrl(source) && !Sources.isValidSource(source)) {
|
||||
return Promise.reject(new Error("Invalid source. Received: " + source));
|
||||
}
|
||||
|
||||
let options = Object.assign({}, globalOptions, rawOptions);
|
||||
let sourceKey = RemoteAssetCache.getRequestId(source, options);
|
||||
if(!sourceKey) {
|
||||
return Promise.reject(Sources.getInvalidSourceError(source));
|
||||
}
|
||||
|
||||
if(instCache[sourceKey]) {
|
||||
return instCache[sourceKey];
|
||||
}
|
||||
|
||||
let inst = new RemoteAssetCache(source, options.directory, options);
|
||||
inst.setQueue(queue);
|
||||
inst.setDirectoryManager(directoryManager);
|
||||
|
||||
instCache[sourceKey] = inst;
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
module.exports = function (source, options) {
|
||||
let instance = createRemoteAssetCache(source, options);
|
||||
return instance.queue();
|
||||
};
|
||||
|
||||
Object.defineProperty(module.exports, "concurrency", {
|
||||
get: function () {
|
||||
return queue.concurrency;
|
||||
},
|
||||
set: function (concurrency) {
|
||||
queue.concurrency = concurrency;
|
||||
},
|
||||
});
|
||||
|
||||
module.exports.Fetch = createRemoteAssetCache;
|
||||
|
||||
// Deprecated API kept for backwards compat, instead: use default export directly.
|
||||
// Intentional: queueCallback is ignored here
|
||||
module.exports.queue = function(source, queueCallback, options) {
|
||||
let instance = createRemoteAssetCache(source, options);
|
||||
return instance.queue();
|
||||
};
|
||||
|
||||
module.exports.Util = {
|
||||
isFullUrl: Sources.isFullUrl,
|
||||
};
|
||||
module.exports.RemoteAssetCache = RemoteAssetCache;
|
||||
module.exports.AssetCache = AssetCache;
|
||||
module.exports.Sources = Sources;
|
||||
66
node_modules/@11ty/eleventy-fetch/package.json
generated
vendored
66
node_modules/@11ty/eleventy-fetch/package.json
generated
vendored
|
|
@ -1,66 +0,0 @@
|
|||
{
|
||||
"name": "@11ty/eleventy-fetch",
|
||||
"version": "5.1.2",
|
||||
"description": "Fetch and locally cache remote API calls and assets.",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/11ty/eleventy-fetch.git"
|
||||
},
|
||||
"main": "eleventy-fetch.js",
|
||||
"scripts": {
|
||||
"test": "ava",
|
||||
"sample": "node sample",
|
||||
"format": "prettier . --write"
|
||||
},
|
||||
"files": [
|
||||
"src/",
|
||||
"eleventy-fetch.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/11ty"
|
||||
},
|
||||
"keywords": [
|
||||
"eleventy",
|
||||
"eleventy-utility"
|
||||
],
|
||||
"author": {
|
||||
"name": "Zach Leatherman",
|
||||
"email": "zachleatherman@gmail.com",
|
||||
"url": "https://zachleat.com/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/11ty/eleventy-fetch/issues"
|
||||
},
|
||||
"homepage": "https://github.com/11ty/eleventy-fetch#readme",
|
||||
"devDependencies": {
|
||||
"ava": "^6.4.1",
|
||||
"prettier": "^3.7.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@11ty/eleventy-utils": "^2.0.7",
|
||||
"@rgrove/parse-xml": "^4.2.0",
|
||||
"debug": "^4.4.3",
|
||||
"flatted": "^3.4.2",
|
||||
"p-queue": "6.6.2"
|
||||
},
|
||||
"ava": {
|
||||
"failFast": false,
|
||||
"files": [
|
||||
"./test/*.js"
|
||||
],
|
||||
"watchMode": {
|
||||
"ignoreChanges": [
|
||||
"**/.cache/**",
|
||||
"**/.customcache/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
270
node_modules/@11ty/eleventy-fetch/src/AssetCache.js
generated
vendored
270
node_modules/@11ty/eleventy-fetch/src/AssetCache.js
generated
vendored
|
|
@ -1,270 +0,0 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const { DateCompare, createHashHexSync } = require("@11ty/eleventy-utils");
|
||||
|
||||
const FileCache = require("./FileCache.js");
|
||||
const Sources = require("./Sources.js");
|
||||
|
||||
const debugUtil = require("debug");
|
||||
const debug = debugUtil("Eleventy:Fetch");
|
||||
|
||||
class AssetCache {
|
||||
#source;
|
||||
#hash;
|
||||
#customFilename;
|
||||
#cache;
|
||||
#cacheDirectory;
|
||||
#cacheLocationDirty = false;
|
||||
#directoryManager;
|
||||
|
||||
constructor(source, cacheDirectory, options = {}) {
|
||||
if(!Sources.isValidSource(source)) {
|
||||
throw Sources.getInvalidSourceError(source);
|
||||
}
|
||||
|
||||
let uniqueKey = AssetCache.getCacheKey(source, options);
|
||||
this.uniqueKey = uniqueKey;
|
||||
this.hash = AssetCache.getHash(uniqueKey, options.hashLength);
|
||||
|
||||
this.cacheDirectory = cacheDirectory || ".cache";
|
||||
this.options = options;
|
||||
|
||||
this.defaultDuration = "1d";
|
||||
this.duration = options.duration || this.defaultDuration;
|
||||
|
||||
// Compute the filename only once
|
||||
if (typeof this.options.filenameFormat === "function") {
|
||||
this.#customFilename = AssetCache.cleanFilename(this.options.filenameFormat(uniqueKey, this.hash));
|
||||
|
||||
if (typeof this.#customFilename !== "string" || this.#customFilename.length === 0) {
|
||||
throw new Error(`The provided filenameFormat callback function needs to return valid filename characters.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log(message) {
|
||||
if (this.options.verbose) {
|
||||
console.log(`[11ty/eleventy-fetch] ${message}`);
|
||||
} else {
|
||||
debug(message);
|
||||
}
|
||||
}
|
||||
|
||||
static cleanFilename(filename) {
|
||||
// Ensure no illegal characters are present (Windows or Linux: forward/backslash, chevrons, colon, double-quote, pipe, question mark, asterisk)
|
||||
if (filename.match(/([\/\\<>:"|?*]+?)/)) {
|
||||
let sanitizedFilename = filename.replace(/[\/\\<>:"|?*]+/g, "");
|
||||
debug(
|
||||
`[@11ty/eleventy-fetch] Some illegal characters were removed from the cache filename: ${filename} will be cached as ${sanitizedFilename}.`,
|
||||
);
|
||||
return sanitizedFilename;
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
static getCacheKey(source, options) {
|
||||
// RemoteAssetCache passes in a string here, which skips this check (requestId is already used upstream)
|
||||
if (Sources.isValidComplexSource(source)) {
|
||||
if(options.requestId) {
|
||||
return options.requestId;
|
||||
}
|
||||
|
||||
if(typeof source.toString === "function") {
|
||||
// return source.toString();
|
||||
let toStr = source.toString();
|
||||
if(toStr !== "function() {}" && toStr !== "[object Object]") {
|
||||
return toStr;
|
||||
}
|
||||
}
|
||||
|
||||
throw Sources.getInvalidSourceError(source);
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
// Defult hashLength also set in global options, duplicated here for tests
|
||||
// v5.0+ key can be Array or literal
|
||||
static getHash(key, hashLength = 30) {
|
||||
if (!Array.isArray(key)) {
|
||||
key = [key];
|
||||
}
|
||||
|
||||
let result = createHashHexSync(...key);
|
||||
return result.slice(0, hashLength);
|
||||
}
|
||||
|
||||
get source() {
|
||||
return this.#source;
|
||||
}
|
||||
|
||||
set source(source) {
|
||||
this.#source = source;
|
||||
}
|
||||
|
||||
get hash() {
|
||||
return this.#hash;
|
||||
}
|
||||
|
||||
set hash(value) {
|
||||
if (value !== this.#hash) {
|
||||
this.#cacheLocationDirty = true;
|
||||
}
|
||||
|
||||
this.#hash = value;
|
||||
}
|
||||
|
||||
get cacheDirectory() {
|
||||
return this.#cacheDirectory;
|
||||
}
|
||||
|
||||
set cacheDirectory(dir) {
|
||||
if (dir !== this.#cacheDirectory) {
|
||||
this.#cacheLocationDirty = true;
|
||||
}
|
||||
|
||||
this.#cacheDirectory = dir;
|
||||
}
|
||||
|
||||
get cacheFilename() {
|
||||
if (typeof this.#customFilename === "string" && this.#customFilename.length > 0) {
|
||||
return this.#customFilename;
|
||||
}
|
||||
|
||||
return `eleventy-fetch-${this.hash}`;
|
||||
}
|
||||
|
||||
get rootDir() {
|
||||
// Work in an AWS Lambda (serverless)
|
||||
// https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html
|
||||
|
||||
// Bad: LAMBDA_TASK_ROOT is /var/task/ on AWS so we must use ELEVENTY_ROOT
|
||||
// When using ELEVENTY_ROOT, cacheDirectory must be relative
|
||||
// (we are bundling the cache files into the serverless function)
|
||||
if (
|
||||
process.env.LAMBDA_TASK_ROOT &&
|
||||
process.env.ELEVENTY_ROOT &&
|
||||
!this.cacheDirectory.startsWith("/")
|
||||
) {
|
||||
return path.resolve(process.env.ELEVENTY_ROOT, this.cacheDirectory);
|
||||
}
|
||||
|
||||
// otherwise, it is recommended to use somewhere in /tmp/ for serverless (otherwise it won’t write)
|
||||
return path.resolve(this.cacheDirectory);
|
||||
}
|
||||
|
||||
get cachePath() {
|
||||
return path.join(this.rootDir, this.cacheFilename);
|
||||
}
|
||||
|
||||
get cache() {
|
||||
if (!this.#cache || this.#cacheLocationDirty) {
|
||||
let cache = new FileCache(this.cacheFilename, {
|
||||
dir: this.rootDir,
|
||||
source: this.source,
|
||||
});
|
||||
cache.setDefaultType(this.options.type);
|
||||
cache.setDryRun(this.options.dryRun);
|
||||
cache.setDirectoryManager(this.#directoryManager);
|
||||
|
||||
this.#cache = cache;
|
||||
this.#cacheLocationDirty = false;
|
||||
}
|
||||
return this.#cache;
|
||||
}
|
||||
|
||||
getDurationMs(duration = "0s") {
|
||||
return DateCompare.getDurationMs(duration);
|
||||
}
|
||||
|
||||
setDirectoryManager(manager) {
|
||||
this.#directoryManager = manager;
|
||||
}
|
||||
|
||||
async save(contents, type = "buffer", metadata = {}) {
|
||||
if(!contents) {
|
||||
throw new Error("save(contents) expects contents (was falsy)");
|
||||
}
|
||||
|
||||
this.cache.set(type, contents, metadata);
|
||||
|
||||
// Dry-run handled downstream
|
||||
this.cache.save();
|
||||
}
|
||||
|
||||
getCachedContents() {
|
||||
return this.cache.getContents();
|
||||
}
|
||||
|
||||
getCachedValue() {
|
||||
if(this.options.returnType === "response") {
|
||||
return {
|
||||
...this.cachedObject.metadata?.response,
|
||||
body: this.getCachedContents(),
|
||||
cache: "hit",
|
||||
}
|
||||
}
|
||||
|
||||
return this.getCachedContents();
|
||||
}
|
||||
|
||||
getCachedTimestamp() {
|
||||
return this.cachedObject?.cachedAt;
|
||||
}
|
||||
|
||||
isCacheValid(duration = this.duration) {
|
||||
if(!this.cachedObject || !this.cachedObject?.cachedAt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.cachedObject?.type && DateCompare.isTimestampWithinDuration(this.cachedObject?.cachedAt, duration)) {
|
||||
return this.cache.hasContents(this.cachedObject?.type); // check file system to make files haven’t been purged.
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
get cachedObject() {
|
||||
return this.cache.get();
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
needsToFetch(duration) {
|
||||
return !this.isCacheValid(duration);
|
||||
}
|
||||
|
||||
// This is only included for completenes—not on the docs.
|
||||
async fetch(optionsOverride = {}) {
|
||||
if (this.isCacheValid(optionsOverride.duration)) {
|
||||
// promise
|
||||
debug(`Using cached version of: ${this.uniqueKey}`);
|
||||
return this.getCachedValue();
|
||||
}
|
||||
|
||||
debug(`Saving ${this.uniqueKey} to ${this.cacheFilename}`);
|
||||
await this.save(this.source, optionsOverride.type);
|
||||
|
||||
return this.source;
|
||||
}
|
||||
|
||||
// for testing
|
||||
hasAnyCacheFiles() {
|
||||
for(let p of this.cache.getAllPossibleFilePaths()) {
|
||||
if(fs.existsSync(p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// for testing
|
||||
async destroy() {
|
||||
await Promise.all(this.cache.getAllPossibleFilePaths().map(path => {
|
||||
if (fs.existsSync(path)) {
|
||||
return fs.unlinkSync(path);
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
module.exports = AssetCache;
|
||||
22
node_modules/@11ty/eleventy-fetch/src/DirectoryManager.js
generated
vendored
22
node_modules/@11ty/eleventy-fetch/src/DirectoryManager.js
generated
vendored
|
|
@ -1,22 +0,0 @@
|
|||
const fs = require("node:fs");
|
||||
const debugAssets = require("debug")("Eleventy:Assets");
|
||||
|
||||
class DirectoryManager {
|
||||
#dirs = new Set();
|
||||
|
||||
isCreated(dir) {
|
||||
return this.#dirs.has(dir);
|
||||
}
|
||||
|
||||
create(dir) {
|
||||
if(this.isCreated(dir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.#dirs.add(dir);
|
||||
debugAssets("Creating directory %o", dir);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DirectoryManager;
|
||||
24
node_modules/@11ty/eleventy-fetch/src/ExistsCache.js
generated
vendored
24
node_modules/@11ty/eleventy-fetch/src/ExistsCache.js
generated
vendored
|
|
@ -1,24 +0,0 @@
|
|||
const fs = require("node:fs");
|
||||
// const debug = require("debug")("Eleventy:Assets");
|
||||
|
||||
class ExistsCache {
|
||||
#checks = new Map();
|
||||
#count = 0;
|
||||
|
||||
set(target, value) {
|
||||
this.#checks.set(target, Boolean(value));
|
||||
}
|
||||
|
||||
exists(target) {
|
||||
if(this.#checks.has(target)) {
|
||||
return this.#checks.get(target);
|
||||
}
|
||||
|
||||
let exists = fs.existsSync(target);
|
||||
this.#count++;
|
||||
this.#checks.set(target, exists);
|
||||
return exists;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ExistsCache;
|
||||
237
node_modules/@11ty/eleventy-fetch/src/FileCache.js
generated
vendored
237
node_modules/@11ty/eleventy-fetch/src/FileCache.js
generated
vendored
|
|
@ -1,237 +0,0 @@
|
|||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const debugUtil = require("debug");
|
||||
const { parse } = require("flatted");
|
||||
|
||||
const debug = debugUtil("Eleventy:Fetch");
|
||||
const debugAssets = debugUtil("Eleventy:Assets");
|
||||
|
||||
const DirectoryManager = require("./DirectoryManager.js");
|
||||
const ExistsCache = require("./ExistsCache.js");
|
||||
|
||||
let existsCache = new ExistsCache();
|
||||
|
||||
class FileCache {
|
||||
#source;
|
||||
#directoryManager;
|
||||
#metadata;
|
||||
#defaultType;
|
||||
#contents;
|
||||
#dryRun = false;
|
||||
#cacheDirectory = ".cache";
|
||||
#savePending = false;
|
||||
#counts = {
|
||||
read: 0,
|
||||
write: 0,
|
||||
};
|
||||
|
||||
constructor(cacheFilename, options = {}) {
|
||||
this.cacheFilename = cacheFilename;
|
||||
if(options.dir) {
|
||||
this.#cacheDirectory = options.dir;
|
||||
}
|
||||
if(options.source) {
|
||||
this.#source = options.source;
|
||||
}
|
||||
}
|
||||
|
||||
setDefaultType(type) {
|
||||
if(type) {
|
||||
this.#defaultType = type;
|
||||
}
|
||||
}
|
||||
|
||||
setDryRun(val) {
|
||||
this.#dryRun = Boolean(val);
|
||||
}
|
||||
|
||||
setDirectoryManager(manager) {
|
||||
this.#directoryManager = manager;
|
||||
}
|
||||
|
||||
ensureDir() {
|
||||
if (this.#dryRun || existsCache.exists(this.#cacheDirectory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.#directoryManager) {
|
||||
// standalone fallback (for tests)
|
||||
this.#directoryManager = new DirectoryManager();
|
||||
}
|
||||
|
||||
this.#directoryManager.create(this.#cacheDirectory);
|
||||
}
|
||||
|
||||
set(type, contents, extraMetadata = {}) {
|
||||
this.#savePending = true;
|
||||
|
||||
this.#metadata = {
|
||||
cachedAt: Date.now(),
|
||||
type,
|
||||
// source: this.#source,
|
||||
metadata: extraMetadata,
|
||||
};
|
||||
|
||||
this.#contents = contents;
|
||||
}
|
||||
|
||||
get fsPath() {
|
||||
return path.join(this.#cacheDirectory, this.cacheFilename);
|
||||
}
|
||||
|
||||
getContentsPath(type) {
|
||||
if(!type) {
|
||||
throw new Error("Missing cache type for " + this.fsPath);
|
||||
}
|
||||
|
||||
// normalize to storage type
|
||||
if(type === "xml") {
|
||||
type = "text";
|
||||
} else if(type === "parsed-xml") {
|
||||
type = "json";
|
||||
}
|
||||
|
||||
return `${this.fsPath}.${type}`;
|
||||
}
|
||||
|
||||
// only when side loaded (buffer content)
|
||||
get contentsPath() {
|
||||
return this.getContentsPath(this.#metadata?.type);
|
||||
}
|
||||
|
||||
get() {
|
||||
if(this.#metadata) {
|
||||
return this.#metadata;
|
||||
}
|
||||
|
||||
if(!existsCache.exists(this.fsPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug(`Fetching from cache ${this.fsPath}`);
|
||||
if(this.#source) {
|
||||
debugAssets("[11ty/eleventy-fetch] Reading via %o", this.#source);
|
||||
} else {
|
||||
debugAssets("[11ty/eleventy-fetch] Reading %o", this.fsPath);
|
||||
}
|
||||
|
||||
this.#counts.read++;
|
||||
let data = fs.readFileSync(this.fsPath, "utf8");
|
||||
|
||||
let json;
|
||||
// Backwards compatibility with previous caches usingn flat-cache and `flatted`
|
||||
if(data.startsWith(`[["1"],`)) {
|
||||
let flattedParsed = parse(data);
|
||||
if(flattedParsed?.[0]?.value) {
|
||||
json = flattedParsed?.[0]?.value
|
||||
}
|
||||
} else {
|
||||
json = JSON.parse(data);
|
||||
}
|
||||
|
||||
this.#metadata = json;
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
_backwardsCompatGetContents(rawData, type) {
|
||||
if (type === "json") {
|
||||
return rawData.contents;
|
||||
} else if (type === "text") {
|
||||
return rawData.contents.toString();
|
||||
}
|
||||
|
||||
// buffer
|
||||
return Buffer.from(rawData.contents);
|
||||
}
|
||||
|
||||
hasContents(type) {
|
||||
if(this.#contents) {
|
||||
return true;
|
||||
}
|
||||
if(this.get()?.contents) { // backwards compat with very old caches
|
||||
return true;
|
||||
}
|
||||
return existsCache.exists(this.getContentsPath(type));
|
||||
}
|
||||
|
||||
getType() {
|
||||
return this.#metadata?.type || this.#defaultType;
|
||||
}
|
||||
|
||||
getContents() {
|
||||
if(this.#contents) {
|
||||
return this.#contents;
|
||||
}
|
||||
|
||||
let metadata = this.get();
|
||||
// backwards compat with old caches
|
||||
if(metadata?.contents) {
|
||||
// already parsed, part of the top level file
|
||||
let normalizedContent = this._backwardsCompatGetContents(this.get(), this.getType());
|
||||
this.#contents = normalizedContent;
|
||||
return normalizedContent;
|
||||
}
|
||||
|
||||
if(!existsCache.exists(this.contentsPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug(`Fetching from cache ${this.contentsPath}`);
|
||||
if(this.#source) {
|
||||
debugAssets("[11ty/eleventy-fetch] Reading (side loaded) via %o", this.#source);
|
||||
} else {
|
||||
debugAssets("[11ty/eleventy-fetch] Reading (side loaded) %o", this.contentsPath);
|
||||
}
|
||||
|
||||
// It is intentional to store contents in a separate file from the metadata: we don’t want to
|
||||
// have to read the entire contents via JSON.parse (or otherwise) to check the cache validity.
|
||||
this.#counts.read++;
|
||||
let type = metadata?.type || this.getType();
|
||||
let data = fs.readFileSync(this.contentsPath);
|
||||
if (type === "json" || type === "parsed-xml") {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
this.#contents = data;
|
||||
return data;
|
||||
}
|
||||
|
||||
save() {
|
||||
if(this.#dryRun || !this.#savePending || this.#metadata && Object.keys(this.#metadata) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.ensureDir(); // doesn’t add to counts (yet?)
|
||||
|
||||
// contents before metadata
|
||||
debugAssets("[11ty/eleventy-fetch] Writing %o (side loaded) from %o", this.contentsPath, this.#source);
|
||||
|
||||
this.#counts.write++;
|
||||
// the contents must exist before the cache metadata are saved below
|
||||
let contents = this.#contents;
|
||||
let type = this.getType();
|
||||
if (type === "json" || type === "parsed-xml") {
|
||||
contents = JSON.stringify(contents);
|
||||
}
|
||||
fs.writeFileSync(this.contentsPath, contents);
|
||||
debug(`Writing ${this.contentsPath}`);
|
||||
|
||||
this.#counts.write++;
|
||||
debugAssets("[11ty/eleventy-fetch] Writing %o from %o", this.fsPath, this.#source);
|
||||
fs.writeFileSync(this.fsPath, JSON.stringify(this.#metadata), "utf8");
|
||||
debug(`Writing ${this.fsPath}`);
|
||||
}
|
||||
|
||||
// for testing
|
||||
getAllPossibleFilePaths() {
|
||||
let types = ["text", "buffer", "json"];
|
||||
let paths = new Set();
|
||||
paths.add(this.fsPath);
|
||||
for(let type of types) {
|
||||
paths.add(this.getContentsPath(type));
|
||||
}
|
||||
return Array.from(paths);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FileCache;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue