Skip to content

Commit

Permalink
Set all pages version & copyright year text dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
daveknights committed Oct 21, 2023
1 parent eff2c03 commit 19c7455
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
5 changes: 3 additions & 2 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<li><a href="https://github.com/daveknights/cre8bit/blob/main/.github/README.md" target="_blank">Documentation</a></li>
<li><a href="../examples" class="active">Examples</a></li>
<li><a href="../playground">Playground</a></li>
<li><a class="btn" href="https://www.npmjs.com/package/cre8bitjs" target="_blank">Install v2.0.0</a></li>
<li><a class="btn" href="https://www.npmjs.com/package/cre8bitjs" target="_blank">Install <span class="v-btn"></span></a></li>
</ul>
</div>
</nav>
Expand Down Expand Up @@ -175,13 +175,14 @@ <h3>JS Code Required</h3>
<a href="https://github.com/daveknights/cre8bit" target="_blank">
<img src="../images/cre8bit-logo.png" class="footer-logo" alt="cre8bitJS" height="31" width="31" loading="lazy">
</a>
<p>cre8bitJS v2.0.0 | &copy; Dave Knights 2023</p>
<p>cre8bitJS <span class="v-footer"></span> | &copy; Dave Knights <span class="year"></span></p>
<ul class="footer-links flex">
<li><a href="https://github.com/daveknights/cre8bit/releases" target="_blank">Release notes</a></li>
<li><a href="https://www.npmjs.com/package/cre8bitjs-minified" target="_blank">Minified version</a></li>
</ul>
</div>
</footer>
<script src="../version-year.js"></script>
<script src="../nav.js"></script>
<script type="module" src="../examples/script.js"></script>
</body>
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ <h3><a href="https://github.com/daveknights/cre8bit#helper-methods" target="_bla
</ul>
</div>
</footer>
<script src="./version-year.js"></script>
<script src="./nav.js"></script>
<script src="./script.js" type="module"></script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<li><a href="https://github.com/daveknights/cre8bit/blob/main/.github/README.md" target="_blank">Documentation</a></li>
<li><a href="../examples">Examples</a></li>
<li><a href="../playground" class="active">Playground</a></li>
<li><a class="btn" href="https://www.npmjs.com/package/cre8bitjs" target="_blank">Install v2.0.0</a></li>
<li><a class="btn" href="https://www.npmjs.com/package/cre8bitjs" target="_blank">Install <span class="v-btn"></span></a></li>
</ul>
</div>
</nav>
Expand Down Expand Up @@ -118,13 +118,14 @@ <h2>JS Code Required</h2>
<a href="https://github.com/daveknights/cre8bit" target="_blank">
<img src="../images/cre8bit-logo.png" class="footer-logo" alt="cre8bitJS" height="31" width="31" loading="lazy">
</a>
<p>cre8bitJS v2.0.0 | &copy; Dave Knights 2023</p>
<p>cre8bitJS <span class="v-footer"></span> | &copy; Dave Knights <span class="year"></span></p>
<ul class="footer-links flex">
<li><a href="https://github.com/daveknights/cre8bit/releases" target="_blank">Release notes</a></li>
<li><a href="https://www.npmjs.com/package/cre8bitjs-minified" target="_blank">Minified version</a></li>
</ul>
</div>
</footer>
<script src="../version-year.js"></script>
<script src="../nav.js"></script>
<script type="module" src="../playground/script.js"></script>
</body>
Expand Down
12 changes: 0 additions & 12 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import cre8bit from './cre8bit.min.js'

const setVersionAndYear = async () => {
const res = await fetch('https://api.github.com/repos/daveknights/cre8bit/tags');
const json = await res.json();
const version = json[0].name;

document.querySelector('.v-btn').textContent = version;
document.querySelector('.v-footer').textContent = version;
document.querySelector('.year').textContent = new Date().getFullYear();
};

setVersionAndYear();

const getSize = size => {
switch (true) {
case window.innerWidth > 1099:
Expand Down
11 changes: 11 additions & 0 deletions version-year.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const setVersionAndYear = async () => {
const res = await fetch('https://api.github.com/repos/daveknights/cre8bit/tags');
const json = await res.json();
const version = json[0].name;

document.querySelector('.v-btn').textContent = version;
document.querySelector('.v-footer').textContent = version;
document.querySelector('.year').textContent = new Date().getFullYear();
};

setVersionAndYear();

0 comments on commit 19c7455

Please sign in to comment.